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.CatalogNameValidator;
19 import gov.nasa.pds.tools.label.validate.FileCharacteristicValidator;
20 import gov.nasa.pds.tools.label.validate.DuplicateIdentifierValidator;
21
22 /***
23 * This class will be used to generate label parsers.
24 * @author pramirez
25 * @version $Revision: 3836 $
26 *
27 */
28 public class LabelParserFactory {
29 private static LabelParserFactory factory = null;
30
31 /***
32 * Constructs a parser factory following the Singleton pattern
33 */
34 private LabelParserFactory() {
35 }
36
37 /***
38 * Retrieve a factory which will create
39 * @return parser factory that will generate parsers
40 */
41 public synchronized static LabelParserFactory getInstance() {
42 if (factory == null)
43 factory = new LabelParserFactory();
44
45 return factory;
46 }
47
48 /***
49 * Retrieves a parser that will read in PDS label files.
50 * @return The parser
51 */
52 public LabelParser newLabelParser() {
53
54 LabelParser parser = new DefaultLabelParser();
55 parser.addLabelValidator(new FileCharacteristicValidator());
56 parser.addLabelValidator(new DuplicateIdentifierValidator());
57 parser.addLabelValidator(new CatalogNameValidator());
58 parser.addFragmentValidator(new DuplicateIdentifierValidator());
59 return parser;
60 }
61
62 }