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: TypeCheckerFactory.java 2601 2007-04-12 18:34:25Z pramirez $ 
14  //
15  
16  package gov.nasa.pds.tools.dict.type;
17  
18  /***
19   * @author pramirez
20   * @version $Revision: 2601 $
21   * 
22   */
23  public class TypeCheckerFactory implements Types{
24      private static TypeCheckerFactory factory = null;
25      
26      private TypeCheckerFactory() {
27          //TODO: Consider supporting dynamic types. This could
28          //loading a mapping at this point
29      }
30      
31      public static synchronized TypeCheckerFactory getInstance() {
32          if (factory == null)
33              factory = new TypeCheckerFactory();
34          return factory;
35      }
36      
37      public TypeChecker newInstance(String type) throws UnsupportedTypeException {
38          TypeChecker checker = null;
39          
40          if (type.equals(REAL)) {
41              checker = new RealChecker();
42          } else if (type.equals(DOUBLE)) {
43              checker = new DoubleChecker();
44          } else if (type.equals(INTEGER) || type.equals(ASCII_INTEGER)) {
45              checker = new IntegerChecker();
46          } else if (type.equals(CHARACTER)) {
47              checker = new CharacterChecker();
48          } else if (type.equals(ALPHABET)) {
49              checker = new AlphabetChecker();
50          } else if (type.equals(ALPHANUMERIC)) {
51              checker = new AlphaNumericChecker();
52          } else if (type.equals(DATE)) {
53              checker = new DateChecker();
54          } else if (type.equals(TIME)) {
55              checker = new TimeChecker();
56          } else if (type.equals(NONDECIMAL) || type.equals(NON_DECIMAL)) {
57              checker = new NonDecimalChecker();
58          } else if (type.equals(DATA_SET)) {
59              checker = new DataSetChecker();
60          } else if (type.equals(IDENTIFIER)) {
61              checker = new IdentifierChecker();
62          } else if (type.equals(CONTEXT_DEPENDENT) || type.equals(CONTEXTDEPENDENT)) {
63              checker = new ContextDependentChecker();
64          }
65          
66          if (checker == null)
67              throw new UnsupportedTypeException(type + " is not a supported type.");
68          
69          return checker;
70      }
71  }