1
2
3
4
5
6
7
8
9 package org.jomc.model;
10
11 import java.io.ByteArrayInputStream;
12 import java.io.ByteArrayOutputStream;
13 import java.io.File;
14 import java.io.IOException;
15 import java.io.InvalidClassException;
16 import java.io.NotSerializableException;
17 import java.io.ObjectInputStream;
18 import java.io.ObjectOutputStream;
19 import java.io.OptionalDataException;
20 import java.io.Serializable;
21 import java.io.StreamCorruptedException;
22 import java.lang.reflect.Array;
23 import java.lang.reflect.InvocationTargetException;
24 import java.math.BigDecimal;
25 import java.math.BigInteger;
26 import java.net.MalformedURLException;
27 import java.net.URI;
28 import java.net.URISyntaxException;
29 import java.net.URL;
30 import java.util.ArrayList;
31 import java.util.Calendar;
32 import java.util.Currency;
33 import java.util.Date;
34 import java.util.Iterator;
35 import java.util.List;
36 import java.util.Locale;
37 import java.util.TimeZone;
38 import java.util.UUID;
39 import javax.activation.MimeType;
40 import javax.activation.MimeTypeParseException;
41 import javax.annotation.Generated;
42 import javax.xml.bind.JAXBElement;
43 import javax.xml.bind.annotation.XmlAccessType;
44 import javax.xml.bind.annotation.XmlAccessorType;
45 import javax.xml.bind.annotation.XmlAnyElement;
46 import javax.xml.bind.annotation.XmlAttribute;
47 import javax.xml.bind.annotation.XmlType;
48 import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
49 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
50 import javax.xml.datatype.Duration;
51 import javax.xml.datatype.XMLGregorianCalendar;
52 import javax.xml.namespace.QName;
53 import org.w3c.dom.Element;
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86 @XmlAccessorType(XmlAccessType.FIELD)
87 @XmlType(name = "Argument", namespace = "http://jomc.org/model", propOrder = {
88 "any"
89 })
90 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
91 public class Argument
92 extends ModelObject
93 implements Cloneable
94 {
95
96 @XmlAnyElement(lax = true)
97 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
98 protected List<Object> any;
99 @XmlAttribute(name = "index", required = true)
100 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
101 protected int index;
102 @XmlAttribute(name = "name", required = true)
103 @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
104 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
105 protected String name;
106 @XmlAttribute(name = "type")
107 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
108 protected ArgumentType type;
109
110
111
112
113
114 public Argument() {
115
116 super();
117 }
118
119
120
121
122
123
124
125
126
127
128 public Argument(final Argument o) {
129
130 super(o);
131 if (o == null) {
132 throw new NullPointerException("Cannot create a copy of 'Argument' from 'null'.");
133 }
134
135 if (o.any!= null) {
136 copyAny(o.getAny(), this.getAny());
137 }
138
139 this.index = o.getIndex();
140
141 this.name = ((o.name == null)?null:o.getName());
142
143 this.type = ((o.type == null)?null:o.getType());
144 }
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
170 public List<Object> getAny() {
171 if (any == null) {
172 any = new ArrayList<Object>();
173 }
174 return this.any;
175 }
176
177
178
179
180
181 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
182 public int getIndex() {
183 return index;
184 }
185
186
187
188
189
190 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
191 public void setIndex(int value) {
192 this.index = value;
193 }
194
195
196
197
198
199
200
201
202
203 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
204 public String getName() {
205 return name;
206 }
207
208
209
210
211
212
213
214
215
216 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
217 public void setName(String value) {
218 this.name = value;
219 }
220
221
222
223
224
225
226
227
228
229 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
230 public ArgumentType getType() {
231 if (type == null) {
232 return ArgumentType.TEXT;
233 } else {
234 return type;
235 }
236 }
237
238
239
240
241
242
243
244
245
246 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
247 public void setType(ArgumentType value) {
248 this.type = value;
249 }
250
251
252
253
254
255
256
257
258
259
260
261 @SuppressWarnings("unchecked")
262 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
263 private static void copyAny(final List<Object> source, final List<Object> target) {
264
265 if ((source!= null)&&(!source.isEmpty())) {
266 for (final Iterator<?> it = source.iterator(); it.hasNext(); ) {
267 final Object next = it.next();
268 if (next instanceof Element) {
269
270 target.add(((Element)((Element) next).cloneNode(true)));
271 continue;
272 }
273 if (next instanceof Object) {
274
275 target.add(copyOf(((Object) next)));
276 continue;
277 }
278
279 throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Any' of class 'org.jomc.model.Argument'."));
280 }
281 }
282 }
283
284
285
286
287
288
289
290
291
292 @SuppressWarnings("unchecked")
293 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
294 private static Object copyOf(final Object o) {
295
296 try {
297 if (o!= null) {
298 if (o.getClass().isPrimitive()) {
299 return o;
300 }
301 if (o.getClass().isArray()) {
302 return copyOfArray(o);
303 }
304
305 if (o instanceof Boolean) {
306 return o;
307 }
308 if (o instanceof Byte) {
309 return o;
310 }
311 if (o instanceof Character) {
312 return o;
313 }
314 if (o instanceof Double) {
315 return o;
316 }
317 if (o instanceof Enum) {
318 return o;
319 }
320 if (o instanceof Float) {
321 return o;
322 }
323 if (o instanceof Integer) {
324 return o;
325 }
326 if (o instanceof Long) {
327 return o;
328 }
329 if (o instanceof Short) {
330 return o;
331 }
332 if (o instanceof String) {
333 return o;
334 }
335 if (o instanceof BigDecimal) {
336 return o;
337 }
338 if (o instanceof BigInteger) {
339 return o;
340 }
341 if (o instanceof UUID) {
342 return o;
343 }
344 if (o instanceof QName) {
345 return o;
346 }
347 if (o instanceof Duration) {
348 return o;
349 }
350 if (o instanceof Currency) {
351 return o;
352 }
353
354 if (o instanceof File) {
355 return new File(o.toString());
356 }
357 if (o instanceof URI) {
358 return new URI(o.toString());
359 }
360 if (o instanceof URL) {
361 return new URL(o.toString());
362 }
363 if (o instanceof MimeType) {
364 return new MimeType(o.toString());
365 }
366
367 if (o instanceof XMLGregorianCalendar) {
368 return ((XMLGregorianCalendar) o).clone();
369 }
370 if (o instanceof Date) {
371 return ((Date) o).clone();
372 }
373 if (o instanceof Calendar) {
374 return ((Calendar) o).clone();
375 }
376 if (o instanceof TimeZone) {
377 return ((TimeZone) o).clone();
378 }
379 if (o instanceof Locale) {
380 return ((Locale) o).clone();
381 }
382 if (o instanceof Element) {
383 return ((Element)((Element) o).cloneNode(true));
384 }
385 if (o instanceof JAXBElement) {
386 return copyOf(((JAXBElement) o));
387 }
388 try {
389 return o.getClass().getMethod("clone", ((Class[]) null)).invoke(o, ((Object[]) null));
390 } catch (NoSuchMethodException e) {
391 if (o instanceof Serializable) {
392 return copyOf(((Serializable) o));
393 }
394
395 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
396 } catch (IllegalAccessException e) {
397
398 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
399 } catch (InvocationTargetException e) {
400
401 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
402 } catch (SecurityException e) {
403
404 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
405 } catch (IllegalArgumentException e) {
406
407 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
408 } catch (ExceptionInInitializerError e) {
409
410 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
411 }
412 }
413 return null;
414 } catch (MimeTypeParseException e) {
415 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
416 } catch (URISyntaxException e) {
417 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
418 } catch (MalformedURLException e) {
419 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
420 }
421 }
422
423
424
425
426
427
428
429
430
431 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
432 private static Object copyOfArray(final Object array) {
433
434 if (array!= null) {
435 if (array.getClass() == boolean[].class) {
436 return copyOf(((boolean[]) array));
437 }
438 if (array.getClass() == byte[].class) {
439 return copyOf(((byte[]) array));
440 }
441 if (array.getClass() == char[].class) {
442 return copyOf(((char[]) array));
443 }
444 if (array.getClass() == double[].class) {
445 return copyOf(((double[]) array));
446 }
447 if (array.getClass() == float[].class) {
448 return copyOf(((float[]) array));
449 }
450 if (array.getClass() == int[].class) {
451 return copyOf(((int[]) array));
452 }
453 if (array.getClass() == long[].class) {
454 return copyOf(((long[]) array));
455 }
456 if (array.getClass() == short[].class) {
457 return copyOf(((short[]) array));
458 }
459 final int len = Array.getLength(array);
460 final Object copy = Array.newInstance(array.getClass().getComponentType(), len);
461 for (int i = (len- 1); (i >= 0); i--) {
462 Array.set(copy, i, copyOf(Array.get(array, i)));
463 }
464 return copy;
465 }
466 return null;
467 }
468
469
470
471
472
473
474
475
476
477 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
478 private static boolean[] copyOf(final boolean[] array) {
479
480 if (array!= null) {
481 final boolean[] copy = ((boolean[]) Array.newInstance(array.getClass().getComponentType(), array.length));
482 System.arraycopy(array, 0, copy, 0, array.length);
483 return copy;
484 }
485 return null;
486 }
487
488
489
490
491
492
493
494
495
496 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
497 private static byte[] copyOf(final byte[] array) {
498
499 if (array!= null) {
500 final byte[] copy = ((byte[]) Array.newInstance(array.getClass().getComponentType(), array.length));
501 System.arraycopy(array, 0, copy, 0, array.length);
502 return copy;
503 }
504 return null;
505 }
506
507
508
509
510
511
512
513
514
515 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
516 private static char[] copyOf(final char[] array) {
517
518 if (array!= null) {
519 final char[] copy = ((char[]) Array.newInstance(array.getClass().getComponentType(), array.length));
520 System.arraycopy(array, 0, copy, 0, array.length);
521 return copy;
522 }
523 return null;
524 }
525
526
527
528
529
530
531
532
533
534 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
535 private static double[] copyOf(final double[] array) {
536
537 if (array!= null) {
538 final double[] copy = ((double[]) Array.newInstance(array.getClass().getComponentType(), array.length));
539 System.arraycopy(array, 0, copy, 0, array.length);
540 return copy;
541 }
542 return null;
543 }
544
545
546
547
548
549
550
551
552
553 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
554 private static float[] copyOf(final float[] array) {
555
556 if (array!= null) {
557 final float[] copy = ((float[]) Array.newInstance(array.getClass().getComponentType(), array.length));
558 System.arraycopy(array, 0, copy, 0, array.length);
559 return copy;
560 }
561 return null;
562 }
563
564
565
566
567
568
569
570
571
572 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
573 private static int[] copyOf(final int[] array) {
574
575 if (array!= null) {
576 final int[] copy = ((int[]) Array.newInstance(array.getClass().getComponentType(), array.length));
577 System.arraycopy(array, 0, copy, 0, array.length);
578 return copy;
579 }
580 return null;
581 }
582
583
584
585
586
587
588
589
590
591 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
592 private static long[] copyOf(final long[] array) {
593
594 if (array!= null) {
595 final long[] copy = ((long[]) Array.newInstance(array.getClass().getComponentType(), array.length));
596 System.arraycopy(array, 0, copy, 0, array.length);
597 return copy;
598 }
599 return null;
600 }
601
602
603
604
605
606
607
608
609
610 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
611 private static short[] copyOf(final short[] array) {
612
613 if (array!= null) {
614 final short[] copy = ((short[]) Array.newInstance(array.getClass().getComponentType(), array.length));
615 System.arraycopy(array, 0, copy, 0, array.length);
616 return copy;
617 }
618 return null;
619 }
620
621
622
623
624
625
626
627
628
629 @SuppressWarnings("unchecked")
630 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
631 private static JAXBElement copyOf(final JAXBElement element) {
632
633 if (element!= null) {
634 final JAXBElement copy = new JAXBElement(element.getName(), element.getDeclaredType(), element.getScope(), element.getValue());
635 copy.setNil(element.isNil());
636 copy.setValue(copyOf(copy.getValue()));
637 return copy;
638 }
639 return null;
640 }
641
642
643
644
645
646
647
648
649
650 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
651 private static Serializable copyOf(final Serializable serializable) {
652
653 if (serializable!= null) {
654 try {
655 final ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
656 final ObjectOutputStream out = new ObjectOutputStream(byteArrayOutput);
657 out.writeObject(serializable);
658 out.close();
659 final ByteArrayInputStream byteArrayInput = new ByteArrayInputStream(byteArrayOutput.toByteArray());
660 final ObjectInputStream in = new ObjectInputStream(byteArrayInput);
661 final Serializable copy = ((Serializable) in.readObject());
662 in.close();
663 return copy;
664 } catch (SecurityException e) {
665 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
666 } catch (ClassNotFoundException e) {
667 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
668 } catch (InvalidClassException e) {
669 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
670 } catch (NotSerializableException e) {
671 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
672 } catch (StreamCorruptedException e) {
673 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
674 } catch (OptionalDataException e) {
675 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
676 } catch (IOException e) {
677 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
678 }
679 }
680 return null;
681 }
682
683
684
685
686
687
688
689
690 @Override
691 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-21T08:43:16+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
692 public Argument clone() {
693 {
694
695 final Argument clone = ((Argument) super.clone());
696
697 if (this.any!= null) {
698 clone.any = null;
699 copyAny(this.getAny(), clone.getAny());
700 }
701
702 clone.index = this.getIndex();
703
704 clone.name = ((this.name == null)?null:this.getName());
705
706 clone.type = ((this.type == null)?null:this.getType());
707 return clone;
708 }
709 }
710
711
712
713
714
715
716
717
718
719
720
721
722
723 public JavaTypeName getJavaTypeName() throws ModelObjectException
724 {
725 try
726 {
727 String typeName = "java.lang.String";
728
729 if ( this.getType() == ArgumentType.DATE || this.getType() == ArgumentType.TIME )
730 {
731 typeName = "java.util.Date";
732 }
733 else if ( this.getType() == ArgumentType.NUMBER )
734 {
735 typeName = "java.lang.Number";
736 }
737
738 return JavaTypeName.parse( typeName );
739 }
740 catch ( final java.text.ParseException e )
741 {
742 throw new ModelObjectException( getMessage( "javaTypeNameParseException", this.getType(), getMessage( e ) ),
743 e );
744
745 }
746 }
747
748
749
750
751
752
753
754
755
756
757
758
759 public JavaIdentifier getJavaVariableName() throws ModelObjectException
760 {
761 try
762 {
763 return JavaIdentifier.normalize( this.getName() != null ? this.getName() : "",
764 JavaIdentifier.NormalizationMode.VARIABLE_NAME_CONVENTION );
765
766 }
767 catch ( final java.text.ParseException e )
768 {
769 throw new ModelObjectException( getMessage( "javaMethodParameterNameParseException", this.getName(),
770 getMessage( e ) ), e );
771
772 }
773 }
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793 @Deprecated
794 public javax.xml.bind.JAXBElement getAnyElement( final String namespaceURI, final String localPart )
795 {
796 return this.getAnyElement( this.getAny(), namespaceURI, localPart );
797 }
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816 @Deprecated
817 public java.util.List<javax.xml.bind.JAXBElement> getAnyElements( final String namespaceURI,
818 final String localPart )
819 {
820 return this.getAnyElements( this.getAny(), namespaceURI, localPart );
821 }
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842 public <T> javax.xml.bind.JAXBElement<T> getAnyElement( final String namespaceURI, final String localPart,
843 final Class<T> type )
844 {
845 return this.getAnyElement( this.getAny(), namespaceURI, localPart, type );
846 }
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866 public <T> java.util.List<javax.xml.bind.JAXBElement<T>> getAnyElements( final String namespaceURI,
867 final String localPart,
868 final Class<T> type )
869 {
870 return this.getAnyElements( this.getAny(), namespaceURI, localPart, type );
871 }
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887 public <T> T getAnyObject( final Class<T> clazz )
888 {
889 return this.getAnyObject( this.getAny(), clazz );
890 }
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905 public <T> java.util.List<T> getAnyObjects( final Class<T> clazz )
906 {
907 return this.getAnyObjects( this.getAny(), clazz );
908 }
909
910 private static String getMessage( final Throwable t )
911 {
912 return t != null
913 ? t.getMessage() != null && t.getMessage().trim().length() > 0
914 ? t.getMessage()
915 : getMessage( t.getCause() )
916 : null;
917
918 }
919
920 private static String getMessage( final String key, final Object... arguments )
921 {
922 return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle(
923 Argument.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ).
924 getString( key ), arguments );
925
926 }
927
928 }