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.XmlElement;
48 import javax.xml.bind.annotation.XmlType;
49 import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
50 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
51 import javax.xml.datatype.Duration;
52 import javax.xml.datatype.XMLGregorianCalendar;
53 import javax.xml.namespace.QName;
54 import org.w3c.dom.Element;
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
87
88
89
90 @XmlAccessorType(XmlAccessType.FIELD)
91 @XmlType(name = "Message", namespace = "http://jomc.org/model", propOrder = {
92 "template",
93 "arguments",
94 "any"
95 })
96 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
97 public class Message
98 extends ModelObject
99 implements Cloneable, Inheritable
100 {
101
102 @XmlElement(namespace = "http://jomc.org/model", required = true)
103 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
104 protected Texts template;
105 @XmlElement(namespace = "http://jomc.org/model")
106 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
107 protected Arguments arguments;
108 @XmlAnyElement(lax = true)
109 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
110 protected List<Object> any;
111 @XmlAttribute(name = "name", required = true)
112 @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
113 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
114 protected String name;
115 @XmlAttribute(name = "final")
116 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
117 protected Boolean _final;
118 @XmlAttribute(name = "override")
119 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
120 protected Boolean override;
121
122
123
124
125
126 public Message() {
127
128 super();
129 }
130
131
132
133
134
135
136
137
138
139
140 public Message(final Message o) {
141
142 super(o);
143 if (o == null) {
144 throw new NullPointerException("Cannot create a copy of 'Message' from 'null'.");
145 }
146
147 this.template = ((o.template == null)?null:((o.getTemplate() == null)?null:o.getTemplate().clone()));
148
149 this.arguments = ((o.arguments == null)?null:((o.getArguments() == null)?null:o.getArguments().clone()));
150
151 if (o.any!= null) {
152 copyAny(o.getAny(), this.getAny());
153 }
154
155 this.name = ((o.name == null)?null:o.getName());
156
157 this._final = ((o._final == null)?null:o.isFinal());
158
159 this.override = ((o.override == null)?null:o.isOverride());
160 }
161
162
163
164
165
166
167
168
169
170 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
171 public Texts getTemplate() {
172 return template;
173 }
174
175
176
177
178
179
180
181
182
183 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
184 public void setTemplate(Texts value) {
185 this.template = value;
186 }
187
188
189
190
191
192
193
194
195
196 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
197 public Arguments getArguments() {
198 return arguments;
199 }
200
201
202
203
204
205
206
207
208
209 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
210 public void setArguments(Arguments value) {
211 this.arguments = value;
212 }
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
238 public List<Object> getAny() {
239 if (any == null) {
240 any = new ArrayList<Object>();
241 }
242 return this.any;
243 }
244
245
246
247
248
249
250
251
252
253 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
254 public String getName() {
255 return name;
256 }
257
258
259
260
261
262
263
264
265
266 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
267 public void setName(String value) {
268 this.name = value;
269 }
270
271
272
273
274
275
276
277
278
279 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
280 public boolean isFinal() {
281 if (_final == null) {
282 return false;
283 } else {
284 return _final;
285 }
286 }
287
288
289
290
291
292
293
294
295
296 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
297 public void setFinal(Boolean value) {
298 this._final = value;
299 }
300
301
302
303
304
305
306
307
308
309 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
310 public boolean isOverride() {
311 if (override == null) {
312 return false;
313 } else {
314 return override;
315 }
316 }
317
318
319
320
321
322
323
324
325
326 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
327 public void setOverride(Boolean value) {
328 this.override = value;
329 }
330
331
332
333
334
335
336
337
338
339
340
341 @SuppressWarnings("unchecked")
342 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
343 private static void copyAny(final List<Object> source, final List<Object> target) {
344
345 if ((source!= null)&&(!source.isEmpty())) {
346 for (final Iterator<?> it = source.iterator(); it.hasNext(); ) {
347 final Object next = it.next();
348 if (next instanceof Element) {
349
350 target.add(((Element)((Element) next).cloneNode(true)));
351 continue;
352 }
353 if (next instanceof Object) {
354
355 target.add(copyOf(((Object) next)));
356 continue;
357 }
358
359 throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Any' of class 'org.jomc.model.Message'."));
360 }
361 }
362 }
363
364
365
366
367
368
369
370
371
372 @SuppressWarnings("unchecked")
373 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
374 private static Object copyOf(final Object o) {
375
376 try {
377 if (o!= null) {
378 if (o.getClass().isPrimitive()) {
379 return o;
380 }
381 if (o.getClass().isArray()) {
382 return copyOfArray(o);
383 }
384
385 if (o instanceof Boolean) {
386 return o;
387 }
388 if (o instanceof Byte) {
389 return o;
390 }
391 if (o instanceof Character) {
392 return o;
393 }
394 if (o instanceof Double) {
395 return o;
396 }
397 if (o instanceof Enum) {
398 return o;
399 }
400 if (o instanceof Float) {
401 return o;
402 }
403 if (o instanceof Integer) {
404 return o;
405 }
406 if (o instanceof Long) {
407 return o;
408 }
409 if (o instanceof Short) {
410 return o;
411 }
412 if (o instanceof String) {
413 return o;
414 }
415 if (o instanceof BigDecimal) {
416 return o;
417 }
418 if (o instanceof BigInteger) {
419 return o;
420 }
421 if (o instanceof UUID) {
422 return o;
423 }
424 if (o instanceof QName) {
425 return o;
426 }
427 if (o instanceof Duration) {
428 return o;
429 }
430 if (o instanceof Currency) {
431 return o;
432 }
433
434 if (o instanceof File) {
435 return new File(o.toString());
436 }
437 if (o instanceof URI) {
438 return new URI(o.toString());
439 }
440 if (o instanceof URL) {
441 return new URL(o.toString());
442 }
443 if (o instanceof MimeType) {
444 return new MimeType(o.toString());
445 }
446
447 if (o instanceof XMLGregorianCalendar) {
448 return ((XMLGregorianCalendar) o).clone();
449 }
450 if (o instanceof Date) {
451 return ((Date) o).clone();
452 }
453 if (o instanceof Calendar) {
454 return ((Calendar) o).clone();
455 }
456 if (o instanceof TimeZone) {
457 return ((TimeZone) o).clone();
458 }
459 if (o instanceof Locale) {
460 return ((Locale) o).clone();
461 }
462 if (o instanceof Element) {
463 return ((Element)((Element) o).cloneNode(true));
464 }
465 if (o instanceof JAXBElement) {
466 return copyOf(((JAXBElement) o));
467 }
468 try {
469 return o.getClass().getMethod("clone", ((Class[]) null)).invoke(o, ((Object[]) null));
470 } catch (NoSuchMethodException e) {
471 if (o instanceof Serializable) {
472 return copyOf(((Serializable) o));
473 }
474
475 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
476 } catch (IllegalAccessException e) {
477
478 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
479 } catch (InvocationTargetException e) {
480
481 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
482 } catch (SecurityException e) {
483
484 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
485 } catch (IllegalArgumentException e) {
486
487 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
488 } catch (ExceptionInInitializerError e) {
489
490 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
491 }
492 }
493 return null;
494 } catch (URISyntaxException e) {
495 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
496 } catch (MimeTypeParseException e) {
497 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
498 } catch (MalformedURLException e) {
499 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
500 }
501 }
502
503
504
505
506
507
508
509
510
511 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
512 private static Object copyOfArray(final Object array) {
513
514 if (array!= null) {
515 if (array.getClass() == boolean[].class) {
516 return copyOf(((boolean[]) array));
517 }
518 if (array.getClass() == byte[].class) {
519 return copyOf(((byte[]) array));
520 }
521 if (array.getClass() == char[].class) {
522 return copyOf(((char[]) array));
523 }
524 if (array.getClass() == double[].class) {
525 return copyOf(((double[]) array));
526 }
527 if (array.getClass() == float[].class) {
528 return copyOf(((float[]) array));
529 }
530 if (array.getClass() == int[].class) {
531 return copyOf(((int[]) array));
532 }
533 if (array.getClass() == long[].class) {
534 return copyOf(((long[]) array));
535 }
536 if (array.getClass() == short[].class) {
537 return copyOf(((short[]) array));
538 }
539 final int len = Array.getLength(array);
540 final Object copy = Array.newInstance(array.getClass().getComponentType(), len);
541 for (int i = (len- 1); (i >= 0); i--) {
542 Array.set(copy, i, copyOf(Array.get(array, i)));
543 }
544 return copy;
545 }
546 return null;
547 }
548
549
550
551
552
553
554
555
556
557 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
558 private static boolean[] copyOf(final boolean[] array) {
559
560 if (array!= null) {
561 final boolean[] copy = ((boolean[]) Array.newInstance(array.getClass().getComponentType(), array.length));
562 System.arraycopy(array, 0, copy, 0, array.length);
563 return copy;
564 }
565 return null;
566 }
567
568
569
570
571
572
573
574
575
576 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
577 private static byte[] copyOf(final byte[] array) {
578
579 if (array!= null) {
580 final byte[] copy = ((byte[]) Array.newInstance(array.getClass().getComponentType(), array.length));
581 System.arraycopy(array, 0, copy, 0, array.length);
582 return copy;
583 }
584 return null;
585 }
586
587
588
589
590
591
592
593
594
595 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
596 private static char[] copyOf(final char[] array) {
597
598 if (array!= null) {
599 final char[] copy = ((char[]) Array.newInstance(array.getClass().getComponentType(), array.length));
600 System.arraycopy(array, 0, copy, 0, array.length);
601 return copy;
602 }
603 return null;
604 }
605
606
607
608
609
610
611
612
613
614 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
615 private static double[] copyOf(final double[] array) {
616
617 if (array!= null) {
618 final double[] copy = ((double[]) Array.newInstance(array.getClass().getComponentType(), array.length));
619 System.arraycopy(array, 0, copy, 0, array.length);
620 return copy;
621 }
622 return null;
623 }
624
625
626
627
628
629
630
631
632
633 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
634 private static float[] copyOf(final float[] array) {
635
636 if (array!= null) {
637 final float[] copy = ((float[]) Array.newInstance(array.getClass().getComponentType(), array.length));
638 System.arraycopy(array, 0, copy, 0, array.length);
639 return copy;
640 }
641 return null;
642 }
643
644
645
646
647
648
649
650
651
652 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
653 private static int[] copyOf(final int[] array) {
654
655 if (array!= null) {
656 final int[] copy = ((int[]) Array.newInstance(array.getClass().getComponentType(), array.length));
657 System.arraycopy(array, 0, copy, 0, array.length);
658 return copy;
659 }
660 return null;
661 }
662
663
664
665
666
667
668
669
670
671 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
672 private static long[] copyOf(final long[] array) {
673
674 if (array!= null) {
675 final long[] copy = ((long[]) Array.newInstance(array.getClass().getComponentType(), array.length));
676 System.arraycopy(array, 0, copy, 0, array.length);
677 return copy;
678 }
679 return null;
680 }
681
682
683
684
685
686
687
688
689
690 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
691 private static short[] copyOf(final short[] array) {
692
693 if (array!= null) {
694 final short[] copy = ((short[]) Array.newInstance(array.getClass().getComponentType(), array.length));
695 System.arraycopy(array, 0, copy, 0, array.length);
696 return copy;
697 }
698 return null;
699 }
700
701
702
703
704
705
706
707
708
709 @SuppressWarnings("unchecked")
710 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
711 private static JAXBElement copyOf(final JAXBElement element) {
712
713 if (element!= null) {
714 final JAXBElement copy = new JAXBElement(element.getName(), element.getDeclaredType(), element.getScope(), element.getValue());
715 copy.setNil(element.isNil());
716 copy.setValue(copyOf(copy.getValue()));
717 return copy;
718 }
719 return null;
720 }
721
722
723
724
725
726
727
728
729
730 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
731 private static Serializable copyOf(final Serializable serializable) {
732
733 if (serializable!= null) {
734 try {
735 final ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
736 final ObjectOutputStream out = new ObjectOutputStream(byteArrayOutput);
737 out.writeObject(serializable);
738 out.close();
739 final ByteArrayInputStream byteArrayInput = new ByteArrayInputStream(byteArrayOutput.toByteArray());
740 final ObjectInputStream in = new ObjectInputStream(byteArrayInput);
741 final Serializable copy = ((Serializable) in.readObject());
742 in.close();
743 return copy;
744 } catch (SecurityException e) {
745 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
746 } catch (ClassNotFoundException e) {
747 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
748 } catch (InvalidClassException e) {
749 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
750 } catch (NotSerializableException e) {
751 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
752 } catch (StreamCorruptedException e) {
753 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
754 } catch (OptionalDataException e) {
755 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
756 } catch (IOException e) {
757 throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
758 }
759 }
760 return null;
761 }
762
763
764
765
766
767
768
769
770 @Override
771 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
772 public Message clone() {
773 {
774
775 final Message clone = ((Message) super.clone());
776
777 clone.template = ((this.template == null)?null:((this.getTemplate() == null)?null:this.getTemplate().clone()));
778
779 clone.arguments = ((this.arguments == null)?null:((this.getArguments() == null)?null:this.getArguments().clone()));
780
781 if (this.any!= null) {
782 clone.any = null;
783 copyAny(this.getAny(), clone.getAny());
784 }
785
786 clone.name = ((this.name == null)?null:this.getName());
787
788 clone._final = ((this._final == null)?null:this.isFinal());
789
790 clone.override = ((this.override == null)?null:this.isOverride());
791 return clone;
792 }
793 }
794
795
796
797
798
799 @javax.xml.bind.annotation.XmlTransient
800 private static final String LINE_SEPARATOR = System.getProperty( "line.separator", "\n" );
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820 @Deprecated
821 public javax.xml.bind.JAXBElement getAnyElement( final String namespaceURI, final String localPart )
822 {
823 return this.getAnyElement( this.getAny(), namespaceURI, localPart );
824 }
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843 @Deprecated
844 public java.util.List<javax.xml.bind.JAXBElement> getAnyElements( final String namespaceURI,
845 final String localPart )
846 {
847 return this.getAnyElements( this.getAny(), namespaceURI, localPart );
848 }
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869 public <T> javax.xml.bind.JAXBElement<T> getAnyElement( final String namespaceURI, final String localPart,
870 final Class<T> type )
871 {
872 return this.getAnyElement( this.getAny(), namespaceURI, localPart, type );
873 }
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893 public <T> java.util.List<javax.xml.bind.JAXBElement<T>> getAnyElements( final String namespaceURI,
894 final String localPart,
895 final Class<T> type )
896 {
897 return this.getAnyElements( this.getAny(), namespaceURI, localPart, type );
898 }
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914 public <T> T getAnyObject( final Class<T> clazz )
915 {
916 return this.getAnyObject( this.getAny(), clazz );
917 }
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932 public <T> java.util.List<T> getAnyObjects( final Class<T> clazz )
933 {
934 return this.getAnyObjects( this.getAny(), clazz );
935 }
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952 public java.text.MessageFormat getJavaMessage( final Locale locale ) throws ModelObjectException
953 {
954 if ( locale == null )
955 {
956 throw new NullPointerException( "locale" );
957 }
958
959 final Text text = this.getTemplate().getText( locale.getLanguage().toLowerCase( Locale.ENGLISH ) );
960 final StringBuilder builder = new StringBuilder( text.getValue().length() );
961 String pattern = null;
962
963 try
964 {
965 final java.io.BufferedReader reader =
966 new java.io.BufferedReader( new java.io.StringReader( text.getValue() ) );
967
968 String line;
969 while ( ( line = reader.readLine() ) != null )
970 {
971 builder.append( LINE_SEPARATOR ).append( line );
972 }
973
974 pattern = builder.length() > 0 ? builder.substring( LINE_SEPARATOR.length() ) : builder.toString();
975 return new java.text.MessageFormat( pattern, locale );
976
977 }
978 catch ( final IllegalArgumentException e )
979 {
980 throw new ModelObjectException( getMessage( "javaMessageParseException", pattern, getMessage( e ) ), e );
981 }
982 catch ( final java.io.IOException e )
983 {
984 throw new AssertionError( e );
985 }
986 }
987
988
989
990
991
992
993
994
995
996
997
998
999 public JavaIdentifier getJavaGetterMethodName() throws ModelObjectException
1000 {
1001 try
1002 {
1003 return JavaIdentifier.parse( "get" + JavaIdentifier.normalize(
1004 this.getName() != null ? this.getName() : "", JavaIdentifier.NormalizationMode.CAMEL_CASE ) );
1005
1006 }
1007 catch ( final java.text.ParseException e )
1008 {
1009 throw new ModelObjectException( getMessage( "javaIdentifierParseException", this.getName(),
1010 getMessage( e ) ), e );
1011
1012 }
1013 }
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026 public JavaIdentifier getJavaSetterMethodName() throws ModelObjectException
1027 {
1028 try
1029 {
1030 return JavaIdentifier.parse( "set" + JavaIdentifier.normalize(
1031 this.getName() != null ? this.getName() : "", JavaIdentifier.NormalizationMode.CAMEL_CASE ) );
1032
1033 }
1034 catch ( final java.text.ParseException e )
1035 {
1036 throw new ModelObjectException( getMessage( "javaIdentifierParseException", this.getName(),
1037 getMessage( e ) ), e );
1038
1039 }
1040 }
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053 public JavaIdentifier getJavaVariableName() throws ModelObjectException
1054 {
1055 try
1056 {
1057 return JavaIdentifier.normalize( this.getName() != null ? this.getName() : "",
1058 JavaIdentifier.NormalizationMode.VARIABLE_NAME_CONVENTION );
1059
1060 }
1061 catch ( final java.text.ParseException e )
1062 {
1063 throw new ModelObjectException( getMessage( "javaIdentifierParseException", this.getName(),
1064 getMessage( e ) ), e );
1065
1066 }
1067 }
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080 public JavaIdentifier getJavaConstantName() throws ModelObjectException
1081 {
1082 try
1083 {
1084 return JavaIdentifier.normalize( this.getName() != null ? this.getName() : "",
1085 JavaIdentifier.NormalizationMode.CONSTANT_NAME_CONVENTION );
1086
1087 }
1088 catch ( final java.text.ParseException e )
1089 {
1090 throw new ModelObjectException( getMessage( "javaIdentifierParseException", this.getName(),
1091 getMessage( e ) ), e );
1092
1093 }
1094 }
1095
1096 private static String getMessage( final Throwable t )
1097 {
1098 return t != null ? t.getMessage() != null ? t.getMessage() : getMessage( t.getCause() ) : null;
1099 }
1100
1101 private static String getMessage( final String key, final Object... arguments )
1102 {
1103 return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle(
1104 Message.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ).
1105 getString( key ), arguments );
1106
1107 }
1108
1109 }