View Javadoc

1   package gov.nasa.pds.ltdt.testLabel;
2   
3   import gov.nasa.pds.tools.dict.type.Types;
4   import gov.nasa.pds.tools.dict.type.UnsupportedTypeException;
5   
6   public class TestValueFactory implements Types {
7   	private static TestValueFactory factory = null;
8   	
9   	private TestValueFactory(){}
10  	
11  	public static synchronized TestValueFactory getInstance() {
12  		if(factory == null)
13  			factory = new TestValueFactory();
14  		return factory;
15  	}
16  	
17  	public TestValue newInstance(String type) throws UnsupportedTypeException {
18  		TestValue value = null;
19  		
20  		if(type.equals(REAL)) {
21  			value = new RealTestValue();
22  		} else if(type.equals(DOUBLE)) {
23  			value = new DoubleTestValue();
24  		} else if(type.equals(INTEGER) || type.equals(ASCII_INTEGER)) {
25  			value = new IntegerTestValue();
26  		} else if(type.equals(CHARACTER)) {
27  			value = new CharacterTestValue();
28  		} else if(type.equals(ALPHABET)) {
29  			value = new AlphabetTestValue();
30  		} else if(type.equals(ALPHANUMERIC)) {
31  			value = new AlphaNumericTestValue();
32  		} else if(type.equals(DATE)) {
33  			value = new DateTestValue();
34  		} else if(type.equals(TIME)) {
35  			value = new TimeTestValue();
36  		} else if(type.equals(NONDECIMAL) || type.equals(NON_DECIMAL)) {
37  			value = new NonDecimalTestValue();
38  		} else if(type.equals(DATA_SET)) {
39  			value = new DataSetTestValue();
40  		} else if(type.equals(IDENTIFIER)) {
41  			value = new IdentifierTestValue();
42  		} else if(type.equals(CONTEXT_DEPENDENT) || type.equals(CONTEXTDEPENDENT)) {
43  			value = new ContextDependentTestValue();
44  		}
45  		
46  		if(value == null)
47  			throw new UnsupportedTypeException(type + " is not a supported type.");
48  		
49  		return value;
50  		
51  	}
52  }