1
2
3
4
5
6
7
8 package org.astrogrid.registry.beans.v10.resource.dataservice.types;
9
10
11
12
13
14 import java.io.Serializable;
15 import java.util.Enumeration;
16 import java.util.Hashtable;
17 import org.exolab.castor.xml.Marshaller;
18 import org.exolab.castor.xml.Unmarshaller;
19
20 /***
21 * Class ScalarDataType.
22 *
23 * @version $Revision: 1.2 $ $Date: 2007/01/04 16:26:19 $
24 */
25 public class ScalarDataType implements java.io.Serializable {
26
27
28
29
30
31
32 /***
33 * The boolean type
34 */
35 public static final int BOOLEAN_TYPE = 0;
36
37 /***
38 * The instance of the boolean type
39 */
40 public static final ScalarDataType BOOLEAN = new ScalarDataType(BOOLEAN_TYPE, "boolean");
41
42 /***
43 * The bit type
44 */
45 public static final int BIT_TYPE = 1;
46
47 /***
48 * The instance of the bit type
49 */
50 public static final ScalarDataType BIT = new ScalarDataType(BIT_TYPE, "bit");
51
52 /***
53 * The unsignedByte type
54 */
55 public static final int UNSIGNEDBYTE_TYPE = 2;
56
57 /***
58 * The instance of the unsignedByte type
59 */
60 public static final ScalarDataType UNSIGNEDBYTE = new ScalarDataType(UNSIGNEDBYTE_TYPE, "unsignedByte");
61
62 /***
63 * The short type
64 */
65 public static final int SHORT_TYPE = 3;
66
67 /***
68 * The instance of the short type
69 */
70 public static final ScalarDataType SHORT = new ScalarDataType(SHORT_TYPE, "short");
71
72 /***
73 * The int type
74 */
75 public static final int INT_TYPE = 4;
76
77 /***
78 * The instance of the int type
79 */
80 public static final ScalarDataType INT = new ScalarDataType(INT_TYPE, "int");
81
82 /***
83 * The long type
84 */
85 public static final int LONG_TYPE = 5;
86
87 /***
88 * The instance of the long type
89 */
90 public static final ScalarDataType LONG = new ScalarDataType(LONG_TYPE, "long");
91
92 /***
93 * The char type
94 */
95 public static final int CHAR_TYPE = 6;
96
97 /***
98 * The instance of the char type
99 */
100 public static final ScalarDataType CHAR = new ScalarDataType(CHAR_TYPE, "char");
101
102 /***
103 * The unicodeChar type
104 */
105 public static final int UNICODECHAR_TYPE = 7;
106
107 /***
108 * The instance of the unicodeChar type
109 */
110 public static final ScalarDataType UNICODECHAR = new ScalarDataType(UNICODECHAR_TYPE, "unicodeChar");
111
112 /***
113 * The float type
114 */
115 public static final int FLOAT_TYPE = 8;
116
117 /***
118 * The instance of the float type
119 */
120 public static final ScalarDataType FLOAT = new ScalarDataType(FLOAT_TYPE, "float");
121
122 /***
123 * The double type
124 */
125 public static final int DOUBLE_TYPE = 9;
126
127 /***
128 * The instance of the double type
129 */
130 public static final ScalarDataType DOUBLE = new ScalarDataType(DOUBLE_TYPE, "double");
131
132 /***
133 * The floatComplex type
134 */
135 public static final int FLOATCOMPLEX_TYPE = 10;
136
137 /***
138 * The instance of the floatComplex type
139 */
140 public static final ScalarDataType FLOATCOMPLEX = new ScalarDataType(FLOATCOMPLEX_TYPE, "floatComplex");
141
142 /***
143 * The doubleComplex type
144 */
145 public static final int DOUBLECOMPLEX_TYPE = 11;
146
147 /***
148 * The instance of the doubleComplex type
149 */
150 public static final ScalarDataType DOUBLECOMPLEX = new ScalarDataType(DOUBLECOMPLEX_TYPE, "doubleComplex");
151
152 /***
153 * Field _memberTable
154 */
155 private static java.util.Hashtable _memberTable = init();
156
157 /***
158 * Field type
159 */
160 private int type = -1;
161
162 /***
163 * Field stringValue
164 */
165 private java.lang.String stringValue = null;
166
167
168
169
170
171
172 private ScalarDataType(int type, java.lang.String value) {
173 super();
174 this.type = type;
175 this.stringValue = value;
176 }
177
178
179
180
181
182
183 /***
184 * Method enumerateReturns an enumeration of all possible
185 * instances of ScalarDataType
186 */
187 public static java.util.Enumeration enumerate()
188 {
189 return _memberTable.elements();
190 }
191
192 /***
193 * Method getTypeReturns the type of this ScalarDataType
194 */
195 public int getType()
196 {
197 return this.type;
198 }
199
200 /***
201 * Method init
202 */
203 private static java.util.Hashtable init()
204 {
205 Hashtable members = new Hashtable();
206 members.put("boolean", BOOLEAN);
207 members.put("bit", BIT);
208 members.put("unsignedByte", UNSIGNEDBYTE);
209 members.put("short", SHORT);
210 members.put("int", INT);
211 members.put("long", LONG);
212 members.put("char", CHAR);
213 members.put("unicodeChar", UNICODECHAR);
214 members.put("float", FLOAT);
215 members.put("double", DOUBLE);
216 members.put("floatComplex", FLOATCOMPLEX);
217 members.put("doubleComplex", DOUBLECOMPLEX);
218 return members;
219 }
220
221 /***
222 * Method toStringReturns the String representation of this
223 * ScalarDataType
224 */
225 public java.lang.String toString()
226 {
227 return this.stringValue;
228 }
229
230 /***
231 * Method valueOfReturns a new ScalarDataType based on the
232 * given String value.
233 *
234 * @param string
235 */
236 public static org.astrogrid.registry.beans.v10.resource.dataservice.types.ScalarDataType valueOf(java.lang.String string)
237 {
238 java.lang.Object obj = null;
239 if (string != null) obj = _memberTable.get(string);
240 if (obj == null) {
241 String err = "'" + string + "' is not a valid ScalarDataType";
242 throw new IllegalArgumentException(err);
243 }
244 return (ScalarDataType) obj;
245 }
246
247 }