|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| package org.deri.wsmo4j.factory; |
|
17 |
| |
|
18 |
| |
|
19 |
| import java.math.*; |
|
20 |
| import java.util.*; |
|
21 |
| |
|
22 |
| import org.omwg.ontology.*; |
|
23 |
| import org.wsmo.common.*; |
|
24 |
| import org.wsmo.factory.*; |
|
25 |
| |
|
26 |
| import com.ontotext.wsmo4j.ontology.*; |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| public class DataFactoryImpl |
|
42 |
| implements DataFactory { |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| private HashMap <String, SimpleDataType[]> complexDataTypeConstructors = new HashMap <String, SimpleDataType[]> (); |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
| private HashMap <String, Class> complexDataTypeJavaMapping = new HashMap <String, Class> (); |
|
53 |
| |
|
54 |
| private HashMap <String, SimpleDataType> simpleDataTypes = new HashMap <String, SimpleDataType> (); |
|
55 |
| |
|
56 |
| private SimpleDataType decimal; |
|
57 |
| |
|
58 |
| private SimpleDataType integer; |
|
59 |
| |
|
60 |
| private SimpleDataType string; |
|
61 |
| |
|
62 |
| private WsmoFactory factory; |
|
63 |
| |
|
64 |
0
| public DataFactoryImpl() {
|
|
65 |
0
| this(null);
|
|
66 |
| } |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
0
| public DataFactoryImpl(Map map) {
|
|
77 |
0
| if (map != null && map.containsKey(DATAFACTORY_WSMO_FACTORY)) {
|
|
78 |
0
| factory = (WsmoFactory) map.get(DATAFACTORY_WSMO_FACTORY);
|
|
79 |
| } |
|
80 |
0
| if (factory == null) {
|
|
81 |
0
| factory = Factory.createWsmoFactory(null);
|
|
82 |
| } |
|
83 |
| |
|
84 |
0
| decimal = new SimpleDataTypeImpl(factory.createIRI(WsmlDataType.WSML_DECIMAL));
|
|
85 |
0
| integer = new SimpleDataTypeImpl(factory.createIRI(WsmlDataType.WSML_INTEGER));
|
|
86 |
0
| string = new SimpleDataTypeImpl(factory.createIRI(WsmlDataType.WSML_STRING));
|
|
87 |
| |
|
88 |
0
| simpleDataTypes.put(WsmlDataType.WSML_INTEGER, integer);
|
|
89 |
0
| simpleDataTypes.put(WsmlDataType.WSML_STRING, string);
|
|
90 |
0
| simpleDataTypes.put(WsmlDataType.WSML_DECIMAL, decimal);
|
|
91 |
| |
|
92 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_FLOAT,
|
|
93 |
| new SimpleDataType[] {string}); |
|
94 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_FLOAT, Float.class);
|
|
95 |
| |
|
96 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_DOUBLE,
|
|
97 |
| new SimpleDataType[] {string}); |
|
98 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_DOUBLE, Double.class);
|
|
99 |
| |
|
100 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_IRI,
|
|
101 |
| new SimpleDataType[] {string}); |
|
102 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_IRI, String.class);
|
|
103 |
| |
|
104 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_SQNAME,
|
|
105 |
| new SimpleDataType[] {string, string}); |
|
106 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_SQNAME, String[].class);
|
|
107 |
| |
|
108 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_BOOLEAN,
|
|
109 |
| new SimpleDataType[] {string}); |
|
110 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_BOOLEAN, Boolean.class);
|
|
111 |
| |
|
112 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_DURATION,
|
|
113 |
| new SimpleDataType[] {integer, integer, integer, |
|
114 |
| integer, integer, integer}); |
|
115 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_DURATION, String.class);
|
|
116 |
| |
|
117 |
| |
|
118 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_DATETIME,
|
|
119 |
| new SimpleDataType[] {integer, integer, integer, |
|
120 |
| integer, integer, decimal, integer, integer}); |
|
121 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_DATETIME, Calendar.class);
|
|
122 |
| |
|
123 |
| |
|
124 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_TIME,
|
|
125 |
| new SimpleDataType[] {integer, integer, decimal, |
|
126 |
| integer, integer}); |
|
127 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_TIME, Calendar.class);
|
|
128 |
| |
|
129 |
| |
|
130 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_DATE,
|
|
131 |
| new SimpleDataType[] {integer, integer, integer, |
|
132 |
| integer, integer}); |
|
133 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_DATE, Calendar.class);
|
|
134 |
| |
|
135 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_GYEARMONTH,
|
|
136 |
| new SimpleDataType[] {integer, integer}); |
|
137 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_GYEARMONTH, Integer[].class);
|
|
138 |
| |
|
139 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_GMONTHDAY,
|
|
140 |
| new SimpleDataType[] {integer, integer}); |
|
141 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_GMONTHDAY, Integer[].class);
|
|
142 |
| |
|
143 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_GYEAR,
|
|
144 |
| new SimpleDataType[] {integer}); |
|
145 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_GYEAR, Integer.class);
|
|
146 |
| |
|
147 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_GDAY,
|
|
148 |
| new SimpleDataType[] {integer}); |
|
149 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_GDAY, Integer.class);
|
|
150 |
| |
|
151 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_GMONTH,
|
|
152 |
| new SimpleDataType[] {integer}); |
|
153 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_GMONTH, Integer.class);
|
|
154 |
| |
|
155 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_HEXBINARY,
|
|
156 |
| new SimpleDataType[] {string}); |
|
157 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_GDAY, String.class);
|
|
158 |
| |
|
159 |
0
| complexDataTypeConstructors.put(WsmlDataType.WSML_BASE64BINARY,
|
|
160 |
| new SimpleDataType[] {string}); |
|
161 |
0
| complexDataTypeJavaMapping.put(WsmlDataType.WSML_GDAY, String.class);
|
|
162 |
| } |
|
163 |
| |
|
164 |
0
| public ComplexDataValue createDataValue(ComplexDataType type, SimpleDataValue argumentValues) {
|
|
165 |
0
| return createDataValue(type, new SimpleDataValue[] {argumentValues});
|
|
166 |
| } |
|
167 |
| |
|
168 |
0
| public ComplexDataValue createDataValue(ComplexDataType type, SimpleDataValue[] argumentValues) {
|
|
169 |
0
| String typeIRIString = type.getIRI().toString();
|
|
170 |
| |
|
171 |
0
| if (type.getArity() != argumentValues.length) {
|
|
172 |
0
| if (!((typeIRIString.equals(WsmlDataType.WSML_DATE) ||
|
|
173 |
| typeIRIString.equals(WsmlDataType.WSML_DATETIME) || |
|
174 |
| typeIRIString.equals(WsmlDataType.WSML_TIME)) && |
|
175 |
| type.getArity() - 2 == argumentValues.length)) { |
|
176 |
0
| throw new IllegalArgumentException("Data type " + typeIRIString +
|
|
177 |
| " must have " + type.getArity() + " number of arguments"); |
|
178 |
| } |
|
179 |
| } |
|
180 |
| |
|
181 |
0
| SimpleDataType[] types = complexDataTypeConstructors.get(typeIRIString);
|
|
182 |
0
| if (types == null) {
|
|
183 |
0
| throw new IllegalArgumentException("Data type" + type.getIRI().toString() +
|
|
184 |
| " not supported!"); |
|
185 |
| } |
|
186 |
| |
|
187 |
0
| for (byte i = 0; i < argumentValues.length; i++) {
|
|
188 |
0
| if (!argumentValues[i].getType().equals(types[i])) {
|
|
189 |
0
| throw new IllegalArgumentException("Wrong type of Argument for complex datatype " +
|
|
190 |
| typeIRIString + ": Found at position " + i + ": " + |
|
191 |
| argumentValues[i].getType().getIRI() + " Expected: " + types[i].getIRI()); |
|
192 |
| } |
|
193 |
| } |
|
194 |
| |
|
195 |
0
| return new ComplexDataValueImpl(type, argumentValues);
|
|
196 |
| } |
|
197 |
| |
|
198 |
| |
|
199 |
| |
|
200 |
| |
|
201 |
| |
|
202 |
| |
|
203 |
| |
|
204 |
0
| public DataValue createDataValueFromJavaObject(WsmlDataType type, Object value) {
|
|
205 |
0
| if (type instanceof SimpleDataType) {
|
|
206 |
0
| if (type.getIRI().toString().equals(WsmlDataType.WSML_INTEGER)){
|
|
207 |
0
| return createWsmlInteger(value.toString());
|
|
208 |
| } |
|
209 |
0
| else if (type.getIRI().toString().equals(WsmlDataType.WSML_DECIMAL)) {
|
|
210 |
0
| return createWsmlDecimal(value.toString());
|
|
211 |
| } |
|
212 |
| else { |
|
213 |
0
| return createWsmlString(value.toString());
|
|
214 |
| } |
|
215 |
| } |
|
216 |
| else { |
|
217 |
| |
|
218 |
0
| Class javaType = complexDataTypeJavaMapping.get(type.getIRI().toString());
|
|
219 |
0
| if (javaType == null) {
|
|
220 |
0
| throw new IllegalArgumentException("Data type" + type.getIRI().toString() +
|
|
221 |
| " not supported!"); |
|
222 |
| } |
|
223 |
| |
|
224 |
0
| if (!javaType.isInstance(value)) {
|
|
225 |
0
| throw new IllegalArgumentException("Java value for type " + type.getIRI().toString() +
|
|
226 |
| " must be of type " + javaType + " (Found: " + value.getClass() + ")"); |
|
227 |
| } |
|
228 |
0
| return new ComplexDataValueImpl((ComplexDataType)type,
|
|
229 |
| createSimpleTypesFromJavaValue((ComplexDataType)type, value)); |
|
230 |
| } |
|
231 |
| |
|
232 |
| } |
|
233 |
| |
|
234 |
0
| public SimpleDataValue createWsmlDecimal(BigDecimal value) {
|
|
235 |
0
| return new SimpleDataValueImpl(simpleDataTypes.get(WsmlDataType.WSML_DECIMAL), value);
|
|
236 |
| } |
|
237 |
| |
|
238 |
0
| public SimpleDataValue createWsmlInteger(BigInteger value) {
|
|
239 |
0
| return new SimpleDataValueImpl( simpleDataTypes.get(WsmlDataType.WSML_INTEGER), value);
|
|
240 |
| } |
|
241 |
| |
|
242 |
0
| public SimpleDataValue createWsmlString(String value) {
|
|
243 |
0
| return new SimpleDataValueImpl( simpleDataTypes.get(WsmlDataType.WSML_STRING), value);
|
|
244 |
| } |
|
245 |
| |
|
246 |
0
| public WsmlDataType createWsmlDataType(IRI typeIRI) {
|
|
247 |
0
| return createWsmlDataType(typeIRI.toString());
|
|
248 |
| } |
|
249 |
| |
|
250 |
0
| public WsmlDataType createWsmlDataType(String typeIRI) {
|
|
251 |
0
| if (simpleDataTypes.get(typeIRI) != null) {
|
|
252 |
0
| return simpleDataTypes.get(typeIRI);
|
|
253 |
| } |
|
254 |
0
| SimpleDataType[] types = complexDataTypeConstructors.get(typeIRI);
|
|
255 |
0
| if (types == null) {
|
|
256 |
0
| throw new IllegalArgumentException("Given datatype: <" + typeIRI + "> not supprted");
|
|
257 |
| } |
|
258 |
0
| IRI iri = factory.createIRI(typeIRI);
|
|
259 |
0
| return new ComplexDataTypeImpl(iri, types);
|
|
260 |
| } |
|
261 |
| |
|
262 |
0
| private SimpleDataValue[] createSimpleTypesFromJavaValue(ComplexDataType type, Object value) {
|
|
263 |
0
| String typeIRI = type.getIRI().toString();
|
|
264 |
0
| if (typeIRI.equals(WsmlDataType.WSML_FLOAT) ||
|
|
265 |
| typeIRI.equals(WsmlDataType.WSML_DOUBLE) || |
|
266 |
| typeIRI.equals(WsmlDataType.WSML_BOOLEAN)) { |
|
267 |
0
| return new SimpleDataValue[] {
|
|
268 |
| createWsmlString(value.toString())}; |
|
269 |
| } |
|
270 |
0
| else if (typeIRI.equals(WsmlDataType.WSML_IRI)) {
|
|
271 |
0
| return new SimpleDataValue[] {
|
|
272 |
| createWsmlString(value.toString())}; |
|
273 |
| } |
|
274 |
0
| else if (typeIRI.equals(WsmlDataType.WSML_SQNAME)) {
|
|
275 |
0
| String[] stringArray = (String[])value;
|
|
276 |
0
| if (stringArray.length != 2) {
|
|
277 |
0
| throw new IllegalArgumentException("datatype " + typeIRI + " must have 2 strings as argument!");
|
|
278 |
| } |
|
279 |
0
| return new SimpleDataValue[] {
|
|
280 |
| createWsmlString(stringArray[0]), |
|
281 |
| createWsmlString(stringArray[1])}; |
|
282 |
| } |
|
283 |
0
| else if (typeIRI.equals(WsmlDataType.WSML_DURATION)) {
|
|
284 |
| |
|
285 |
0
| return new SimpleDataValue[] {
|
|
286 |
| createWsmlString(value.toString())}; |
|
287 |
| } |
|
288 |
0
| else if (typeIRI.equals(WsmlDataType.WSML_DATETIME)) {
|
|
289 |
0
| Calendar cal = (Calendar)value;
|
|
290 |
| |
|
291 |
0
| float seconds = cal.get(Calendar.SECOND) + cal.get(Calendar.MILLISECOND) / 1000f;
|
|
292 |
0
| if (cal.isSet(Calendar.ZONE_OFFSET)) {
|
|
293 |
0
| int zoneOffSetHour = cal.getTimeZone().getRawOffset() / 1000 / 60;
|
|
294 |
0
| int zoneOffSetMinute = cal.get(Calendar.ZONE_OFFSET) / 1000 % 60;
|
|
295 |
| |
|
296 |
0
| return new SimpleDataValue[] {
|
|
297 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.YEAR))), |
|
298 |
| createWsmlInteger(new BigInteger("" + (cal.get(Calendar.MONTH) + 1))), |
|
299 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.DAY_OF_MONTH))), |
|
300 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.HOUR_OF_DAY))), |
|
301 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.MINUTE))), |
|
302 |
| createWsmlDecimal(new BigDecimal(String.valueOf(seconds))), |
|
303 |
| createWsmlInteger(new BigInteger("" + zoneOffSetHour)), |
|
304 |
| createWsmlInteger(new BigInteger("" + zoneOffSetMinute))}; |
|
305 |
| } |
|
306 |
| else { |
|
307 |
0
| return new SimpleDataValue[] {
|
|
308 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.YEAR))), |
|
309 |
| createWsmlInteger(new BigInteger("" + (cal.get(Calendar.MONTH) + 1))), |
|
310 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.DAY_OF_MONTH))), |
|
311 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.HOUR_OF_DAY))), |
|
312 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.MINUTE))), |
|
313 |
| createWsmlDecimal(new BigDecimal(seconds))}; |
|
314 |
| } |
|
315 |
| } |
|
316 |
0
| else if (typeIRI.equals(WsmlDataType.WSML_DATE)) {
|
|
317 |
0
| Calendar cal = (Calendar)value;
|
|
318 |
0
| if (cal.isSet(Calendar.ZONE_OFFSET)) {
|
|
319 |
0
| int zoneOffSetHour = cal.getTimeZone().getRawOffset() / 1000 / 60;
|
|
320 |
0
| int zoneOffSetMinute = cal.get(Calendar.ZONE_OFFSET) / 1000 % 60;
|
|
321 |
0
| return new SimpleDataValue[] {
|
|
322 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.YEAR))), |
|
323 |
| createWsmlInteger(new BigInteger("" + (cal.get(Calendar.MONTH) + 1))), |
|
324 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.DAY_OF_MONTH))), |
|
325 |
| createWsmlInteger(new BigInteger("" + zoneOffSetHour)), |
|
326 |
| createWsmlInteger(new BigInteger("" + zoneOffSetMinute))}; |
|
327 |
| } |
|
328 |
| else { |
|
329 |
0
| return new SimpleDataValue[] {
|
|
330 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.YEAR))), |
|
331 |
| createWsmlInteger(new BigInteger("" + (cal.get(Calendar.MONTH) + 1))), |
|
332 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.DAY_OF_MONTH)))}; |
|
333 |
| } |
|
334 |
| } |
|
335 |
0
| else if (typeIRI.equals(WsmlDataType.WSML_TIME)) {
|
|
336 |
0
| Calendar cal = (Calendar)value;
|
|
337 |
0
| float seconds = cal.get(Calendar.SECOND) + cal.get(Calendar.MILLISECOND) / 1000f;
|
|
338 |
0
| if (cal.isSet(Calendar.ZONE_OFFSET)) {
|
|
339 |
0
| int zoneOffSetHour = cal.getTimeZone().getRawOffset() / 1000 / 60;
|
|
340 |
0
| int zoneOffSetMinute = cal.get(Calendar.ZONE_OFFSET) / 1000 % 60;
|
|
341 |
0
| return new SimpleDataValue[] {
|
|
342 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.HOUR_OF_DAY))), |
|
343 |
| createWsmlInteger(new BigInteger("" + (cal.get(Calendar.MINUTE)))), |
|
344 |
| createWsmlDecimal(new BigDecimal(seconds)), |
|
345 |
| createWsmlInteger(new BigInteger("" + zoneOffSetHour)), |
|
346 |
| createWsmlInteger(new BigInteger("" + zoneOffSetMinute))}; |
|
347 |
| } |
|
348 |
| else { |
|
349 |
0
| return new SimpleDataValue[] {
|
|
350 |
| createWsmlInteger(new BigInteger("" + cal.get(Calendar.HOUR_OF_DAY))), |
|
351 |
| createWsmlInteger(new BigInteger("" + (cal.get(Calendar.MINUTE)))), |
|
352 |
| createWsmlDecimal(new BigDecimal(seconds))}; |
|
353 |
| } |
|
354 |
| } |
|
355 |
0
| else if (typeIRI.equals(WsmlDataType.WSML_GYEARMONTH)) {
|
|
356 |
0
| Integer[] integer = (Integer[])value;
|
|
357 |
0
| if (integer.length != 2) {
|
|
358 |
0
| throw new IllegalArgumentException("datatype " + typeIRI + " must have 2 Integers as argument!");
|
|
359 |
| } |
|
360 |
0
| return new SimpleDataValue[] {
|
|
361 |
| createWsmlInteger(new BigInteger("" + integer[0])), |
|
362 |
| createWsmlInteger(new BigInteger("" + integer[1]))}; |
|
363 |
| } |
|
364 |
0
| else if (typeIRI.equals(WsmlDataType.WSML_GMONTHDAY)) {
|
|
365 |
0
| Integer[] integer = (Integer[])value;
|
|
366 |
0
| if (integer.length != 2) {
|
|
367 |
0
| throw new IllegalArgumentException("datatype " + typeIRI + " must have 2 Integers as argument!");
|
|
368 |
| } |
|
369 |
0
| return new SimpleDataValue[] {
|
|
370 |
| createWsmlInteger(new BigInteger("" + integer[0])), |
|
371 |
| createWsmlInteger(new BigInteger("" + integer[1]))}; |
|
372 |
| } |
|
373 |
0
| else if (typeIRI.equals(WsmlDataType.WSML_GYEAR)) {
|
|
374 |
0
| return new SimpleDataValue[] {
|
|
375 |
| createWsmlInteger(new BigInteger("" + value))}; |
|
376 |
| } |
|
377 |
0
| else if (typeIRI.equals(WsmlDataType.WSML_GDAY)) {
|
|
378 |
0
| return new SimpleDataValue[] {
|
|
379 |
| createWsmlInteger(new BigInteger("" + value))}; |
|
380 |
| } |
|
381 |
0
| else if (typeIRI.equals(WsmlDataType.WSML_GMONTH)) {
|
|
382 |
0
| return new SimpleDataValue[] {
|
|
383 |
| createWsmlInteger(new BigInteger("" + value))}; |
|
384 |
| } |
|
385 |
0
| else if (typeIRI.equals(WsmlDataType.WSML_HEXBINARY)) {
|
|
386 |
0
| return new SimpleDataValue[] {
|
|
387 |
| createWsmlString((String)value)}; |
|
388 |
| } |
|
389 |
0
| else if (typeIRI.equals(WsmlDataType.WSML_BASE64BINARY)) {
|
|
390 |
0
| return new SimpleDataValue[] {
|
|
391 |
| createWsmlString((String)value)}; |
|
392 |
| } |
|
393 |
| else { |
|
394 |
0
| throw new UnsupportedOperationException("DataType " + typeIRI + " not supported!");
|
|
395 |
| } |
|
396 |
| } |
|
397 |
| |
|
398 |
0
| public ComplexDataValue createWsmlBoolean(Boolean value) {
|
|
399 |
0
| return (ComplexDataValue)createDataValueFromJavaObject(
|
|
400 |
| createWsmlDataType(WsmlDataType.WSML_BOOLEAN), |
|
401 |
| value); |
|
402 |
| } |
|
403 |
| |
|
404 |
0
| public ComplexDataValue createWsmlBoolean(String value){
|
|
405 |
0
| Boolean bValue = Boolean.valueOf(value);
|
|
406 |
0
| return (ComplexDataValue)createDataValueFromJavaObject(
|
|
407 |
| createWsmlDataType(WsmlDataType.WSML_BOOLEAN), |
|
408 |
| bValue); |
|
409 |
| } |
|
410 |
| |
|
411 |
| |
|
412 |
0
| public ComplexDataValue createWsmlDuration(int year, int month, int day, int hour, int minute, int second){
|
|
413 |
| |
|
414 |
| |
|
415 |
0
| return (ComplexDataValue)createDataValueFromJavaObject(
|
|
416 |
| createWsmlDataType(WsmlDataType.WSML_DURATION), |
|
417 |
| "P"+year+"Y"+month+"M"+day+"DT"+hour+"H"+minute+"M"+second+"S"); |
|
418 |
| } |
|
419 |
| |
|
420 |
0
| public ComplexDataValue createWsmlDuration(String year, String month, String day, String hour, String minute, String second){
|
|
421 |
0
| return (ComplexDataValue)createDataValueFromJavaObject(
|
|
422 |
| createWsmlDataType(WsmlDataType.WSML_DURATION), |
|
423 |
| "P"+year+"Y"+month+"M"+day+"DT"+hour+"H"+minute+"M"+second+"S"); |
|
424 |
| } |
|
425 |
| |
|
426 |
| |
|
427 |
0
| public ComplexDataValue createWsmlDateTime(Calendar value){
|
|
428 |
0
| return (ComplexDataValue)createDataValueFromJavaObject(
|
|
429 |
| createWsmlDataType(WsmlDataType.WSML_DATETIME), |
|
430 |
| value); |
|
431 |
| } |
|
432 |
| |
|
433 |
0
| public ComplexDataValue createWsmlDateTime(int year, int month, int day, int hour, int minute, int second, int tzHour, int tzMinute){
|
|
434 |
0
| return createWsmlDateTime(year, month, day, hour, minute, (float)second, tzHour, tzMinute);
|
|
435 |
| } |
|
436 |
| |
|
437 |
0
| public ComplexDataValue createWsmlDateTime(int year, int month, int day, int hour, int minute, float second, int tzHour, int tzMinute){
|
|
438 |
0
| return createDataValue(
|
|
439 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_DATETIME), |
|
440 |
| new SimpleDataValue[]{ |
|
441 |
| createWsmlInteger(year), |
|
442 |
| createWsmlInteger(month), |
|
443 |
| createWsmlInteger(day), |
|
444 |
| createWsmlInteger(hour), |
|
445 |
| createWsmlInteger(minute), |
|
446 |
| createWsmlDecimal(new BigDecimal(String.valueOf(second))), |
|
447 |
| createWsmlInteger(tzHour), |
|
448 |
| createWsmlInteger(tzMinute), |
|
449 |
| }); |
|
450 |
| } |
|
451 |
| |
|
452 |
0
| public ComplexDataValue createWsmlDateTime(String year, String month, String day, String hour, String minute, String second, String tzHour, String tzMinute){
|
|
453 |
0
| return createDataValue(
|
|
454 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_DATETIME), |
|
455 |
| new SimpleDataValue[]{ |
|
456 |
| createWsmlInteger(year), |
|
457 |
| createWsmlInteger(month), |
|
458 |
| createWsmlInteger(day), |
|
459 |
| createWsmlInteger(hour), |
|
460 |
| createWsmlInteger(minute), |
|
461 |
| createWsmlDecimal(new BigDecimal(second)), |
|
462 |
| createWsmlInteger(tzHour), |
|
463 |
| createWsmlInteger(tzMinute), |
|
464 |
| }); |
|
465 |
| } |
|
466 |
| |
|
467 |
| |
|
468 |
0
| public ComplexDataValue createWsmlTime(Calendar value){
|
|
469 |
0
| return (ComplexDataValue)createDataValueFromJavaObject(
|
|
470 |
| createWsmlDataType(WsmlDataType.WSML_TIME), |
|
471 |
| value); } |
|
472 |
| |
|
473 |
0
| public ComplexDataValue createWsmlTime(int hour, int minute, int second, int tzHour, int tzMinute){
|
|
474 |
0
| return createWsmlTime( hour, minute, (float)second, tzHour, tzMinute);
|
|
475 |
| } |
|
476 |
| |
|
477 |
0
| public ComplexDataValue createWsmlTime(int hour, int minute, float second, int tzHour, int tzMinute){
|
|
478 |
0
| return createDataValue(
|
|
479 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_TIME), |
|
480 |
| new SimpleDataValue[]{ |
|
481 |
| createWsmlInteger(hour), |
|
482 |
| createWsmlInteger(minute), |
|
483 |
| createWsmlDecimal(new BigDecimal(second)), |
|
484 |
| createWsmlInteger(tzHour), |
|
485 |
| createWsmlInteger(tzMinute), |
|
486 |
| }); |
|
487 |
| } |
|
488 |
| |
|
489 |
0
| public ComplexDataValue createWsmlTime(String hour, String minute, String second, String tzHour, String tzMinute){
|
|
490 |
0
| return createDataValue(
|
|
491 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_TIME), |
|
492 |
| new SimpleDataValue[]{ |
|
493 |
| createWsmlInteger(hour), |
|
494 |
| createWsmlInteger(minute), |
|
495 |
| createWsmlDecimal(new BigDecimal(second)), |
|
496 |
| createWsmlInteger(tzHour), |
|
497 |
| createWsmlInteger(tzMinute), |
|
498 |
| }); |
|
499 |
| } |
|
500 |
| |
|
501 |
| |
|
502 |
0
| public ComplexDataValue createWsmlDate(Calendar value){
|
|
503 |
0
| return (ComplexDataValue)createDataValueFromJavaObject(
|
|
504 |
| createWsmlDataType(WsmlDataType.WSML_DATE), |
|
505 |
| value); |
|
506 |
| } |
|
507 |
| |
|
508 |
0
| public ComplexDataValue createWsmlDate(int year, int month, int day, int tzHour, int tzMinute){
|
|
509 |
0
| return createDataValue(
|
|
510 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_DATE), |
|
511 |
| new SimpleDataValue[]{ |
|
512 |
| createWsmlInteger(year), |
|
513 |
| createWsmlInteger(month), |
|
514 |
| createWsmlInteger(day), |
|
515 |
| createWsmlInteger(tzHour), |
|
516 |
| createWsmlInteger(tzMinute), |
|
517 |
| }); |
|
518 |
| } |
|
519 |
| |
|
520 |
0
| public ComplexDataValue createWsmlDate(String year, String month, String day, String tzHour, String tzMinute){
|
|
521 |
0
| return createDataValue(
|
|
522 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_DATE), |
|
523 |
| new SimpleDataValue[]{ |
|
524 |
| createWsmlInteger(year), |
|
525 |
| createWsmlInteger(month), |
|
526 |
| createWsmlInteger(day), |
|
527 |
| createWsmlInteger(tzHour), |
|
528 |
| createWsmlInteger(tzMinute), |
|
529 |
| }); |
|
530 |
| } |
|
531 |
| |
|
532 |
| |
|
533 |
0
| public ComplexDataValue createWsmlGregorianYearMonth(int year, int month){
|
|
534 |
0
| return createDataValue(
|
|
535 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_GYEARMONTH), |
|
536 |
| new SimpleDataValue[]{ |
|
537 |
| createWsmlInteger(year), |
|
538 |
| createWsmlInteger(month), |
|
539 |
| }); |
|
540 |
| } |
|
541 |
| |
|
542 |
0
| public ComplexDataValue createWsmlGregorianYearMonth(String year, String month){
|
|
543 |
0
| return createDataValue(
|
|
544 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_GYEARMONTH), |
|
545 |
| new SimpleDataValue[]{ |
|
546 |
| createWsmlInteger(year), |
|
547 |
| createWsmlInteger(month), |
|
548 |
| }); |
|
549 |
| } |
|
550 |
| |
|
551 |
| |
|
552 |
0
| public ComplexDataValue createWsmlGregorianYear(int year){
|
|
553 |
0
| return createDataValue(
|
|
554 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_GYEAR), |
|
555 |
| new SimpleDataValue[]{ |
|
556 |
| createWsmlInteger(year), |
|
557 |
| }); |
|
558 |
| } |
|
559 |
| |
|
560 |
0
| public ComplexDataValue createWsmlGregorianYear(String year){
|
|
561 |
0
| return createDataValue(
|
|
562 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_GYEAR), |
|
563 |
| new SimpleDataValue[]{ |
|
564 |
| createWsmlInteger(year), |
|
565 |
| }); |
|
566 |
| } |
|
567 |
| |
|
568 |
| |
|
569 |
0
| public ComplexDataValue createWsmlGregorianMonthDay(int month, int day){
|
|
570 |
0
| return createDataValue(
|
|
571 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_GMONTHDAY), |
|
572 |
| new SimpleDataValue[]{ |
|
573 |
| createWsmlInteger(month), |
|
574 |
| createWsmlInteger(day), |
|
575 |
| }); |
|
576 |
| } |
|
577 |
| |
|
578 |
0
| public ComplexDataValue createWsmlGregorianMonthDay(String month, String day){
|
|
579 |
0
| return createDataValue(
|
|
580 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_GMONTHDAY), |
|
581 |
| new SimpleDataValue[]{ |
|
582 |
| createWsmlInteger(month), |
|
583 |
| createWsmlInteger(day), |
|
584 |
| }); |
|
585 |
| } |
|
586 |
| |
|
587 |
| |
|
588 |
0
| public ComplexDataValue createWsmlGregorianMonth(int month){
|
|
589 |
0
| return createDataValue(
|
|
590 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_GMONTH), |
|
591 |
| new SimpleDataValue[]{ |
|
592 |
| createWsmlInteger(month), |
|
593 |
| }); |
|
594 |
| } |
|
595 |
| |
|
596 |
0
| public ComplexDataValue createWsmlGregorianMonth(String month){
|
|
597 |
0
| return createDataValue(
|
|
598 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_GMONTH), |
|
599 |
| new SimpleDataValue[]{ |
|
600 |
| createWsmlInteger(month), |
|
601 |
| }); |
|
602 |
| } |
|
603 |
| |
|
604 |
| |
|
605 |
0
| public ComplexDataValue createWsmlGregorianDay(int day){
|
|
606 |
0
| return createDataValue(
|
|
607 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_GDAY), |
|
608 |
| new SimpleDataValue[]{ |
|
609 |
| createWsmlInteger(day), |
|
610 |
| }); |
|
611 |
| } |
|
612 |
| |
|
613 |
0
| public ComplexDataValue createWsmlGregorianDay(String day){
|
|
614 |
0
| return createDataValue(
|
|
615 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_GDAY), |
|
616 |
| new SimpleDataValue[]{ |
|
617 |
| createWsmlInteger(day), |
|
618 |
| }); |
|
619 |
| } |
|
620 |
| |
|
621 |
0
| public ComplexDataValue creatWsmlHexBinary(byte[] value){
|
|
622 |
0
| return createDataValue(
|
|
623 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_HEXBINARY), |
|
624 |
| new SimpleDataValue[]{ |
|
625 |
| createWsmlString(new String(value)), |
|
626 |
| }); |
|
627 |
| } |
|
628 |
| |
|
629 |
0
| public ComplexDataValue createWsmlBase64Binary(byte[] value){
|
|
630 |
0
| return createDataValue(
|
|
631 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_BASE64BINARY), |
|
632 |
| new SimpleDataValue[]{ |
|
633 |
| createWsmlString(new String(value)), |
|
634 |
| }); |
|
635 |
| } |
|
636 |
| |
|
637 |
0
| public SimpleDataValue createWsmlDecimal(String value){
|
|
638 |
| |
|
639 |
| |
|
640 |
| |
|
641 |
0
| value = value.replaceFirst("-\\s+", "-");
|
|
642 |
0
| return createWsmlDecimal(new BigDecimal(value));
|
|
643 |
| } |
|
644 |
| |
|
645 |
0
| public SimpleDataValue createWsmlInteger(String value){
|
|
646 |
0
| return createWsmlInteger(new BigInteger(value));
|
|
647 |
| } |
|
648 |
| |
|
649 |
0
| public SimpleDataValue createWsmlInteger(int value){
|
|
650 |
0
| return createWsmlInteger(new BigInteger(value+""));
|
|
651 |
| } |
|
652 |
| |
|
653 |
0
| public ComplexDataValue createWsmlFloat(String value){
|
|
654 |
0
| return createDataValue(
|
|
655 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_FLOAT), |
|
656 |
| new SimpleDataValue[]{ |
|
657 |
| createWsmlString(value), |
|
658 |
| }); |
|
659 |
| } |
|
660 |
| |
|
661 |
0
| public ComplexDataValue createWsmlFloat(Float value){
|
|
662 |
0
| return (ComplexDataValue)createDataValueFromJavaObject(
|
|
663 |
| createWsmlDataType(WsmlDataType.WSML_FLOAT), |
|
664 |
| value); |
|
665 |
| } |
|
666 |
| |
|
667 |
0
| public ComplexDataValue createWsmlDouble(Double value){
|
|
668 |
0
| return (ComplexDataValue)createDataValueFromJavaObject(
|
|
669 |
| createWsmlDataType(WsmlDataType.WSML_DOUBLE), |
|
670 |
| value); |
|
671 |
| } |
|
672 |
| |
|
673 |
0
| public ComplexDataValue createWsmlDouble(String value){
|
|
674 |
0
| return createDataValue(
|
|
675 |
| (ComplexDataType)createWsmlDataType(WsmlDataType.WSML_DOUBLE), |
|
676 |
| new SimpleDataValue[]{ |
|
677 |
| createWsmlString(value), |
|
678 |
| }); |
|
679 |
| } |
|
680 |
| |
|
681 |
| } |
|
682 |
| |
|
683 |
| |
|
684 |
| |
|
685 |
| |
|
686 |
| |
|
687 |
| |
|
688 |
| |
|
689 |
| |
|
690 |
| |
|
691 |
| |
|
692 |
| |
|
693 |
| |
|
694 |
| |
|
695 |
| |
|
696 |
| |
|
697 |
| |
|
698 |
| |
|
699 |
| |
|
700 |
| |
|
701 |
| |
|
702 |
| |
|
703 |
| |
|
704 |
| |
|
705 |
| |
|
706 |
| |
|
707 |
| |
|
708 |
| |
|
709 |
| |
|
710 |
| |
|
711 |
| |
|
712 |
| |
|
713 |
| |
|
714 |
| |
|
715 |
| |
|
716 |
| |
|
717 |
| |
|
718 |
| |
|
719 |
| |
|
720 |
| |
|
721 |
| |
|
722 |
| |
|
723 |
| |
|
724 |
| |
|
725 |
| |
|
726 |
| |
|
727 |
| |
|
728 |
| |
|
729 |
| |
|
730 |
| |
|
731 |
| |
|
732 |
| |
|
733 |
| |
|
734 |
| |
|
735 |
| |
|
736 |
| |
|
737 |
| |
|
738 |
| |