1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package gov.nasa.pds.tools.label.parser;
17
18 import gov.nasa.pds.tools.label.validate.FileCharacteristicValidator;
19 import gov.nasa.pds.tools.label.validate.DuplicateIdentifierValidator;
20
21 /***
22 * This class will be used to generate label parsers.
23 * @author pramirez
24 * @version $Revision: 2904 $
25 *
26 */
27 public class LabelParserFactory {
28 private static LabelParserFactory factory = null;
29
30 /***
31 * Constructs a parser factory following the Singleton pattern
32 */
33 private LabelParserFactory() {
34 }
35
36 /***
37 * Retrieve a factory which will create
38 * @return parser factory that will generate parsers
39 */
40 public synchronized static LabelParserFactory getInstance() {
41 if (factory == null)
42 factory = new LabelParserFactory();
43
44 return factory;
45 }
46
47 /***
48 * Retrieves a parser that will read in PDS label files.
49 * @return The parser
50 */
51 public LabelParser newLabelParser() {
52
53 LabelParser parser = new DefaultLabelParser();
54 parser.addValidator(new FileCharacteristicValidator());
55 parser.addValidator(new DuplicateIdentifierValidator());
56 return parser;
57 }
58
59 }