View Javadoc

1   // Copyright 2006-2007, by the California Institute of Technology.
2   // ALL RIGHTS RESERVED. United States Government Sponsorship acknowledged.
3   // Any commercial use must be negotiated with the Office of Technology Transfer
4   // at the California Institute of Technology.
5   //
6   // This software is subject to U. S. export control laws and regulations
7   // (22 C.F.R. 120-130 and 15 C.F.R. 730-774). To the extent that the software
8   // is subject to U.S. export control laws and regulations, the recipient has
9   // the responsibility to obtain export licenses or other export authority as
10  // may be required before exporting such information to foreign countries or
11  // providing access to foreign nationals.
12  //
13  // $Id: LabelParserFactory.java 2606 2007-04-18 19:35:09Z pramirez $ 
14  //
15  
16  package gov.nasa.pds.tools.label.parser;
17  
18  import gov.nasa.pds.tools.label.validate.FileCharacteristicValidator;
19  
20  /***
21   * This class will be used to generate label parsers.
22   * @author pramirez
23   * @version $Revision: 2606 $
24   * 
25   */
26  public class LabelParserFactory {
27      private static LabelParserFactory factory = null;
28      
29      /***
30       * Constructs a parser factory following the Singleton pattern
31       */
32      private LabelParserFactory() {
33      }
34      
35      /***
36       * Retrieve a factory which will create
37       * @return parser factory that will generate parsers
38       */
39      public synchronized static LabelParserFactory getInstance() {
40          if (factory == null) 
41              factory = new LabelParserFactory();
42          
43          return factory;
44      }
45      
46      /***
47       * Retrieves a parser that will read in PDS label files.
48       * @return The parser
49       */
50      public LabelParser newLabelParser() {
51          // TODO: Change to dynamic class loading based upon configuration
52          LabelParser parser = new DefaultLabelParser();
53          parser.addValidator(new FileCharacteristicValidator());
54          return parser;
55      }
56  
57  }