1 | // |
2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2 |
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: 2014.03.26 at 03:31:26 PM CET |
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 | * Model of an instance. |
60 | * |
61 | * The 'Instance' type defines attributes 'identifier', 'name', 'class' and 'stateless'. Attribute 'identifier' holds an |
62 | * identifier uniquely identifying the instance in a set of instances. Attribute 'name' holds an identifier uniquely |
63 | * identifying the implementation of the specifications implemented by an instance. Attribute 'class' holds an identifier |
64 | * of the class of an instance. Attribute 'stateless' flags an instance stateless. |
65 | * |
66 | * An instance is build from implementations. An implementation declaring a location declares its instance located outside |
67 | * the scope of the model. An implementation not delcaring a class is only available during implementation inheritance |
68 | * processing. No instance is build from such implementations. |
69 | * |
70 | * |
71 | * <p>Java class for Instance complex type. |
72 | * |
73 | * <p>The following schema fragment specifies the expected content contained within this class. |
74 | * |
75 | * <pre> |
76 | * <complexType name="Instance"> |
77 | * <complexContent> |
78 | * <extension base="{http://jomc.org/model}ModelObject"> |
79 | * <sequence> |
80 | * <element ref="{http://jomc.org/model}specifications" minOccurs="0"/> |
81 | * <element ref="{http://jomc.org/model}dependencies" minOccurs="0"/> |
82 | * <element ref="{http://jomc.org/model}properties" minOccurs="0"/> |
83 | * <element ref="{http://jomc.org/model}messages" minOccurs="0"/> |
84 | * <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/> |
85 | * </sequence> |
86 | * <attribute name="identifier" use="required" type="{http://jomc.org/model}Identifier" /> |
87 | * <attribute name="name" use="required" type="{http://jomc.org/model}Identifier" /> |
88 | * <attribute name="class" use="required" type="{http://jomc.org/model}Identifier" /> |
89 | * <attribute name="stateless" type="{http://jomc.org/model}Flag" default="false" /> |
90 | * </extension> |
91 | * </complexContent> |
92 | * </complexType> |
93 | * </pre> |
94 | * |
95 | * |
96 | */ |
97 | @XmlAccessorType(XmlAccessType.FIELD) |
98 | @XmlType(name = "Instance", namespace = "http://jomc.org/model", propOrder = { |
99 | "specifications", |
100 | "dependencies", |
101 | "properties", |
102 | "messages", |
103 | "any" |
104 | }) |
105 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
106 | public class Instance |
107 | extends ModelObject |
108 | implements Cloneable |
109 | { |
110 | |
111 | @XmlElement(namespace = "http://jomc.org/model") |
112 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
113 | protected Specifications specifications; |
114 | @XmlElement(namespace = "http://jomc.org/model") |
115 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
116 | protected Dependencies dependencies; |
117 | @XmlElement(namespace = "http://jomc.org/model") |
118 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
119 | protected Properties properties; |
120 | @XmlElement(namespace = "http://jomc.org/model") |
121 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
122 | protected Messages messages; |
123 | @XmlAnyElement(lax = true) |
124 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
125 | protected List<Object> any; |
126 | @XmlAttribute(name = "identifier", required = true) |
127 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) |
128 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
129 | protected String identifier; |
130 | @XmlAttribute(name = "name", required = true) |
131 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) |
132 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
133 | protected String name; |
134 | @XmlAttribute(name = "class", required = true) |
135 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) |
136 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
137 | protected String clazz; |
138 | @XmlAttribute(name = "stateless") |
139 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
140 | protected Boolean stateless; |
141 | |
142 | /** |
143 | * Creates a new {@code Instance} instance. |
144 | * |
145 | */ |
146 | public Instance() { |
147 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
148 | super(); |
149 | } |
150 | |
151 | /** |
152 | * Creates a new {@code Instance} instance by deeply copying a given {@code Instance} instance. |
153 | * |
154 | * |
155 | * @param o |
156 | * The instance to copy. |
157 | * @throws NullPointerException |
158 | * if {@code o} is {@code null}. |
159 | */ |
160 | public Instance(final Instance o) { |
161 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
162 | super(o); |
163 | if (o == null) { |
164 | throw new NullPointerException("Cannot create a copy of 'Instance' from 'null'."); |
165 | } |
166 | // CClassInfo: org.jomc.model.Specifications |
167 | this.specifications = ((o.specifications == null)?null:((o.getSpecifications() == null)?null:o.getSpecifications().clone())); |
168 | // CClassInfo: org.jomc.model.Dependencies |
169 | this.dependencies = ((o.dependencies == null)?null:((o.getDependencies() == null)?null:o.getDependencies().clone())); |
170 | // CClassInfo: org.jomc.model.Properties |
171 | this.properties = ((o.properties == null)?null:((o.getProperties() == null)?null:o.getProperties().clone())); |
172 | // CClassInfo: org.jomc.model.Messages |
173 | this.messages = ((o.messages == null)?null:((o.getMessages() == null)?null:o.getMessages().clone())); |
174 | // 'Any' collection. |
175 | if (o.any!= null) { |
176 | copyAny(o.getAny(), this.getAny()); |
177 | } |
178 | // CBuiltinLeafInfo: java.lang.String |
179 | this.identifier = ((o.identifier == null)?null:o.getIdentifier()); |
180 | // CBuiltinLeafInfo: java.lang.String |
181 | this.name = ((o.name == null)?null:o.getName()); |
182 | // CBuiltinLeafInfo: java.lang.String |
183 | this.clazz = ((o.clazz == null)?null:o.getClazz()); |
184 | // CBuiltinLeafInfo: java.lang.Boolean |
185 | this.stateless = ((o.stateless == null)?null:o.isStateless()); |
186 | } |
187 | |
188 | /** |
189 | * Specifications implemented by this instance or {@code null}. |
190 | * |
191 | * @return |
192 | * possible object is |
193 | * {@link Specifications } |
194 | * |
195 | */ |
196 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
197 | public Specifications getSpecifications() { |
198 | return specifications; |
199 | } |
200 | |
201 | /** |
202 | * Sets the value of the specifications property. |
203 | * |
204 | * @param value |
205 | * allowed object is |
206 | * {@link Specifications } |
207 | * |
208 | */ |
209 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
210 | public void setSpecifications(Specifications value) { |
211 | this.specifications = value; |
212 | } |
213 | |
214 | /** |
215 | * Dependencies of this instance or {@code null}. |
216 | * |
217 | * @return |
218 | * possible object is |
219 | * {@link Dependencies } |
220 | * |
221 | */ |
222 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
223 | public Dependencies getDependencies() { |
224 | return dependencies; |
225 | } |
226 | |
227 | /** |
228 | * Sets the value of the dependencies property. |
229 | * |
230 | * @param value |
231 | * allowed object is |
232 | * {@link Dependencies } |
233 | * |
234 | */ |
235 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
236 | public void setDependencies(Dependencies value) { |
237 | this.dependencies = value; |
238 | } |
239 | |
240 | /** |
241 | * Properties of this instance or {@code null}. |
242 | * |
243 | * @return |
244 | * possible object is |
245 | * {@link Properties } |
246 | * |
247 | */ |
248 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
249 | public Properties getProperties() { |
250 | return properties; |
251 | } |
252 | |
253 | /** |
254 | * Sets the value of the properties property. |
255 | * |
256 | * @param value |
257 | * allowed object is |
258 | * {@link Properties } |
259 | * |
260 | */ |
261 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
262 | public void setProperties(Properties value) { |
263 | this.properties = value; |
264 | } |
265 | |
266 | /** |
267 | * Messages of this instance or {@code null}. |
268 | * |
269 | * @return |
270 | * possible object is |
271 | * {@link Messages } |
272 | * |
273 | */ |
274 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
275 | public Messages getMessages() { |
276 | return messages; |
277 | } |
278 | |
279 | /** |
280 | * Sets the value of the messages property. |
281 | * |
282 | * @param value |
283 | * allowed object is |
284 | * {@link Messages } |
285 | * |
286 | */ |
287 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
288 | public void setMessages(Messages value) { |
289 | this.messages = value; |
290 | } |
291 | |
292 | /** |
293 | * Gets the value of the any property. |
294 | * |
295 | * <p> |
296 | * This accessor method returns a reference to the live list, |
297 | * not a snapshot. Therefore any modification you make to the |
298 | * returned list will be present inside the JAXB object. |
299 | * This is why there is not a <CODE>set</CODE> method for the any property. |
300 | * |
301 | * <p> |
302 | * For example, to add a new item, do as follows: |
303 | * <pre> |
304 | * getAny().add(newItem); |
305 | * </pre> |
306 | * |
307 | * |
308 | * <p> |
309 | * Objects of the following type(s) are allowed in the list |
310 | * {@link Object } |
311 | * {@link Element } |
312 | * |
313 | * |
314 | */ |
315 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
316 | public List<Object> getAny() { |
317 | if (any == null) { |
318 | any = new ArrayList<Object>(); |
319 | } |
320 | return this.any; |
321 | } |
322 | |
323 | /** |
324 | * The identifier of this instance. |
325 | * |
326 | * @return |
327 | * possible object is |
328 | * {@link String } |
329 | * |
330 | */ |
331 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
332 | public String getIdentifier() { |
333 | return identifier; |
334 | } |
335 | |
336 | /** |
337 | * Sets the value of the identifier property. |
338 | * |
339 | * @param value |
340 | * allowed object is |
341 | * {@link String } |
342 | * |
343 | */ |
344 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
345 | public void setIdentifier(String value) { |
346 | this.identifier = value; |
347 | } |
348 | |
349 | /** |
350 | * The name of the implementation of the specifications implemented by this instance. |
351 | * |
352 | * @return |
353 | * possible object is |
354 | * {@link String } |
355 | * |
356 | */ |
357 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
358 | public String getName() { |
359 | return name; |
360 | } |
361 | |
362 | /** |
363 | * Sets the value of the name property. |
364 | * |
365 | * @param value |
366 | * allowed object is |
367 | * {@link String } |
368 | * |
369 | */ |
370 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
371 | public void setName(String value) { |
372 | this.name = value; |
373 | } |
374 | |
375 | /** |
376 | * The identifier of the class of this instance. |
377 | * |
378 | * @return |
379 | * possible object is |
380 | * {@link String } |
381 | * |
382 | */ |
383 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
384 | public String getClazz() { |
385 | return clazz; |
386 | } |
387 | |
388 | /** |
389 | * Sets the value of the clazz property. |
390 | * |
391 | * @param value |
392 | * allowed object is |
393 | * {@link String } |
394 | * |
395 | */ |
396 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
397 | public void setClazz(String value) { |
398 | this.clazz = value; |
399 | } |
400 | |
401 | /** |
402 | * {@code true}, if this instance does not retain state across operations. |
403 | * |
404 | * @return |
405 | * possible object is |
406 | * {@link Boolean } |
407 | * |
408 | */ |
409 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
410 | public boolean isStateless() { |
411 | if (stateless == null) { |
412 | return false; |
413 | } else { |
414 | return stateless; |
415 | } |
416 | } |
417 | |
418 | /** |
419 | * Sets the value of the stateless property. |
420 | * |
421 | * @param value |
422 | * allowed object is |
423 | * {@link Boolean } |
424 | * |
425 | */ |
426 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
427 | public void setStateless(Boolean value) { |
428 | this.stateless = value; |
429 | } |
430 | |
431 | /** |
432 | * Copies all values of property {@code Any} deeply. |
433 | * |
434 | * @param source |
435 | * The source to copy from. |
436 | * @param target |
437 | * The target to copy {@code source} to. |
438 | * @throws NullPointerException |
439 | * if {@code target} is {@code null}. |
440 | */ |
441 | @SuppressWarnings("unchecked") |
442 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
443 | private static void copyAny(final List<Object> source, final List<Object> target) { |
444 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
445 | if ((source!= null)&&(!source.isEmpty())) { |
446 | for (final Iterator<?> it = source.iterator(); it.hasNext(); ) { |
447 | final Object next = it.next(); |
448 | if (next instanceof Element) { |
449 | // CWildcardTypeInfo: org.w3c.dom.Element |
450 | target.add(((Element)((Element) next).cloneNode(true))); |
451 | continue; |
452 | } |
453 | if (next instanceof Object) { |
454 | // CBuiltinLeafInfo: java.lang.Object |
455 | target.add(copyOf(((Object) next))); |
456 | continue; |
457 | } |
458 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
459 | throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Any' of class 'org.jomc.model.Instance'.")); |
460 | } |
461 | } |
462 | } |
463 | |
464 | /** |
465 | * Creates and returns a deep copy of a given object. |
466 | * |
467 | * @param o |
468 | * The instance to copy or {@code null}. |
469 | * @return |
470 | * A deep copy of {@code o} or {@code null} if {@code o} is {@code null}. |
471 | */ |
472 | @SuppressWarnings("unchecked") |
473 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
474 | private static Object copyOf(final Object o) { |
475 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
476 | try { |
477 | if (o!= null) { |
478 | if (o.getClass().isPrimitive()) { |
479 | return o; |
480 | } |
481 | if (o.getClass().isArray()) { |
482 | return copyOfArray(o); |
483 | } |
484 | // Immutable types. |
485 | if (o instanceof Boolean) { |
486 | return o; |
487 | } |
488 | if (o instanceof Byte) { |
489 | return o; |
490 | } |
491 | if (o instanceof Character) { |
492 | return o; |
493 | } |
494 | if (o instanceof Double) { |
495 | return o; |
496 | } |
497 | if (o instanceof Enum) { |
498 | return o; |
499 | } |
500 | if (o instanceof Float) { |
501 | return o; |
502 | } |
503 | if (o instanceof Integer) { |
504 | return o; |
505 | } |
506 | if (o instanceof Long) { |
507 | return o; |
508 | } |
509 | if (o instanceof Short) { |
510 | return o; |
511 | } |
512 | if (o instanceof String) { |
513 | return o; |
514 | } |
515 | if (o instanceof BigDecimal) { |
516 | return o; |
517 | } |
518 | if (o instanceof BigInteger) { |
519 | return o; |
520 | } |
521 | if (o instanceof UUID) { |
522 | return o; |
523 | } |
524 | if (o instanceof QName) { |
525 | return o; |
526 | } |
527 | if (o instanceof Duration) { |
528 | return o; |
529 | } |
530 | if (o instanceof Currency) { |
531 | return o; |
532 | } |
533 | // String based types. |
534 | if (o instanceof File) { |
535 | return new File(o.toString()); |
536 | } |
537 | if (o instanceof URI) { |
538 | return new URI(o.toString()); |
539 | } |
540 | if (o instanceof URL) { |
541 | return new URL(o.toString()); |
542 | } |
543 | if (o instanceof MimeType) { |
544 | return new MimeType(o.toString()); |
545 | } |
546 | // Cloneable types. |
547 | if (o instanceof XMLGregorianCalendar) { |
548 | return ((XMLGregorianCalendar) o).clone(); |
549 | } |
550 | if (o instanceof Date) { |
551 | return ((Date) o).clone(); |
552 | } |
553 | if (o instanceof Calendar) { |
554 | return ((Calendar) o).clone(); |
555 | } |
556 | if (o instanceof TimeZone) { |
557 | return ((TimeZone) o).clone(); |
558 | } |
559 | if (o instanceof Locale) { |
560 | return ((Locale) o).clone(); |
561 | } |
562 | if (o instanceof Element) { |
563 | return ((Element)((Element) o).cloneNode(true)); |
564 | } |
565 | if (o instanceof JAXBElement) { |
566 | return copyOf(((JAXBElement) o)); |
567 | } |
568 | try { |
569 | return o.getClass().getMethod("clone", ((Class[]) null)).invoke(o, ((Object[]) null)); |
570 | } catch (NoSuchMethodException e) { |
571 | if (o instanceof Serializable) { |
572 | return copyOf(((Serializable) o)); |
573 | } |
574 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
575 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
576 | } catch (IllegalAccessException e) { |
577 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
578 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
579 | } catch (InvocationTargetException e) { |
580 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
581 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
582 | } catch (SecurityException e) { |
583 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
584 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
585 | } catch (IllegalArgumentException e) { |
586 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
587 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
588 | } catch (ExceptionInInitializerError e) { |
589 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
590 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
591 | } |
592 | } |
593 | return null; |
594 | } catch (MalformedURLException e) { |
595 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
596 | } catch (MimeTypeParseException e) { |
597 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
598 | } catch (URISyntaxException e) { |
599 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e)); |
600 | } |
601 | } |
602 | |
603 | /** |
604 | * Creates and returns a deep copy of a given array. |
605 | * |
606 | * @param array |
607 | * The array to copy or {@code null}. |
608 | * @return |
609 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
610 | */ |
611 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
612 | private static Object copyOfArray(final Object array) { |
613 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
614 | if (array!= null) { |
615 | if (array.getClass() == boolean[].class) { |
616 | return copyOf(((boolean[]) array)); |
617 | } |
618 | if (array.getClass() == byte[].class) { |
619 | return copyOf(((byte[]) array)); |
620 | } |
621 | if (array.getClass() == char[].class) { |
622 | return copyOf(((char[]) array)); |
623 | } |
624 | if (array.getClass() == double[].class) { |
625 | return copyOf(((double[]) array)); |
626 | } |
627 | if (array.getClass() == float[].class) { |
628 | return copyOf(((float[]) array)); |
629 | } |
630 | if (array.getClass() == int[].class) { |
631 | return copyOf(((int[]) array)); |
632 | } |
633 | if (array.getClass() == long[].class) { |
634 | return copyOf(((long[]) array)); |
635 | } |
636 | if (array.getClass() == short[].class) { |
637 | return copyOf(((short[]) array)); |
638 | } |
639 | final int len = Array.getLength(array); |
640 | final Object copy = Array.newInstance(array.getClass().getComponentType(), len); |
641 | for (int i = (len- 1); (i >= 0); i--) { |
642 | Array.set(copy, i, copyOf(Array.get(array, i))); |
643 | } |
644 | return copy; |
645 | } |
646 | return null; |
647 | } |
648 | |
649 | /** |
650 | * Creates and returns a deep copy of a given array. |
651 | * |
652 | * @param array |
653 | * The array to copy or {@code null}. |
654 | * @return |
655 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
656 | */ |
657 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
658 | private static boolean[] copyOf(final boolean[] array) { |
659 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
660 | if (array!= null) { |
661 | final boolean[] copy = ((boolean[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
662 | System.arraycopy(array, 0, copy, 0, array.length); |
663 | return copy; |
664 | } |
665 | return null; |
666 | } |
667 | |
668 | /** |
669 | * Creates and returns a deep copy of a given array. |
670 | * |
671 | * @param array |
672 | * The array to copy or {@code null}. |
673 | * @return |
674 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
675 | */ |
676 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
677 | private static byte[] copyOf(final byte[] array) { |
678 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
679 | if (array!= null) { |
680 | final byte[] copy = ((byte[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
681 | System.arraycopy(array, 0, copy, 0, array.length); |
682 | return copy; |
683 | } |
684 | return null; |
685 | } |
686 | |
687 | /** |
688 | * Creates and returns a deep copy of a given array. |
689 | * |
690 | * @param array |
691 | * The array to copy or {@code null}. |
692 | * @return |
693 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
694 | */ |
695 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
696 | private static char[] copyOf(final char[] array) { |
697 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
698 | if (array!= null) { |
699 | final char[] copy = ((char[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
700 | System.arraycopy(array, 0, copy, 0, array.length); |
701 | return copy; |
702 | } |
703 | return null; |
704 | } |
705 | |
706 | /** |
707 | * Creates and returns a deep copy of a given array. |
708 | * |
709 | * @param array |
710 | * The array to copy or {@code null}. |
711 | * @return |
712 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
713 | */ |
714 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
715 | private static double[] copyOf(final double[] array) { |
716 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
717 | if (array!= null) { |
718 | final double[] copy = ((double[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
719 | System.arraycopy(array, 0, copy, 0, array.length); |
720 | return copy; |
721 | } |
722 | return null; |
723 | } |
724 | |
725 | /** |
726 | * Creates and returns a deep copy of a given array. |
727 | * |
728 | * @param array |
729 | * The array to copy or {@code null}. |
730 | * @return |
731 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
732 | */ |
733 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
734 | private static float[] copyOf(final float[] array) { |
735 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
736 | if (array!= null) { |
737 | final float[] copy = ((float[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
738 | System.arraycopy(array, 0, copy, 0, array.length); |
739 | return copy; |
740 | } |
741 | return null; |
742 | } |
743 | |
744 | /** |
745 | * Creates and returns a deep copy of a given array. |
746 | * |
747 | * @param array |
748 | * The array to copy or {@code null}. |
749 | * @return |
750 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
751 | */ |
752 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
753 | private static int[] copyOf(final int[] array) { |
754 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
755 | if (array!= null) { |
756 | final int[] copy = ((int[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
757 | System.arraycopy(array, 0, copy, 0, array.length); |
758 | return copy; |
759 | } |
760 | return null; |
761 | } |
762 | |
763 | /** |
764 | * Creates and returns a deep copy of a given array. |
765 | * |
766 | * @param array |
767 | * The array to copy or {@code null}. |
768 | * @return |
769 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
770 | */ |
771 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
772 | private static long[] copyOf(final long[] array) { |
773 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
774 | if (array!= null) { |
775 | final long[] copy = ((long[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
776 | System.arraycopy(array, 0, copy, 0, array.length); |
777 | return copy; |
778 | } |
779 | return null; |
780 | } |
781 | |
782 | /** |
783 | * Creates and returns a deep copy of a given array. |
784 | * |
785 | * @param array |
786 | * The array to copy or {@code null}. |
787 | * @return |
788 | * A deep copy of {@code array} or {@code null} if {@code array} is {@code null}. |
789 | */ |
790 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
791 | private static short[] copyOf(final short[] array) { |
792 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
793 | if (array!= null) { |
794 | final short[] copy = ((short[]) Array.newInstance(array.getClass().getComponentType(), array.length)); |
795 | System.arraycopy(array, 0, copy, 0, array.length); |
796 | return copy; |
797 | } |
798 | return null; |
799 | } |
800 | |
801 | /** |
802 | * Creates and returns a deep copy of a given {@code JAXBElement} instance. |
803 | * |
804 | * @param element |
805 | * The instance to copy or {@code null}. |
806 | * @return |
807 | * A deep copy of {@code element} or {@code null} if {@code element} is {@code null}. |
808 | */ |
809 | @SuppressWarnings("unchecked") |
810 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
811 | private static JAXBElement copyOf(final JAXBElement element) { |
812 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
813 | if (element!= null) { |
814 | final JAXBElement copy = new JAXBElement(element.getName(), element.getDeclaredType(), element.getScope(), element.getValue()); |
815 | copy.setNil(element.isNil()); |
816 | copy.setValue(copyOf(copy.getValue())); |
817 | return copy; |
818 | } |
819 | return null; |
820 | } |
821 | |
822 | /** |
823 | * Creates and returns a deep copy of a given {@code Serializable}. |
824 | * |
825 | * @param serializable |
826 | * The instance to copy or {@code null}. |
827 | * @return |
828 | * A deep copy of {@code serializable} or {@code null} if {@code serializable} is {@code null}. |
829 | */ |
830 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
831 | private static Serializable copyOf(final Serializable serializable) { |
832 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
833 | if (serializable!= null) { |
834 | try { |
835 | final ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream(); |
836 | final ObjectOutputStream out = new ObjectOutputStream(byteArrayOutput); |
837 | out.writeObject(serializable); |
838 | out.close(); |
839 | final ByteArrayInputStream byteArrayInput = new ByteArrayInputStream(byteArrayOutput.toByteArray()); |
840 | final ObjectInputStream in = new ObjectInputStream(byteArrayInput); |
841 | final Serializable copy = ((Serializable) in.readObject()); |
842 | in.close(); |
843 | return copy; |
844 | } catch (SecurityException e) { |
845 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
846 | } catch (ClassNotFoundException e) { |
847 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
848 | } catch (InvalidClassException e) { |
849 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
850 | } catch (NotSerializableException e) { |
851 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
852 | } catch (StreamCorruptedException e) { |
853 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
854 | } catch (OptionalDataException e) { |
855 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
856 | } catch (IOException e) { |
857 | throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e)); |
858 | } |
859 | } |
860 | return null; |
861 | } |
862 | |
863 | /** |
864 | * Creates and returns a deep copy of this object. |
865 | * |
866 | * |
867 | * @return |
868 | * A deep copy of this object. |
869 | */ |
870 | @Override |
871 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:31:25+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
872 | public Instance clone() { |
873 | { |
874 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
875 | final Instance clone = ((Instance) super.clone()); |
876 | // CClassInfo: org.jomc.model.Specifications |
877 | clone.specifications = ((this.specifications == null)?null:((this.getSpecifications() == null)?null:this.getSpecifications().clone())); |
878 | // CClassInfo: org.jomc.model.Dependencies |
879 | clone.dependencies = ((this.dependencies == null)?null:((this.getDependencies() == null)?null:this.getDependencies().clone())); |
880 | // CClassInfo: org.jomc.model.Properties |
881 | clone.properties = ((this.properties == null)?null:((this.getProperties() == null)?null:this.getProperties().clone())); |
882 | // CClassInfo: org.jomc.model.Messages |
883 | clone.messages = ((this.messages == null)?null:((this.getMessages() == null)?null:this.getMessages().clone())); |
884 | // 'Any' collection. |
885 | if (this.any!= null) { |
886 | clone.any = null; |
887 | copyAny(this.getAny(), clone.getAny()); |
888 | } |
889 | // CBuiltinLeafInfo: java.lang.String |
890 | clone.identifier = ((this.identifier == null)?null:this.getIdentifier()); |
891 | // CBuiltinLeafInfo: java.lang.String |
892 | clone.name = ((this.name == null)?null:this.getName()); |
893 | // CBuiltinLeafInfo: java.lang.String |
894 | clone.clazz = ((this.clazz == null)?null:this.getClazz()); |
895 | // CBuiltinLeafInfo: java.lang.Boolean |
896 | clone.stateless = ((this.stateless == null)?null:this.isStateless()); |
897 | return clone; |
898 | } |
899 | } |
900 | |
901 | /** |
902 | * Empty {@code Class} array. |
903 | * @since 1.2 |
904 | */ |
905 | @javax.xml.bind.annotation.XmlTransient |
906 | private static final Class<?>[] NO_CLASSES = |
907 | { |
908 | }; |
909 | |
910 | /** Maps dependency names to dependency objects. */ |
911 | @javax.xml.bind.annotation.XmlTransient private java.util.Map<String, Object> dependencyObjects; |
912 | |
913 | /** |
914 | * Maps message names and locales to message format objects. |
915 | * @since 1.2 |
916 | */ |
917 | @javax.xml.bind.annotation.XmlTransient private java.util.Map<String, java.util.Map<java.util.Locale, java.text.MessageFormat>> messageObjects; |
918 | |
919 | /** Maps property names to property objects. */ |
920 | @javax.xml.bind.annotation.XmlTransient private java.util.Map<String, Object> propertyObjects; |
921 | |
922 | /** |
923 | * Gets a mapping of dependency names to objects bound to the instance. |
924 | * <p>This method returns a reference to the live map, not a snapshot. Any modification you make to the returned map |
925 | * will be present inside the object.</p> |
926 | * |
927 | * @return A mapping of dependency names to objects bound to the instance. |
928 | */ |
929 | public java.util.Map<String, Object> getDependencyObjects() |
930 | { |
931 | if ( this.dependencyObjects == null ) |
932 | { |
933 | this.dependencyObjects = new java.util.HashMap<String, Object>(); |
934 | } |
935 | |
936 | return this.dependencyObjects; |
937 | } |
938 | |
939 | /** |
940 | * Gets a mapping of message names to a mapping of locales to message format objects bound to the instance. |
941 | * <p>This method returns a reference to the live map, not a snapshot. Any modification you make to the returned map |
942 | * will be present inside the object.</p> |
943 | * |
944 | * @return A mapping of message names to a mapping of locales to message format objects bound to the instance. |
945 | * |
946 | * @since 1.2 |
947 | */ |
948 | public java.util.Map<String, java.util.Map<java.util.Locale, java.text.MessageFormat>> getMessageObjects() |
949 | { |
950 | if ( this.messageObjects == null ) |
951 | { |
952 | this.messageObjects = |
953 | new java.util.HashMap<String, java.util.Map<java.util.Locale, java.text.MessageFormat>>(); |
954 | |
955 | } |
956 | |
957 | return this.messageObjects; |
958 | } |
959 | |
960 | /** |
961 | * Gets a mapping of property names to objects bound to the instance. |
962 | * <p>This method returns a reference to the live map, not a snapshot. Any modification you make to the returned map |
963 | * will be present inside the object.</p> |
964 | * |
965 | * @return A mapping of property names to objects bound to the instance. |
966 | */ |
967 | public java.util.Map<String, Object> getPropertyObjects() |
968 | { |
969 | if ( this.propertyObjects == null ) |
970 | { |
971 | this.propertyObjects = new java.util.HashMap<String, Object>(); |
972 | } |
973 | |
974 | return this.propertyObjects; |
975 | } |
976 | |
977 | /** |
978 | * Gets the Java class of the type referenced by the instance for a given class loader. |
979 | * |
980 | * @param classLoader The class loader to get the Java class from or {@code null}, to get the Java class from the |
981 | * platform's bootstrap class loader. |
982 | * |
983 | * @return The Java class of the type referenced by the instance or {@code null}, if the instance does not reference |
984 | * a type. |
985 | * |
986 | * @throws ClassNotFoundException if the Java class is not found. |
987 | * @throws ModelObjectException if compiling the name of the referenced type to a {@code JavaTypeName} fails. |
988 | * |
989 | * @see #getClazz() |
990 | * @see #getJavaTypeName() |
991 | * |
992 | * @since 1.2 |
993 | */ |
994 | public Class<?> getJavaClass( final ClassLoader classLoader ) |
995 | throws ClassNotFoundException, ModelObjectException |
996 | { |
997 | Class<?> javaClass = null; |
998 | final JavaTypeName javaTypeName = this.getJavaTypeName(); |
999 | |
1000 | if ( javaTypeName != null ) |
1001 | { |
1002 | javaClass = javaTypeName.getClass( classLoader, false ); |
1003 | } |
1004 | |
1005 | return javaClass; |
1006 | } |
1007 | |
1008 | /** |
1009 | * Gets the Java classes of all types referenced by the specifications of the instance for a given class loader. |
1010 | * |
1011 | * @param classLoader The class loader to get the Java classes from or {@code null}, to get the Java classes from |
1012 | * the platform's bootstrap class loader. |
1013 | * |
1014 | * @return The Java classes of all types referenced by the specifications of the instance. |
1015 | * |
1016 | * @throws ClassNotFoundException if a Java class is not found. |
1017 | * @throws ModelObjectException if parsing a name of a referenced type to a {@code JavaTypeName} fails. |
1018 | * |
1019 | * @see #getSpecifications() |
1020 | * @see Specification#getClazz() |
1021 | * @see Specification#getJavaClass(java.lang.ClassLoader) |
1022 | * |
1023 | * @since 1.2 |
1024 | */ |
1025 | public Class<?>[] getJavaClasses( final ClassLoader classLoader ) |
1026 | throws ClassNotFoundException, ModelObjectException |
1027 | { |
1028 | final java.util.Set<Class<?>> classes = new java.util.HashSet<Class<?>>(); |
1029 | |
1030 | if ( this.getSpecifications() != null ) |
1031 | { |
1032 | for ( int i = 0, s0 = this.getSpecifications().getSpecification().size(); i < s0; i++ ) |
1033 | { |
1034 | final Specification s = this.getSpecifications().getSpecification().get( i ); |
1035 | final JavaTypeName javaTypeName = s.getJavaTypeName(); |
1036 | |
1037 | if ( javaTypeName != null ) |
1038 | { |
1039 | classes.add( javaTypeName.getClass( classLoader, false ) ); |
1040 | } |
1041 | } |
1042 | } |
1043 | |
1044 | return classes.toArray( new Class<?>[ classes.size() ] ); |
1045 | } |
1046 | |
1047 | /** |
1048 | * Gets the Java constructor to use for creating objects of the instance. |
1049 | * |
1050 | * @param classLoader The class loader to get the Java class from or {@code null}, to get the Java class from the |
1051 | * platform's bootstrap class loader. |
1052 | * |
1053 | * @return The public default Java constructor of the Java class of the instance or {@code null}, if the instance |
1054 | * does not reference a type, or if the class is not accessible or abstract or does not declare such a constructor. |
1055 | * |
1056 | * @throws ClassNotFoundException if the Java class is not found. |
1057 | * @throws ModelObjectException if compiling the name of the type referenced by the instance to a |
1058 | * {@code JavaTypeName} fails. |
1059 | * |
1060 | * @see #getJavaClass(java.lang.ClassLoader) |
1061 | * |
1062 | * @since 1.2 |
1063 | */ |
1064 | public java.lang.reflect.Constructor<?> getJavaConstructor( final ClassLoader classLoader ) |
1065 | throws ClassNotFoundException, ModelObjectException |
1066 | { |
1067 | java.lang.reflect.Constructor<?> javaConstructor = null; |
1068 | final JavaTypeName javaTypeName = this.getJavaTypeName(); |
1069 | |
1070 | if ( javaTypeName != null ) |
1071 | { |
1072 | final Class<?> javaClass = javaTypeName.getClass( classLoader, false ); |
1073 | |
1074 | if ( java.lang.reflect.Modifier.isPublic( javaClass.getModifiers() ) |
1075 | && !java.lang.reflect.Modifier.isAbstract( javaClass.getModifiers() ) ) |
1076 | { |
1077 | try |
1078 | { |
1079 | javaConstructor = javaClass.getConstructor( NO_CLASSES ); |
1080 | } |
1081 | catch ( final NoSuchMethodException e ) |
1082 | { |
1083 | javaConstructor = null; |
1084 | } |
1085 | } |
1086 | } |
1087 | |
1088 | return javaConstructor; |
1089 | } |
1090 | |
1091 | /** |
1092 | * Gets the name of the Java method to use for creating objects of the instance. |
1093 | * |
1094 | * @return The name of the Java method to use for creating objects of the instance or {@code null}, if no such |
1095 | * method name is supported. |
1096 | * |
1097 | * @throws ModelObjectException if compiling the name of the instance to a {@code JavaIdentifier} fails. |
1098 | * |
1099 | * @see #getName() |
1100 | * |
1101 | * @since 1.2 |
1102 | */ |
1103 | public String getJavaFactoryMethodName() throws ModelObjectException |
1104 | { |
1105 | try |
1106 | { |
1107 | String javaFactoryMethodName = null; |
1108 | |
1109 | if ( this.getName() != null ) |
1110 | { |
1111 | javaFactoryMethodName = |
1112 | JavaIdentifier.parse( "get" + JavaIdentifier.normalize( |
1113 | this.getName(), JavaIdentifier.NormalizationMode.CAMEL_CASE ) ).toString(); |
1114 | |
1115 | } |
1116 | |
1117 | return javaFactoryMethodName; |
1118 | } |
1119 | catch ( final java.text.ParseException e ) |
1120 | { |
1121 | throw new ModelObjectException( getMessage( "javaIdentifierParseException", this.getName(), |
1122 | getMessage( e ) ), e ); |
1123 | |
1124 | } |
1125 | } |
1126 | |
1127 | /** |
1128 | * Gets the Java method to use for creating objects of the instance. |
1129 | * |
1130 | * @param classLoader The class loader to get the Java class from or {@code null}, to get the Java class from the |
1131 | * platform's bootstrap class loader. |
1132 | * |
1133 | * @return The public Java method of the Java class of the instance to use for creating objects of the instance or |
1134 | * {@code null}, if the instance does not reference a type or no such method is supported. |
1135 | * |
1136 | * @throws ClassNotFoundException if the Java class is not found. |
1137 | * @throws ModelObjectException if compiling the name of the type referenced by the instance to a |
1138 | * {@code JavaTypeName} or if compiling the name of the instance to a {@code JavaIdentifier} fails. |
1139 | * |
1140 | * @see #getJavaClass(java.lang.ClassLoader) |
1141 | * @see #getJavaFactoryMethodName() |
1142 | * |
1143 | * @since 1.2 |
1144 | */ |
1145 | public java.lang.reflect.Method getJavaFactoryMethod( final ClassLoader classLoader ) |
1146 | throws ClassNotFoundException, ModelObjectException |
1147 | { |
1148 | final JavaTypeName javaTypeName = this.getJavaTypeName(); |
1149 | java.lang.reflect.Method factoryMethod = null; |
1150 | |
1151 | if ( javaTypeName != null ) |
1152 | { |
1153 | final Class<?> javaClass = javaTypeName.getClass( classLoader, false ); |
1154 | final String methodName = this.getJavaFactoryMethodName(); |
1155 | |
1156 | if ( methodName != null ) |
1157 | { |
1158 | try |
1159 | { |
1160 | factoryMethod = javaClass.getMethod( methodName, (Class[]) null ); |
1161 | } |
1162 | catch ( final NoSuchMethodException e ) |
1163 | { |
1164 | factoryMethod = null; |
1165 | } |
1166 | } |
1167 | |
1168 | if ( factoryMethod == null ) |
1169 | { |
1170 | try |
1171 | { |
1172 | factoryMethod = javaClass.getMethod( "getObject", (Class[]) null ); |
1173 | } |
1174 | catch ( final NoSuchMethodException e ) |
1175 | { |
1176 | factoryMethod = null; |
1177 | } |
1178 | } |
1179 | } |
1180 | |
1181 | return factoryMethod; |
1182 | } |
1183 | |
1184 | /** |
1185 | * Gets a flag indicating the Java class of the instance is assignable to all Java classes of all specifications of |
1186 | * the instance. |
1187 | * |
1188 | * @param classLoader The class loader to get the Java classes from or {@code null}, to get the Java classes from |
1189 | * the platform's bootstrap class loader. |
1190 | * |
1191 | * @return {@code true}, if the Java class of the instance is assignable to all Java classes of all specifications |
1192 | * of the instance; {@code false}, if the Java class of the instance is not assignable to all Java classes of all |
1193 | * specifications of the instance. |
1194 | * |
1195 | * @throws ClassNotFoundException if a Java class is not found. |
1196 | * @throws ModelObjectException if compiling a name of a referenced type to a {@code JavaTypeName} fails. |
1197 | * |
1198 | * @see #getJavaClass(java.lang.ClassLoader) |
1199 | * @see #getJavaClasses(java.lang.ClassLoader) |
1200 | * @see Class#isAssignableFrom(java.lang.Class) |
1201 | * |
1202 | * @since 1.2 |
1203 | */ |
1204 | public boolean isJavaClassAssignable( final ClassLoader classLoader ) |
1205 | throws ClassNotFoundException, ModelObjectException |
1206 | { |
1207 | final JavaTypeName javaTypeName = this.getJavaTypeName(); |
1208 | boolean assignable = javaTypeName != null; |
1209 | |
1210 | if ( assignable ) |
1211 | { |
1212 | final Class<?> javaClass = javaTypeName.getClass( classLoader, false ); |
1213 | final Class<?>[] javaClasses = this.getJavaClasses( classLoader ); |
1214 | |
1215 | for ( int i = javaClasses.length - 1; i >= 0; i-- ) |
1216 | { |
1217 | if ( !javaClasses[i].isAssignableFrom( javaClass ) ) |
1218 | { |
1219 | assignable = false; |
1220 | break; |
1221 | } |
1222 | } |
1223 | } |
1224 | |
1225 | return assignable; |
1226 | } |
1227 | |
1228 | /** |
1229 | * Gets the Java proxy class for a given class loader. |
1230 | * |
1231 | * @param classLoader The class loader to get the Java proxy class from or {@code null}, to get the Java proxy class |
1232 | * from the platform's bootstrap class loader. |
1233 | * |
1234 | * @return The Java proxy class for {@code classLoader} or {@code null}, if the instance does not support a Java |
1235 | * proxy class. |
1236 | * |
1237 | * @throws ClassNotFoundException if a Java class is not found. |
1238 | * @throws ModelObjectException if compiling a name of a referenced type to a {@code JavaTypeName} fails. |
1239 | * |
1240 | * @see #getJavaClasses(java.lang.ClassLoader) |
1241 | * @see Class#isInterface() |
1242 | * |
1243 | * @since 1.2 |
1244 | */ |
1245 | public Class<?> getJavaProxyClass( final ClassLoader classLoader ) |
1246 | throws ClassNotFoundException, ModelObjectException |
1247 | { |
1248 | final Class<?>[] javaClasses = this.getJavaClasses( classLoader ); |
1249 | boolean canProxy = javaClasses.length > 0; |
1250 | |
1251 | if ( canProxy ) |
1252 | { |
1253 | for ( int i = javaClasses.length - 1; i >= 0; i-- ) |
1254 | { |
1255 | if ( !javaClasses[i].isInterface() ) |
1256 | { |
1257 | canProxy = false; |
1258 | break; |
1259 | } |
1260 | } |
1261 | } |
1262 | |
1263 | return canProxy ? java.lang.reflect.Proxy.getProxyClass( classLoader, javaClasses ) : null; |
1264 | } |
1265 | |
1266 | /** |
1267 | * Gets the Java type name of the type referenced by the instance. |
1268 | * |
1269 | * @return The Java type name of the type referenced by the instance or {@code null}, if the instance does not |
1270 | * reference a type. |
1271 | * |
1272 | * @throws ModelObjectException if compiling the name of the referenced type to a {@code JavaTypeName} fails. |
1273 | * |
1274 | * @see #getClazz() |
1275 | * |
1276 | * @since 1.4 |
1277 | */ |
1278 | public JavaTypeName getJavaTypeName() throws ModelObjectException |
1279 | { |
1280 | try |
1281 | { |
1282 | JavaTypeName javaTypeName = null; |
1283 | |
1284 | if ( this.getClazz() != null ) |
1285 | { |
1286 | javaTypeName = JavaTypeName.parse( this.getClazz() ); |
1287 | } |
1288 | |
1289 | return javaTypeName; |
1290 | } |
1291 | catch ( final java.text.ParseException e ) |
1292 | { |
1293 | throw new ModelObjectException( getMessage( "javaTypeNameParseException", this.getClazz(), |
1294 | getMessage( e ) ), e ); |
1295 | |
1296 | } |
1297 | } |
1298 | |
1299 | /** |
1300 | * Gets a single {@code JAXBElement} matching a namespace URI and local part from the {@code any} property of the |
1301 | * instance. |
1302 | * |
1303 | * @param namespaceURI The namespace URI of the {@code JAXBElement} to return. |
1304 | * @param localPart The local part of the {@code JAXBElement} to return. |
1305 | * |
1306 | * @return The {@code JAXBElement} matching {@code namespaceURI} and {@code localPart} from the {@code any} property |
1307 | * of the instance or {@code null}, if no such element is found. |
1308 | * |
1309 | * @throws NullPointerException if {@code namespaceURI} or {@code localPart} is {@code null}. |
1310 | * @throws IllegalStateException if the {@code any} property contains more than one matching element. |
1311 | * |
1312 | * @see #getAnyElement(java.util.List, java.lang.String, java.lang.String) |
1313 | * |
1314 | * @deprecated As of JOMC 1.1, please use method {@link #getAnyElement(java.lang.String, java.lang.String, java.lang.Class)}. |
1315 | * This method will be removed in version 2.0. |
1316 | */ |
1317 | @Deprecated |
1318 | public javax.xml.bind.JAXBElement getAnyElement( final String namespaceURI, final String localPart ) |
1319 | { |
1320 | return this.getAnyElement( this.getAny(), namespaceURI, localPart ); |
1321 | } |
1322 | |
1323 | /** |
1324 | * Gets a list containing all {@code JAXBElement}s matching a namespace URI and local part from the {@code any} |
1325 | * property of the instance. |
1326 | * |
1327 | * @param namespaceURI The namespace URI of the {@code JAXBElement}s to return. |
1328 | * @param localPart The local part of the {@code JAXBElement}s to return. |
1329 | * |
1330 | * @return An unmodifiable list of all {@code JAXBElement}s matching {@code namespaceURI} and {@code localPart} from |
1331 | * the {@code any} property of the instance - an empty list if no such elements are found. |
1332 | * |
1333 | * @throws NullPointerException if {@code namespaceURI} or {@code localPart} is {@code null}. |
1334 | * |
1335 | * @see #getAnyElements(java.util.List, java.lang.String, java.lang.String) |
1336 | * |
1337 | * @deprecated As of JOMC 1.1, please use method {@link #getAnyElements(java.lang.String, java.lang.String, java.lang.Class)}. |
1338 | * This method will be removed in version 2.0. |
1339 | */ |
1340 | @Deprecated |
1341 | public java.util.List<javax.xml.bind.JAXBElement> getAnyElements( final String namespaceURI, |
1342 | final String localPart ) |
1343 | { |
1344 | return this.getAnyElements( this.getAny(), namespaceURI, localPart ); |
1345 | } |
1346 | |
1347 | /** |
1348 | * Gets a single {@code JAXBElement} matching a namespace URI and local part from the {@code any} property of the |
1349 | * instance. |
1350 | * |
1351 | * @param namespaceURI The namespace URI of the {@code JAXBElement} to return. |
1352 | * @param localPart The local part of the {@code JAXBElement} to return. |
1353 | * @param type The class of the type the element is bound to. |
1354 | * @param <T> The type the element is bound to. |
1355 | * |
1356 | * @return The {@code JAXBElement} matching {@code namespaceURI} and {@code localPart} from the {@code any} property |
1357 | * of the instance or {@code null}, if no such element is found. |
1358 | * |
1359 | * @throws NullPointerException if {@code namespaceURI}, {@code localPart} or {@code type} is {@code null}. |
1360 | * @throws IllegalStateException if the {@code any} property contains more than one matching element. |
1361 | * |
1362 | * @see #getAnyElement(java.util.List, java.lang.String, java.lang.String, java.lang.Class) |
1363 | * |
1364 | * @since 1.1 |
1365 | */ |
1366 | public <T> javax.xml.bind.JAXBElement<T> getAnyElement( final String namespaceURI, final String localPart, |
1367 | final Class<T> type ) |
1368 | { |
1369 | return this.getAnyElement( this.getAny(), namespaceURI, localPart, type ); |
1370 | } |
1371 | |
1372 | /** |
1373 | * Gets a list containing all {@code JAXBElement}s matching a namespace URI and local part from the {@code any} |
1374 | * property of the instance. |
1375 | * |
1376 | * @param namespaceURI The namespace URI of the {@code JAXBElement}s to return. |
1377 | * @param localPart The local part of the {@code JAXBElement}s to return. |
1378 | * @param type The class of the type the elements are bound to. |
1379 | * @param <T> The type the elements are bound to. |
1380 | * |
1381 | * @return An unmodifiable list of all {@code JAXBElement}s matching {@code namespaceURI} and {@code localPart} from |
1382 | * the {@code any} property of the instance - an empty list if no such elements are found. |
1383 | * |
1384 | * @throws NullPointerException if {@code namespaceURI}, {@code localPart} or {@code type} is {@code null}. |
1385 | * |
1386 | * @see #getAnyElements(java.util.List, java.lang.String, java.lang.String, java.lang.Class) |
1387 | * |
1388 | * @since 1.1 |
1389 | */ |
1390 | public <T> java.util.List<javax.xml.bind.JAXBElement<T>> getAnyElements( final String namespaceURI, |
1391 | final String localPart, |
1392 | final Class<T> type ) |
1393 | { |
1394 | return this.getAnyElements( this.getAny(), namespaceURI, localPart, type ); |
1395 | } |
1396 | |
1397 | /** |
1398 | * Gets a single object matching a given class from the {@code any} property of the instance. |
1399 | * |
1400 | * @param clazz The class to return an instance of. |
1401 | * @param <T> The type of the object to return. |
1402 | * |
1403 | * @return The instance of {@code clazz} from the {@code any} property of the instance or {@code null} if no such |
1404 | * instance is found. |
1405 | * |
1406 | * @throws NullPointerException if {@code clazz} is {@code null}. |
1407 | * @throws IllegalStateException if the {@code any} property contains more than one matching object. |
1408 | * |
1409 | * @see #getAnyObject(java.util.List, java.lang.Class) |
1410 | */ |
1411 | public <T> T getAnyObject( final Class<T> clazz ) |
1412 | { |
1413 | return this.getAnyObject( this.getAny(), clazz ); |
1414 | } |
1415 | |
1416 | /** |
1417 | * Gets a list containing all objects matching a given class from the {@code any} property of the instance. |
1418 | * |
1419 | * @param clazz The class to return all instances of. |
1420 | * @param <T> The type of the objects to return. |
1421 | * |
1422 | * @return An unmodifiable list of all instances of {@code clazz} from the {@code any} property of the instance - |
1423 | * an empty list if no such objects are found. |
1424 | * |
1425 | * @throws NullPointerException if {@code clazz} is {@code null}. |
1426 | * |
1427 | * @see #getAnyObjects(java.util.List, java.lang.Class) |
1428 | */ |
1429 | public <T> java.util.List<T> getAnyObjects( final Class<T> clazz ) |
1430 | { |
1431 | return this.getAnyObjects( this.getAny(), clazz ); |
1432 | } |
1433 | |
1434 | private static String getMessage( final Throwable t ) |
1435 | { |
1436 | return t != null |
1437 | ? t.getMessage() != null && t.getMessage().trim().length() > 0 |
1438 | ? t.getMessage() |
1439 | : getMessage( t.getCause() ) |
1440 | : null; |
1441 | |
1442 | } |
1443 | |
1444 | private static String getMessage( final String key, final Object... arguments ) |
1445 | { |
1446 | return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( |
1447 | Instance.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ). |
1448 | getString( key ), arguments ); |
1449 | |
1450 | } |
1451 | |
1452 | } |