1 | // |
2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 |
3 | // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> |
4 | // Any modifications to this file will be lost upon recompilation of the source schema. |
5 | // Generated on: 2010.02.03 at 01:25:12 AM UTC |
6 | // |
7 | |
8 | |
9 | package org.jomc.model; |
10 | |
11 | import java.io.ByteArrayInputStream; |
12 | import java.io.ByteArrayOutputStream; |
13 | import java.io.IOException; |
14 | import java.io.InvalidClassException; |
15 | import java.io.NotSerializableException; |
16 | import java.io.ObjectInputStream; |
17 | import java.io.ObjectOutputStream; |
18 | import java.io.OptionalDataException; |
19 | import java.io.Serializable; |
20 | import java.io.StreamCorruptedException; |
21 | import java.lang.reflect.Array; |
22 | import java.lang.reflect.InvocationTargetException; |
23 | import java.math.BigDecimal; |
24 | import java.math.BigInteger; |
25 | import java.util.Calendar; |
26 | import java.util.Currency; |
27 | import java.util.Date; |
28 | import java.util.Locale; |
29 | import java.util.TimeZone; |
30 | import java.util.UUID; |
31 | import javax.annotation.Generated; |
32 | import javax.xml.bind.JAXBElement; |
33 | import javax.xml.bind.annotation.XmlAccessType; |
34 | import javax.xml.bind.annotation.XmlAccessorType; |
35 | import javax.xml.bind.annotation.XmlAnyElement; |
36 | import javax.xml.bind.annotation.XmlAttribute; |
37 | import javax.xml.bind.annotation.XmlType; |
38 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; |
39 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
40 | import javax.xml.datatype.Duration; |
41 | import javax.xml.datatype.XMLGregorianCalendar; |
42 | import javax.xml.namespace.QName; |
43 | import org.w3c.dom.Element; |
44 | |
45 | |
46 | /** |
47 | * |
48 | * Model of a property. |
49 | * |
50 | * The 'Property' type defines attributes 'name', 'type', 'value', 'final' and 'override'. Attribute 'name' holds the name |
51 | * uniquely identifying the property in a set of properties. Attribute 'type' holds an identifier of the type of the |
52 | * property. Attribute 'value' holds the properties value. |
53 | * |
54 | * |
55 | * <p>Java class for Property complex type. |
56 | * |
57 | * <p>The following schema fragment specifies the expected content contained within this class. |
58 | * |
59 | * <pre> |
60 | * <complexType name="Property"> |
61 | * <complexContent> |
62 | * <extension base="{http://jomc.org/model}ModelObject"> |
63 | * <sequence> |
64 | * <any processContents='lax' namespace='##other' minOccurs="0"/> |
65 | * </sequence> |
66 | * <attribute name="name" use="required" type="{http://jomc.org/model}Identifier" /> |
67 | * <attribute name="type" type="{http://jomc.org/model}Identifier" /> |
68 | * <attribute name="value" type="{http://jomc.org/model}String" /> |
69 | * <attribute name="final" type="{http://jomc.org/model}Flag" default="false" /> |
70 | * <attribute name="override" type="{http://jomc.org/model}Flag" default="false" /> |
71 | * </extension> |
72 | * </complexContent> |
73 | * </complexType> |
74 | * </pre> |
75 | * |
76 | * |
77 | */ |
78 | @XmlAccessorType(XmlAccessType.FIELD) |
79 | @XmlType(name = "Property", propOrder = { |
80 | "any" |
81 | }) |
82 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
83 | public class Property |
84 | extends ModelObject |
85 | implements Cloneable |
86 | { |
87 | |
88 | @XmlAnyElement(lax = true) |
89 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
90 | protected Object any; |
91 | @XmlAttribute(required = true) |
92 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) |
93 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
94 | protected String name; |
95 | @XmlAttribute |
96 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) |
97 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
98 | protected String type; |
99 | @XmlAttribute |
100 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
101 | protected String value; |
102 | @XmlAttribute(name = "final") |
103 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
104 | protected Boolean _final; |
105 | @XmlAttribute |
106 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
107 | protected Boolean override; |
108 | |
109 | /** |
110 | * Creates a new {@code Property} instance. |
111 | * |
112 | */ |
113 | public Property() { |
114 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
115 | super(); |
116 | } |
117 | |
118 | /** |
119 | * Creates a new {@code Property} instance by deeply copying a given {@code Property} instance. |
120 | * |
121 | * |
122 | * @param o |
123 | * The instance to copy. |
124 | * @throws NullPointerException |
125 | * if {@code o} is {@code null}. |
126 | */ |
127 | public Property(final Property o) { |
128 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
129 | super(o); |
130 | if (o == null) { |
131 | throw new NullPointerException("Cannot create a copy of 'Property' from 'null'."); |
132 | } |
133 | // 'Any' property. |
134 | this.any = copyAny(o.getAny()); |
135 | // CBuiltinLeafInfo: java.lang.String |
136 | this.name = o.getName(); |
137 | // CBuiltinLeafInfo: java.lang.String |
138 | this.type = o.getType(); |
139 | // CBuiltinLeafInfo: java.lang.String |
140 | this.value = o.getValue(); |
141 | // CBuiltinLeafInfo: java.lang.Boolean |
142 | this._final = o.isFinal(); |
143 | // CBuiltinLeafInfo: java.lang.Boolean |
144 | this.override = o.isOverride(); |
145 | } |
146 | |
147 | /** |
148 | * Object value of this property or {@code null}. |
149 | * |
150 | * @return |
151 | * possible object is |
152 | * {@link Element } |
153 | * {@link Object } |
154 | * |
155 | */ |
156 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
157 | public Object getAny() { |
158 | return any; |
159 | } |
160 | |
161 | /** |
162 | * Sets the value of the any property. |
163 | * |
164 | * @param value |
165 | * allowed object is |
166 | * {@link Element } |
167 | * {@link Object } |
168 | * |
169 | */ |
170 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
171 | public void setAny(Object value) { |
172 | this.any = value; |
173 | } |
174 | |
175 | /** |
176 | * Name of this property. |
177 | * |
178 | * @return |
179 | * possible object is |
180 | * {@link String } |
181 | * |
182 | */ |
183 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
184 | public String getName() { |
185 | return name; |
186 | } |
187 | |
188 | /** |
189 | * Sets the value of the name property. |
190 | * |
191 | * @param value |
192 | * allowed object is |
193 | * {@link String } |
194 | * |
195 | */ |
196 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
197 | public void setName(String value) { |
198 | this.name = value; |
199 | } |
200 | |
201 | /** |
202 | * Type of this property or {@code null}. |
203 | * |
204 | * @return |
205 | * possible object is |
206 | * {@link String } |
207 | * |
208 | */ |
209 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
210 | public String getType() { |
211 | return type; |
212 | } |
213 | |
214 | /** |
215 | * Sets the value of the type property. |
216 | * |
217 | * @param value |
218 | * allowed object is |
219 | * {@link String } |
220 | * |
221 | */ |
222 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
223 | public void setType(String value) { |
224 | this.type = value; |
225 | } |
226 | |
227 | /** |
228 | * String value of this property or {@code null}. |
229 | * |
230 | * @return |
231 | * possible object is |
232 | * {@link String } |
233 | * |
234 | */ |
235 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
236 | public String getValue() { |
237 | return value; |
238 | } |
239 | |
240 | /** |
241 | * Sets the value of the value property. |
242 | * |
243 | * @param value |
244 | * allowed object is |
245 | * {@link String } |
246 | * |
247 | */ |
248 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
249 | public void setValue(String value) { |
250 | this.value = value; |
251 | } |
252 | |
253 | /** |
254 | * {@code true} if this property is the final node in an inheritance hierarchy. |
255 | * |
256 | * @return |
257 | * possible object is |
258 | * {@link Boolean } |
259 | * |
260 | */ |
261 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
262 | public boolean isFinal() { |
263 | if (_final == null) { |
264 | return false; |
265 | } else { |
266 | return _final; |
267 | } |
268 | } |
269 | |
270 | /** |
271 | * Sets the value of the final property. |
272 | * |
273 | * @param value |
274 | * allowed object is |
275 | * {@link Boolean } |
276 | * |
277 | */ |
278 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
279 | public void setFinal(Boolean value) { |
280 | this._final = value; |
281 | } |
282 | |
283 | /** |
284 | * {@code true} if this property is intended to override a super property. |
285 | * |
286 | * @return |
287 | * possible object is |
288 | * {@link Boolean } |
289 | * |
290 | */ |
291 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
292 | public boolean isOverride() { |
293 | if (override == null) { |
294 | return false; |
295 | } else { |
296 | return override; |
297 | } |
298 | } |
299 | |
300 | /** |
301 | * Sets the value of the override property. |
302 | * |
303 | * @param value |
304 | * allowed object is |
305 | * {@link Boolean } |
306 | * |
307 | */ |
308 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
309 | public void setOverride(Boolean value) { |
310 | this.override = value; |
311 | } |
312 | |
313 | /** |
314 | * Creates and returns a deep copy of property {@code Any}. |
315 | * |
316 | * @param source |
317 | * The source to copy from or {@code null}. |
318 | * @return |
319 | * A deep copy of {@code source} or {@code null} if {@code source} is {@code null}. |
320 | */ |
321 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
322 | private static Object copyAny(final Object source) { |
323 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
324 | if (source!= null) { |
325 | if (source instanceof Element) { |
326 | // CWildcardTypeInfo: org.w3c.dom.Element |
327 | return ((Element)((Element) source).cloneNode(true)); |
328 | } |
329 | if (source instanceof Object) { |
330 | // CBuiltinLeafInfo: java.lang.Object |
331 | return copyOfObject(((Object) source)); |
332 | } |
333 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
334 | throw new AssertionError((("Unexpected instance '"+ source)+"' for property 'Any' of class 'org.jomc.model.Property'.")); |
335 | } |
336 | return null; |
337 | } |
338 | |
339 | /** |
340 | * Creates and returns a deep copy of a given object. |
341 | * |
342 | * @param o |
343 | * The instance to copy or {@code null}. |
344 | * @return |
345 | * A deep copy of {@code o} or {@code null} if {@code o} is {@code null}. |
346 | */ |
347 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
348 | private static Object copyOfObject(final Object o) { |
349 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
350 | if (o!= null) { |
351 | if (o.getClass().isPrimitive()) { |
352 | return o; |
353 | } |
354 | if (o.getClass().isArray()) { |
355 | return copyOfArray(o); |
356 | } |
357 | if (o instanceof Boolean) { |
358 | return o; |
359 | } |
360 | if (o instanceof Byte) { |
361 | return o; |
362 | } |
363 | if (o instanceof Character) { |
364 | return o; |
365 | } |
366 | if (o instanceof Double) { |
367 | return o; |
368 | } |
369 | if (o instanceof Enum) { |
370 | return o; |
371 | } |
372 | if (o instanceof Float) { |
373 | return o; |
374 | } |
375 | if (o instanceof Integer) { |
376 | return o; |
377 | } |
378 | if (o instanceof Long) { |
379 | return o; |
380 | } |
381 | if (o instanceof Short) { |
382 | return o; |
383 | } |
384 | if (o instanceof String) { |
385 | return o; |
386 | } |
387 | if (o instanceof BigDecimal) { |
388 | return o; |
389 | } |
390 | if (o instanceof BigInteger) { |
391 | return o; |
392 | } |
393 | if (o instanceof UUID) { |
394 | return o; |
395 | } |
396 | if (o instanceof QName) { |
397 | return o; |
398 | } |
399 | if (o instanceof Duration) { |
400 | return o; |
401 | } |
402 | if (o instanceof Currency) { |
403 | return o; |
404 | } |
405 | if (o instanceof XMLGregorianCalendar) { |
406 | return ((XMLGregorianCalendar) o).clone(); |
407 | } |
408 | if (o instanceof Date) { |
409 | return ((Date) o).clone(); |
410 | } |
411 | if (o instanceof Calendar) { |
412 | return ((Calendar) o).clone(); |
413 | } |
414 | if (o instanceof TimeZone) { |
415 | return ((TimeZone) o).clone(); |
416 | } |
417 | if (o instanceof Locale) { |
418 | return ((Locale) o).clone(); |
419 | } |
420 | if (o instanceof Element) { |
421 | return ((Element)((Element) o).cloneNode(true)); |
422 | } |
423 | if (o instanceof JAXBElement) { |
424 | return copyOFJAXBElement(((JAXBElement) o)); |
425 | } |
426 | try { |
427 | return o.getClass().getMethod("clone", ((Class[]) null)).invoke(o, ((Object[]) null)); |
428 | } catch (NoSuchMethodException e) { |
429 | if (o instanceof Serializable) { |
430 | return copyOfSerializable(((Serializable) o)); |
431 | } |
432 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
433 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
434 | } catch (IllegalAccessException e) { |
435 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
436 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
437 | } catch (InvocationTargetException e) { |
438 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
439 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
440 | } catch (SecurityException e) { |
441 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
442 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
443 | } catch (IllegalArgumentException e) { |
444 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
445 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
446 | } catch (ExceptionInInitializerError e) { |
447 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
448 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
449 | } |
450 | } |
451 | return null; |
452 | } |
453 | |
454 | /** |
455 | * Creates and returns a deep copy of a given array. |
456 | * |
457 | * @param array |
458 | * The array to copy or {@code null}. |
459 | * @return |
460 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
461 | */ |
462 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
463 | private static Object copyOfArray(final Object array) { |
464 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
465 | if (array!= null) { |
466 | if (array.getClass() == boolean[].class) { |
467 | return copyOf(((boolean[]) array)); |
468 | } |
469 | if (array.getClass() == byte[].class) { |
470 | return copyOf(((byte[]) array)); |
471 | } |
472 | if (array.getClass() == char[].class) { |
473 | return copyOf(((char[]) array)); |
474 | } |
475 | if (array.getClass() == double[].class) { |
476 | return copyOf(((double[]) array)); |
477 | } |
478 | if (array.getClass() == float[].class) { |
479 | return copyOf(((float[]) array)); |
480 | } |
481 | if (array.getClass() == int[].class) { |
482 | return copyOf(((int[]) array)); |
483 | } |
484 | if (array.getClass() == long[].class) { |
485 | return copyOf(((long[]) array)); |
486 | } |
487 | if (array.getClass() == short[].class) { |
488 | return copyOf(((short[]) array)); |
489 | } |
490 | final int len = Array.getLength(array); |
491 | final Object copy = Array.newInstance(array.getClass().getComponentType(), len); |
492 | for (int i = (len- 1); (i >= 0); i--) { |
493 | Array.set(copy, i, copyOfObject(Array.get(array, i))); |
494 | } |
495 | return copy; |
496 | } |
497 | return null; |
498 | } |
499 | |
500 | /** |
501 | * Creates and returns a deep copy of a given array. |
502 | * |
503 | * @param array |
504 | * The array to copy or {@code null}. |
505 | * @return |
506 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
507 | */ |
508 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
509 | private static boolean[] copyOf(final boolean[] array) { |
510 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
511 | if (array!= null) { |
512 | final boolean[] copy = ((boolean[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
513 | System.arraycopy(array, 0, copy, 0, array.length); |
514 | return copy; |
515 | } |
516 | return null; |
517 | } |
518 | |
519 | /** |
520 | * Creates and returns a deep copy of a given array. |
521 | * |
522 | * @param array |
523 | * The array to copy or {@code null}. |
524 | * @return |
525 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
526 | */ |
527 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
528 | private static byte[] copyOf(final byte[] array) { |
529 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
530 | if (array!= null) { |
531 | final byte[] copy = ((byte[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
532 | System.arraycopy(array, 0, copy, 0, array.length); |
533 | return copy; |
534 | } |
535 | return null; |
536 | } |
537 | |
538 | /** |
539 | * Creates and returns a deep copy of a given array. |
540 | * |
541 | * @param array |
542 | * The array to copy or {@code null}. |
543 | * @return |
544 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
545 | */ |
546 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
547 | private static char[] copyOf(final char[] array) { |
548 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
549 | if (array!= null) { |
550 | final char[] copy = ((char[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
551 | System.arraycopy(array, 0, copy, 0, array.length); |
552 | return copy; |
553 | } |
554 | return null; |
555 | } |
556 | |
557 | /** |
558 | * Creates and returns a deep copy of a given array. |
559 | * |
560 | * @param array |
561 | * The array to copy or {@code null}. |
562 | * @return |
563 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
564 | */ |
565 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
566 | private static double[] copyOf(final double[] array) { |
567 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
568 | if (array!= null) { |
569 | final double[] copy = ((double[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
570 | System.arraycopy(array, 0, copy, 0, array.length); |
571 | return copy; |
572 | } |
573 | return null; |
574 | } |
575 | |
576 | /** |
577 | * Creates and returns a deep copy of a given array. |
578 | * |
579 | * @param array |
580 | * The array to copy or {@code null}. |
581 | * @return |
582 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
583 | */ |
584 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
585 | private static float[] copyOf(final float[] array) { |
586 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
587 | if (array!= null) { |
588 | final float[] copy = ((float[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
589 | System.arraycopy(array, 0, copy, 0, array.length); |
590 | return copy; |
591 | } |
592 | return null; |
593 | } |
594 | |
595 | /** |
596 | * Creates and returns a deep copy of a given array. |
597 | * |
598 | * @param array |
599 | * The array to copy or {@code null}. |
600 | * @return |
601 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
602 | */ |
603 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
604 | private static int[] copyOf(final int[] array) { |
605 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
606 | if (array!= null) { |
607 | final int[] copy = ((int[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
608 | System.arraycopy(array, 0, copy, 0, array.length); |
609 | return copy; |
610 | } |
611 | return null; |
612 | } |
613 | |
614 | /** |
615 | * Creates and returns a deep copy of a given array. |
616 | * |
617 | * @param array |
618 | * The array to copy or {@code null}. |
619 | * @return |
620 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
621 | */ |
622 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
623 | private static long[] copyOf(final long[] array) { |
624 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
625 | if (array!= null) { |
626 | final long[] copy = ((long[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
627 | System.arraycopy(array, 0, copy, 0, array.length); |
628 | return copy; |
629 | } |
630 | return null; |
631 | } |
632 | |
633 | /** |
634 | * Creates and returns a deep copy of a given array. |
635 | * |
636 | * @param array |
637 | * The array to copy or {@code null}. |
638 | * @return |
639 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
640 | */ |
641 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
642 | private static short[] copyOf(final short[] array) { |
643 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
644 | if (array!= null) { |
645 | final short[] copy = ((short[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
646 | System.arraycopy(array, 0, copy, 0, array.length); |
647 | return copy; |
648 | } |
649 | return null; |
650 | } |
651 | |
652 | /** |
653 | * Creates and returns a deep copy of a given {@code JAXBElement} instance. |
654 | * |
655 | * @param element |
656 | * The instance to copy or {@code null}. |
657 | * @return |
658 | * A deep copy of {@code element} or {@code null} if {@code element} is {@code null}. |
659 | */ |
660 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
661 | private static JAXBElement copyOFJAXBElement(final JAXBElement element) { |
662 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
663 | if (element!= null) { |
664 | final JAXBElement copy = new JAXBElement(element.getName(), element.getDeclaredType(), element.getScope(), element.getValue()); |
665 | copy.setNil(element.isNil()); |
666 | copy.setValue(copyOfObject(copy.getValue())); |
667 | return copy; |
668 | } |
669 | return null; |
670 | } |
671 | |
672 | /** |
673 | * Creates and returns a deep copy of a given {@code Serializable}. |
674 | * |
675 | * @param serializable |
676 | * The instance to copy or {@code null}. |
677 | * @return |
678 | * A deep copy of {@code serializable} or {@code null} if {@code serializable} is {@code null}. |
679 | */ |
680 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
681 | private static Serializable copyOfSerializable(final Serializable serializable) { |
682 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
683 | if (serializable!= null) { |
684 | try { |
685 | final ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream(); |
686 | final ObjectOutputStream out = new ObjectOutputStream(byteArrayOutput); |
687 | out.writeObject(serializable); |
688 | out.close(); |
689 | final ByteArrayInputStream byteArrayInput = new ByteArrayInputStream(byteArrayOutput.toByteArray()); |
690 | final ObjectInputStream in = new ObjectInputStream(byteArrayInput); |
691 | final Serializable copy = ((Serializable) in.readObject()); |
692 | in.close(); |
693 | return copy; |
694 | } catch (SecurityException e) { |
695 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
696 | } catch (ClassNotFoundException e) { |
697 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
698 | } catch (InvalidClassException e) { |
699 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
700 | } catch (NotSerializableException e) { |
701 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
702 | } catch (StreamCorruptedException e) { |
703 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
704 | } catch (OptionalDataException e) { |
705 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
706 | } catch (IOException e) { |
707 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
708 | } |
709 | } |
710 | return null; |
711 | } |
712 | |
713 | /** |
714 | * Creates and returns a deep copy of this object. |
715 | * |
716 | * |
717 | * @return |
718 | * A deep copy of this object. |
719 | */ |
720 | @Override |
721 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
722 | public Property clone() { |
723 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
724 | return new Property(this); |
725 | } |
726 | |
727 | /** |
728 | * Gets the Java value of the property. |
729 | * <p>The Java value of the property is computed based on the following rules: |
730 | * <ol> |
731 | * <li>If property {@code any} is set, the Java value is computed based on the object returned by method |
732 | * {@code getAny()} by possibly unwrapping any {@code JAXBElement} instances. If that object declares a |
733 | * <blockquote><pre>public Object getJavaValue( ClassLoader )</pre></blockquote> method, the value returned by this |
734 | * method is the object returned by a call to that method using reflection. If that object does not declare such a |
735 | * method, the value returned by this method is that (possibly unwrapped) object.</li> |
736 | * <li>If property {@code value} is set, the Java value is computed based on the values of properties {@code type} |
737 | * and {@code value}. If property {@code type} is not set or equals {@code java.lang.String}, the value returned |
738 | * by this method is the string value returned by method {@code getValue()}. If property {@code type} equals a name |
739 | * of a Java primitive type, an instance of the wrapper class corresponding to that primitive type name is returned |
740 | * instantiated by passing the value of property {@code value} to the public constructor taking a single |
741 | * {@code java.lang.String} argument of that wrapper class. For all other values of property {@code type} an |
742 | * instance of a class with a name equal to the value of property {@code type} is returned instantiated by passing |
743 | * the value of property {@code value} to the public constructor taking a single {@code java.lang.String} argument |
744 | * of that class.</li> |
745 | * <li>If properties {@code any} and {@code value} are both {@code null}, this method returns {@code null}.</li> |
746 | * </ol></p> |
747 | * |
748 | * @param classLoader The class loader to use for getting the Java value; {@code null} to use the platform's |
749 | * bootstrap class loader. |
750 | * |
751 | * @return The Java value of the property or {@code null}. |
752 | * |
753 | * @throws ModelException if getting the Java value of the property fails. |
754 | */ |
755 | public Object getJavaValue( final ClassLoader classLoader ) throws ModelException |
756 | { |
757 | try |
758 | { |
759 | if ( this.getAny() != null ) |
760 | { |
761 | if ( this.getType() == null ) |
762 | { |
763 | throw new ModelException( this.getMessage( "mandatoryType", this.getName() ) ); |
764 | } |
765 | |
766 | String typeName = this.getType(); |
767 | final int idx = typeName.indexOf( "<" ); |
768 | if ( idx != -1 ) |
769 | { |
770 | typeName = typeName.substring( 0, idx ); |
771 | } |
772 | |
773 | final Class javaType = Class.forName( typeName, true, classLoader ); |
774 | final Object anyObject = this.getAny() instanceof JAXBElement |
775 | ? ( (JAXBElement) this.getAny() ).getValue() : this.getAny(); |
776 | |
777 | return this.getJavaValue( classLoader, anyObject, javaType ); |
778 | } |
779 | |
780 | Class javaType = String.class; |
781 | boolean primitive = false; |
782 | |
783 | if ( this.getType() != null ) |
784 | { |
785 | if ( Boolean.TYPE.getName().equals( this.getType() ) ) |
786 | { |
787 | javaType = Boolean.class; |
788 | primitive = true; |
789 | } |
790 | else if ( Byte.TYPE.getName().equals( this.getType() ) ) |
791 | { |
792 | javaType = Byte.class; |
793 | primitive = true; |
794 | } |
795 | else if ( Character.TYPE.getName().equals( this.getType() ) ) |
796 | { |
797 | javaType = Character.class; |
798 | primitive = true; |
799 | } |
800 | else if ( Double.TYPE.getName().equals( this.getType() ) ) |
801 | { |
802 | javaType = Double.class; |
803 | primitive = true; |
804 | } |
805 | else if ( Float.TYPE.getName().equals( this.getType() ) ) |
806 | { |
807 | javaType = Float.class; |
808 | primitive = true; |
809 | } |
810 | else if ( Integer.TYPE.getName().equals( this.getType() ) ) |
811 | { |
812 | javaType = Integer.class; |
813 | primitive = true; |
814 | } |
815 | else if ( Long.TYPE.getName().equals( this.getType() ) ) |
816 | { |
817 | javaType = Long.class; |
818 | primitive = true; |
819 | } |
820 | else if ( Short.TYPE.getName().equals( this.getType() ) ) |
821 | { |
822 | javaType = Short.class; |
823 | primitive = true; |
824 | } |
825 | else |
826 | { |
827 | String typeName = this.getType(); |
828 | final int idx = typeName.indexOf( "<" ); |
829 | if ( idx != -1 ) |
830 | { |
831 | typeName = typeName.substring( 0, idx ); |
832 | } |
833 | |
834 | javaType = Class.forName( typeName, true, classLoader ); |
835 | } |
836 | } |
837 | |
838 | if ( this.getValue() == null && primitive ) |
839 | { |
840 | throw new ModelException( this.getMessage( |
841 | "mandatoryPrimitiveValue", this.getName(), this.getType() ) ); |
842 | |
843 | } |
844 | |
845 | return this.getJavaValue( javaType, this.getValue() ); |
846 | } |
847 | catch ( final ClassNotFoundException e ) |
848 | { |
849 | throw new ModelException( this.getMessage( "classNotFound", this.getName(), this.getType() ), e ); |
850 | } |
851 | } |
852 | |
853 | private Object getJavaValue( final ClassLoader classLoader, final Object any, final Class returnType ) |
854 | throws ModelException |
855 | { |
856 | if ( any != null ) |
857 | { |
858 | final String methodName = "getJavaValue"; |
859 | |
860 | try |
861 | { |
862 | final java.lang.reflect.Method m = any.getClass().getMethod( methodName, ClassLoader.class ); |
863 | final Object result = m.invoke( any, classLoader ); |
864 | |
865 | if ( result != null && !returnType.isAssignableFrom( result.getClass() ) ) |
866 | { |
867 | throw new ModelException( this.getMessage( |
868 | "illegalMethodInvocationResult", methodName, any.getClass().getName(), |
869 | result.getClass().getName(), returnType.getName() ) ); |
870 | |
871 | } |
872 | |
873 | return result; |
874 | } |
875 | catch ( final IllegalAccessException e ) |
876 | { |
877 | throw new ModelException( this.getMessage( |
878 | "methodAccessDenied", methodName, any.getClass().getName() ), e ); |
879 | |
880 | } |
881 | catch ( final IllegalArgumentException e ) |
882 | { |
883 | throw new AssertionError( e ); |
884 | } |
885 | catch ( final InvocationTargetException e ) |
886 | { |
887 | throw new ModelException( this.getMessage( |
888 | "methodInvocationFailure", methodName, any.getClass().getName() ), e ); |
889 | |
890 | } |
891 | catch ( final SecurityException e ) |
892 | { |
893 | throw new ModelException( this.getMessage( |
894 | "methodAccessDenied", methodName, any.getClass().getName() ), e ); |
895 | |
896 | } |
897 | catch ( final NoSuchMethodException e ) |
898 | { |
899 | // Optional method not provided. |
900 | } |
901 | } |
902 | |
903 | return any; |
904 | } |
905 | |
906 | private Object getJavaValue( final Class type, final String value ) throws ModelException |
907 | { |
908 | if ( value != null ) |
909 | { |
910 | try |
911 | { |
912 | if ( type == Character.class ) |
913 | { |
914 | if ( value.length() != 1 ) |
915 | { |
916 | throw new ModelException( this.getMessage( "illegalValue", value, Character.class.getName() ) ); |
917 | } |
918 | |
919 | return type.getConstructor( new Class[] |
920 | { |
921 | char.class |
922 | } ).newInstance( new Object[] |
923 | { |
924 | value.charAt( 0 ) |
925 | } ); |
926 | |
927 | } |
928 | else if ( type == String.class ) |
929 | { |
930 | return value; |
931 | } |
932 | else |
933 | { |
934 | return type.getConstructor( new Class[] |
935 | { |
936 | String.class |
937 | } ).newInstance( value ); |
938 | |
939 | } |
940 | } |
941 | catch ( final InstantiationException e ) |
942 | { |
943 | throw new ModelException( this.getMessage( "instantiationException", type.getName() ), e ); |
944 | } |
945 | catch ( final IllegalAccessException e ) |
946 | { |
947 | throw new ModelException( this.getMessage( "constructorAccessDenied", type.getName() ), e ); |
948 | } |
949 | catch ( final IllegalArgumentException e ) |
950 | { |
951 | throw new AssertionError( e ); |
952 | } |
953 | catch ( final InvocationTargetException e ) |
954 | { |
955 | throw new ModelException( this.getMessage( "constructorInvocationFailure", type.getName() ), e ); |
956 | } |
957 | catch ( final NoSuchMethodException e ) |
958 | { |
959 | throw new ModelException( this.getMessage( "constructorNotFound", type.getName() ), e ); |
960 | } |
961 | } |
962 | |
963 | return value; |
964 | } |
965 | |
966 | private String getMessage( final String key, final Object... arguments ) |
967 | { |
968 | return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( |
969 | Property.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ).getString( key ), arguments ); |
970 | |
971 | } |
972 | |
973 | |
974 | } |