001//
002// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2 
003// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
004// Any modifications to this file will be lost upon recompilation of the source schema. 
005// Generated on: 2013.01.03 at 05:01:35 AM CET 
006//
007
008
009package org.jomc.model;
010
011import java.io.ByteArrayInputStream;
012import java.io.ByteArrayOutputStream;
013import java.io.File;
014import java.io.IOException;
015import java.io.InvalidClassException;
016import java.io.NotSerializableException;
017import java.io.ObjectInputStream;
018import java.io.ObjectOutputStream;
019import java.io.OptionalDataException;
020import java.io.Serializable;
021import java.io.StreamCorruptedException;
022import java.lang.reflect.Array;
023import java.lang.reflect.InvocationTargetException;
024import java.math.BigDecimal;
025import java.math.BigInteger;
026import java.net.MalformedURLException;
027import java.net.URI;
028import java.net.URISyntaxException;
029import java.net.URL;
030import java.util.Calendar;
031import java.util.Currency;
032import java.util.Date;
033import java.util.Locale;
034import java.util.TimeZone;
035import java.util.UUID;
036import javax.activation.MimeType;
037import javax.activation.MimeTypeParseException;
038import javax.annotation.Generated;
039import javax.xml.bind.JAXBElement;
040import javax.xml.bind.annotation.XmlAccessType;
041import javax.xml.bind.annotation.XmlAccessorType;
042import javax.xml.bind.annotation.XmlAnyElement;
043import javax.xml.bind.annotation.XmlAttribute;
044import javax.xml.bind.annotation.XmlType;
045import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
046import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
047import javax.xml.datatype.Duration;
048import javax.xml.datatype.XMLGregorianCalendar;
049import javax.xml.namespace.QName;
050import org.w3c.dom.Element;
051
052
053/**
054 * 
055 * Model of a property.
056 * 
057 * The 'Property' type defines attributes 'name', 'type', 'value', 'final' and 'override'. Attribute 'name' holds the name
058 * uniquely identifying the property in a set of properties. Attribute 'type' holds an identifier of the type of the
059 * property. Attribute 'value' holds the properties value.
060 *       
061 * 
062 * <p>Java class for Property complex type.
063 * 
064 * <p>The following schema fragment specifies the expected content contained within this class.
065 * 
066 * <pre>
067 * &lt;complexType name="Property">
068 *   &lt;complexContent>
069 *     &lt;extension base="{http://jomc.org/model}ModelObject">
070 *       &lt;sequence>
071 *         &lt;any processContents='lax' namespace='##other' minOccurs="0"/>
072 *       &lt;/sequence>
073 *       &lt;attribute name="name" use="required" type="{http://jomc.org/model}Identifier" />
074 *       &lt;attribute name="type" type="{http://jomc.org/model}Identifier" />
075 *       &lt;attribute name="value" type="{http://jomc.org/model}String" />
076 *       &lt;attribute name="final" type="{http://jomc.org/model}Flag" default="false" />
077 *       &lt;attribute name="override" type="{http://jomc.org/model}Flag" default="false" />
078 *     &lt;/extension>
079 *   &lt;/complexContent>
080 * &lt;/complexType>
081 * </pre>
082 * 
083 * 
084 */
085@XmlAccessorType(XmlAccessType.FIELD)
086@XmlType(name = "Property", namespace = "http://jomc.org/model", propOrder = {
087    "any"
088})
089@Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
090public class Property
091    extends ModelObject
092    implements Cloneable, Inheritable
093{
094
095    @XmlAnyElement(lax = true)
096    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
097    protected Object any;
098    @XmlAttribute(name = "name", required = true)
099    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
100    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
101    protected String name;
102    @XmlAttribute(name = "type")
103    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
104    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
105    protected String type;
106    @XmlAttribute(name = "value")
107    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
108    protected String value;
109    @XmlAttribute(name = "final")
110    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
111    protected Boolean _final;
112    @XmlAttribute(name = "override")
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 Boolean override;
115
116    /**
117     * Creates a new {@code Property} instance.
118     * 
119     */
120    public Property() {
121        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
122        super();
123    }
124
125    /**
126     * Creates a new {@code Property} instance by deeply copying a given {@code Property} instance.
127     * 
128     * 
129     * @param o
130     *     The instance to copy.
131     * @throws NullPointerException
132     *     if {@code o} is {@code null}.
133     */
134    public Property(final Property o) {
135        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
136        super(o);
137        if (o == null) {
138            throw new NullPointerException("Cannot create a copy of 'Property' from 'null'.");
139        }
140        // 'Any' property.
141        this.any = ((o.any == null)?null:copyOfAny(o.getAny()));
142        // CBuiltinLeafInfo: java.lang.String
143        this.name = ((o.name == null)?null:o.getName());
144        // CBuiltinLeafInfo: java.lang.String
145        this.type = ((o.type == null)?null:o.getType());
146        // CBuiltinLeafInfo: java.lang.String
147        this.value = ((o.value == null)?null:o.getValue());
148        // CBuiltinLeafInfo: java.lang.Boolean
149        this._final = ((o._final == null)?null:o.isFinal());
150        // CBuiltinLeafInfo: java.lang.Boolean
151        this.override = ((o.override == null)?null:o.isOverride());
152    }
153
154    /**
155     * Object value of this property or {@code null}.
156     * 
157     * @return
158     *     possible object is
159     *     {@link Object }
160     *     {@link Element }
161     *     
162     */
163    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
164    public Object getAny() {
165        return any;
166    }
167
168    /**
169     * Sets the value of the any property.
170     * 
171     * @param value
172     *     allowed object is
173     *     {@link Object }
174     *     {@link Element }
175     *     
176     */
177    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
178    public void setAny(Object value) {
179        this.any = value;
180    }
181
182    /**
183     * Name of this property.
184     * 
185     * @return
186     *     possible object is
187     *     {@link String }
188     *     
189     */
190    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
191    public String getName() {
192        return name;
193    }
194
195    /**
196     * Sets the value of the name property.
197     * 
198     * @param value
199     *     allowed object is
200     *     {@link String }
201     *     
202     */
203    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
204    public void setName(String value) {
205        this.name = value;
206    }
207
208    /**
209     * Type of this property or {@code null}.
210     * 
211     * @return
212     *     possible object is
213     *     {@link String }
214     *     
215     */
216    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
217    public String getType() {
218        return type;
219    }
220
221    /**
222     * Sets the value of the type property.
223     * 
224     * @param value
225     *     allowed object is
226     *     {@link String }
227     *     
228     */
229    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
230    public void setType(String value) {
231        this.type = value;
232    }
233
234    /**
235     * String value of this property or {@code null}.
236     * 
237     * @return
238     *     possible object is
239     *     {@link String }
240     *     
241     */
242    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
243    public String getValue() {
244        return value;
245    }
246
247    /**
248     * Sets the value of the value property.
249     * 
250     * @param value
251     *     allowed object is
252     *     {@link String }
253     *     
254     */
255    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
256    public void setValue(String value) {
257        this.value = value;
258    }
259
260    /**
261     * {@code true}, if this property is the final node in an inheritance hierarchy.
262     * 
263     * @return
264     *     possible object is
265     *     {@link Boolean }
266     *     
267     */
268    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
269    public boolean isFinal() {
270        if (_final == null) {
271            return false;
272        } else {
273            return _final;
274        }
275    }
276
277    /**
278     * Sets the value of the final property.
279     * 
280     * @param value
281     *     allowed object is
282     *     {@link Boolean }
283     *     
284     */
285    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
286    public void setFinal(Boolean value) {
287        this._final = value;
288    }
289
290    /**
291     * {@code true}, if this property is intended to override a super property.
292     * 
293     * @return
294     *     possible object is
295     *     {@link Boolean }
296     *     
297     */
298    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
299    public boolean isOverride() {
300        if (override == null) {
301            return false;
302        } else {
303            return override;
304        }
305    }
306
307    /**
308     * Sets the value of the override property.
309     * 
310     * @param value
311     *     allowed object is
312     *     {@link Boolean }
313     *     
314     */
315    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
316    public void setOverride(Boolean value) {
317        this.override = value;
318    }
319
320    /**
321     * Creates and returns a deep copy of property {@code Any}.
322     * 
323     * @param source
324     *     The source to copy from or {@code null}.
325     * @return
326     *     A deep copy of {@code source} or {@code null} if {@code source} is {@code null}.
327     */
328    @SuppressWarnings("unchecked")
329    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
330    private static Object copyOfAny(final Object source) {
331        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
332        if (source!= null) {
333            if (source instanceof Element) {
334                // CWildcardTypeInfo: org.w3c.dom.Element
335                return ((Element)((Element) source).cloneNode(true));
336            }
337            if (source instanceof Object) {
338                // CBuiltinLeafInfo: java.lang.Object
339                return copyOf(((Object) source));
340            }
341            // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
342            throw new AssertionError((("Unexpected instance '"+ source)+"' for property 'Any' of class 'org.jomc.model.Property'."));
343        }
344        return null;
345    }
346
347    /**
348     * Creates and returns a deep copy of a given object.
349     * 
350     * @param o
351     *     The instance to copy or {@code null}.
352     * @return
353     *     A deep copy of {@code o} or {@code null} if {@code o} is {@code null}.
354     */
355    @SuppressWarnings("unchecked")
356    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
357    private static Object copyOf(final Object o) {
358        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
359        try {
360            if (o!= null) {
361                if (o.getClass().isPrimitive()) {
362                    return o;
363                }
364                if (o.getClass().isArray()) {
365                    return copyOfArray(o);
366                }
367                // Immutable types.
368                if (o instanceof Boolean) {
369                    return o;
370                }
371                if (o instanceof Byte) {
372                    return o;
373                }
374                if (o instanceof Character) {
375                    return o;
376                }
377                if (o instanceof Double) {
378                    return o;
379                }
380                if (o instanceof Enum) {
381                    return o;
382                }
383                if (o instanceof Float) {
384                    return o;
385                }
386                if (o instanceof Integer) {
387                    return o;
388                }
389                if (o instanceof Long) {
390                    return o;
391                }
392                if (o instanceof Short) {
393                    return o;
394                }
395                if (o instanceof String) {
396                    return o;
397                }
398                if (o instanceof BigDecimal) {
399                    return o;
400                }
401                if (o instanceof BigInteger) {
402                    return o;
403                }
404                if (o instanceof UUID) {
405                    return o;
406                }
407                if (o instanceof QName) {
408                    return o;
409                }
410                if (o instanceof Duration) {
411                    return o;
412                }
413                if (o instanceof Currency) {
414                    return o;
415                }
416                // String based types.
417                if (o instanceof File) {
418                    return new File(o.toString());
419                }
420                if (o instanceof URI) {
421                    return new URI(o.toString());
422                }
423                if (o instanceof URL) {
424                    return new URL(o.toString());
425                }
426                if (o instanceof MimeType) {
427                    return new MimeType(o.toString());
428                }
429                // Cloneable types.
430                if (o instanceof XMLGregorianCalendar) {
431                    return ((XMLGregorianCalendar) o).clone();
432                }
433                if (o instanceof Date) {
434                    return ((Date) o).clone();
435                }
436                if (o instanceof Calendar) {
437                    return ((Calendar) o).clone();
438                }
439                if (o instanceof TimeZone) {
440                    return ((TimeZone) o).clone();
441                }
442                if (o instanceof Locale) {
443                    return ((Locale) o).clone();
444                }
445                if (o instanceof Element) {
446                    return ((Element)((Element) o).cloneNode(true));
447                }
448                if (o instanceof JAXBElement) {
449                    return copyOf(((JAXBElement) o));
450                }
451                try {
452                    return o.getClass().getMethod("clone", ((Class[]) null)).invoke(o, ((Object[]) null));
453                } catch (NoSuchMethodException e) {
454                    if (o instanceof Serializable) {
455                        return copyOf(((Serializable) o));
456                    }
457                    // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
458                    throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
459                } catch (IllegalAccessException e) {
460                    // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
461                    throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
462                } catch (InvocationTargetException e) {
463                    // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
464                    throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
465                } catch (SecurityException e) {
466                    // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
467                    throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
468                } catch (IllegalArgumentException e) {
469                    // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
470                    throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
471                } catch (ExceptionInInitializerError e) {
472                    // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
473                    throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
474                }
475            }
476            return null;
477        } catch (URISyntaxException e) {
478            throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
479        } catch (MimeTypeParseException e) {
480            throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
481        } catch (MalformedURLException e) {
482            throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ o)+"'.")).initCause(e));
483        }
484    }
485
486    /**
487     * Creates and returns a deep copy of a given array.
488     * 
489     * @param array
490     *     The array to copy or {@code null}.
491     * @return
492     *     A deep copy of {@code array} or {@code null} if {@code array} is {@code null}.
493     */
494    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
495    private static Object copyOfArray(final Object array) {
496        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
497        if (array!= null) {
498            if (array.getClass() == boolean[].class) {
499                return copyOf(((boolean[]) array));
500            }
501            if (array.getClass() == byte[].class) {
502                return copyOf(((byte[]) array));
503            }
504            if (array.getClass() == char[].class) {
505                return copyOf(((char[]) array));
506            }
507            if (array.getClass() == double[].class) {
508                return copyOf(((double[]) array));
509            }
510            if (array.getClass() == float[].class) {
511                return copyOf(((float[]) array));
512            }
513            if (array.getClass() == int[].class) {
514                return copyOf(((int[]) array));
515            }
516            if (array.getClass() == long[].class) {
517                return copyOf(((long[]) array));
518            }
519            if (array.getClass() == short[].class) {
520                return copyOf(((short[]) array));
521            }
522            final int len = Array.getLength(array);
523            final Object copy = Array.newInstance(array.getClass().getComponentType(), len);
524            for (int i = (len- 1); (i >= 0); i--) {
525                Array.set(copy, i, copyOf(Array.get(array, i)));
526            }
527            return copy;
528        }
529        return null;
530    }
531
532    /**
533     * Creates and returns a deep copy of a given array.
534     * 
535     * @param array
536     *     The array to copy or {@code null}.
537     * @return
538     *     A deep copy of {@code array} or {@code null} if {@code array} is {@code null}.
539     */
540    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
541    private static boolean[] copyOf(final boolean[] array) {
542        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
543        if (array!= null) {
544            final boolean[] copy = ((boolean[]) Array.newInstance(array.getClass().getComponentType(), array.length));
545            System.arraycopy(array, 0, copy, 0, array.length);
546            return copy;
547        }
548        return null;
549    }
550
551    /**
552     * Creates and returns a deep copy of a given array.
553     * 
554     * @param array
555     *     The array to copy or {@code null}.
556     * @return
557     *     A deep copy of {@code array} or {@code null} if {@code array} is {@code null}.
558     */
559    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
560    private static byte[] copyOf(final byte[] array) {
561        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
562        if (array!= null) {
563            final byte[] copy = ((byte[]) Array.newInstance(array.getClass().getComponentType(), array.length));
564            System.arraycopy(array, 0, copy, 0, array.length);
565            return copy;
566        }
567        return null;
568    }
569
570    /**
571     * Creates and returns a deep copy of a given array.
572     * 
573     * @param array
574     *     The array to copy or {@code null}.
575     * @return
576     *     A deep copy of {@code array} or {@code null} if {@code array} is {@code null}.
577     */
578    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
579    private static char[] copyOf(final char[] array) {
580        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
581        if (array!= null) {
582            final char[] copy = ((char[]) Array.newInstance(array.getClass().getComponentType(), array.length));
583            System.arraycopy(array, 0, copy, 0, array.length);
584            return copy;
585        }
586        return null;
587    }
588
589    /**
590     * Creates and returns a deep copy of a given array.
591     * 
592     * @param array
593     *     The array to copy or {@code null}.
594     * @return
595     *     A deep copy of {@code array} or {@code null} if {@code array} is {@code null}.
596     */
597    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
598    private static double[] copyOf(final double[] array) {
599        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
600        if (array!= null) {
601            final double[] copy = ((double[]) Array.newInstance(array.getClass().getComponentType(), array.length));
602            System.arraycopy(array, 0, copy, 0, array.length);
603            return copy;
604        }
605        return null;
606    }
607
608    /**
609     * Creates and returns a deep copy of a given array.
610     * 
611     * @param array
612     *     The array to copy or {@code null}.
613     * @return
614     *     A deep copy of {@code array} or {@code null} if {@code array} is {@code null}.
615     */
616    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
617    private static float[] copyOf(final float[] array) {
618        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
619        if (array!= null) {
620            final float[] copy = ((float[]) Array.newInstance(array.getClass().getComponentType(), array.length));
621            System.arraycopy(array, 0, copy, 0, array.length);
622            return copy;
623        }
624        return null;
625    }
626
627    /**
628     * Creates and returns a deep copy of a given array.
629     * 
630     * @param array
631     *     The array to copy or {@code null}.
632     * @return
633     *     A deep copy of {@code array} or {@code null} if {@code array} is {@code null}.
634     */
635    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
636    private static int[] copyOf(final int[] array) {
637        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
638        if (array!= null) {
639            final int[] copy = ((int[]) Array.newInstance(array.getClass().getComponentType(), array.length));
640            System.arraycopy(array, 0, copy, 0, array.length);
641            return copy;
642        }
643        return null;
644    }
645
646    /**
647     * Creates and returns a deep copy of a given array.
648     * 
649     * @param array
650     *     The array to copy or {@code null}.
651     * @return
652     *     A deep copy of {@code array} or {@code null} if {@code array} is {@code null}.
653     */
654    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
655    private static long[] copyOf(final long[] array) {
656        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
657        if (array!= null) {
658            final long[] copy = ((long[]) Array.newInstance(array.getClass().getComponentType(), array.length));
659            System.arraycopy(array, 0, copy, 0, array.length);
660            return copy;
661        }
662        return null;
663    }
664
665    /**
666     * Creates and returns a deep copy of a given array.
667     * 
668     * @param array
669     *     The array to copy or {@code null}.
670     * @return
671     *     A deep copy of {@code array} or {@code null} if {@code array} is {@code null}.
672     */
673    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
674    private static short[] copyOf(final short[] array) {
675        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
676        if (array!= null) {
677            final short[] copy = ((short[]) Array.newInstance(array.getClass().getComponentType(), array.length));
678            System.arraycopy(array, 0, copy, 0, array.length);
679            return copy;
680        }
681        return null;
682    }
683
684    /**
685     * Creates and returns a deep copy of a given {@code JAXBElement} instance.
686     * 
687     * @param element
688     *     The instance to copy or {@code null}.
689     * @return
690     *     A deep copy of {@code element} or {@code null} if {@code element} is {@code null}.
691     */
692    @SuppressWarnings("unchecked")
693    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
694    private static JAXBElement copyOf(final JAXBElement element) {
695        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
696        if (element!= null) {
697            final JAXBElement copy = new JAXBElement(element.getName(), element.getDeclaredType(), element.getScope(), element.getValue());
698            copy.setNil(element.isNil());
699            copy.setValue(copyOf(copy.getValue()));
700            return copy;
701        }
702        return null;
703    }
704
705    /**
706     * Creates and returns a deep copy of a given {@code Serializable}.
707     * 
708     * @param serializable
709     *     The instance to copy or {@code null}.
710     * @return
711     *     A deep copy of {@code serializable} or {@code null} if {@code serializable} is {@code null}.
712     */
713    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
714    private static Serializable copyOf(final Serializable serializable) {
715        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
716        if (serializable!= null) {
717            try {
718                final ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
719                final ObjectOutputStream out = new ObjectOutputStream(byteArrayOutput);
720                out.writeObject(serializable);
721                out.close();
722                final ByteArrayInputStream byteArrayInput = new ByteArrayInputStream(byteArrayOutput.toByteArray());
723                final ObjectInputStream in = new ObjectInputStream(byteArrayInput);
724                final Serializable copy = ((Serializable) in.readObject());
725                in.close();
726                return copy;
727            } catch (SecurityException e) {
728                throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
729            } catch (ClassNotFoundException e) {
730                throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
731            } catch (InvalidClassException e) {
732                throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
733            } catch (NotSerializableException e) {
734                throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
735            } catch (StreamCorruptedException e) {
736                throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
737            } catch (OptionalDataException e) {
738                throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
739            } catch (IOException e) {
740                throw((AssertionError) new AssertionError((("Unexpected instance during copying object '"+ serializable)+"'.")).initCause(e));
741            }
742        }
743        return null;
744    }
745
746    /**
747     * Creates and returns a deep copy of this object.
748     * 
749     * 
750     * @return
751     *     A deep copy of this object.
752     */
753    @Override
754    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
755    public Property clone() {
756        {
757            // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
758            final Property clone = ((Property) super.clone());
759            // 'Any' property.
760            clone.any = ((this.any == null)?null:copyOfAny(this.getAny()));
761            // CBuiltinLeafInfo: java.lang.String
762            clone.name = ((this.name == null)?null:this.getName());
763            // CBuiltinLeafInfo: java.lang.String
764            clone.type = ((this.type == null)?null:this.getType());
765            // CBuiltinLeafInfo: java.lang.String
766            clone.value = ((this.value == null)?null:this.getValue());
767            // CBuiltinLeafInfo: java.lang.Boolean
768            clone._final = ((this._final == null)?null:this.isFinal());
769            // CBuiltinLeafInfo: java.lang.Boolean
770            clone.override = ((this.override == null)?null:this.isOverride());
771            return clone;
772        }
773    }
774    
775    /**
776     * Gets the Java value of the property.
777     * <p>The Java value of the property is computed based on the following rules:
778     * <ol>
779     * <li>If property {@code any} is set, the Java value is computed based on the object returned by method
780     * {@code getAny()} by possibly unwrapping any {@code JAXBElement} instances. If that object declares a
781     * <blockquote><pre>public Object getJavaValue( ClassLoader )</pre></blockquote> method, the value returned by this
782     * method is the object returned by a call to that method using reflection. If that object does not declare such a
783     * method, the value returned by this method is that (possibly unwrapped) object.</li>
784     * <li>If property {@code value} is set, the Java value is computed based on the values of properties {@code type}
785     * and {@code value}. If property {@code type} is not set or equals {@code java.lang.String}, the value returned
786     * by this method is the string value returned by method {@code getValue()}. If property {@code type} equals a name
787     * of a Java primitive type, an instance of the wrapper class corresponding to that primitive type name is returned
788     * instantiated by passing the value of property {@code value} to the public constructor taking a single
789     * {@code java.lang.String} argument of that wrapper class. For all other values of property {@code type} an
790     * instance of a class with a name equal to the value of property {@code type} is returned instantiated by passing
791     * the value of property {@code value} to the public constructor taking a single {@code java.lang.String} argument
792     * of that class.</li>
793     * <li>If properties {@code any} and {@code value} are both {@code null}, this method returns {@code null}.</li>
794     * </ol></p>
795     *
796     * @param classLoader The class loader to use for getting the Java value; {@code null} to use the platform's
797     * bootstrap class loader.
798     *
799     * @return The Java value of the property or {@code null}.
800     *
801     * @throws ModelObjectException if compiling the name of the type to a {@code JavaTypeName} fails.
802     * @throws PropertyException if getting the Java value of the property fails unexpectedly.
803     *
804     * @see #getJavaTypeName()
805     */
806    public Object getJavaValue( final ClassLoader classLoader ) throws ModelObjectException, PropertyException
807    {
808        try
809        {
810            if ( this.getAny() != null )
811            {
812                if ( this.getType() == null )
813                {
814                    throw new PropertyException( getMessage( "mandatoryType", this.getName() ) );
815                }
816
817                final Object anyObject = this.getAny() instanceof JAXBElement
818                                         ? ( (JAXBElement) this.getAny() ).getValue() : this.getAny();
819
820                return this.getJavaValue( classLoader, anyObject,
821                                          this.getJavaTypeName().getClass( classLoader, false ) );
822
823            }
824            else
825            {
826                if ( this.getJavaTypeName().isPrimitive() && this.getValue() == null )
827                {
828                    throw new PropertyException( getMessage( "mandatoryPrimitiveValue", this.getName(),
829                                                             this.getType() ) );
830
831                }
832
833                return this.getJavaValue( this.getJavaTypeName().isPrimitive()
834                                          ? this.getJavaTypeName().getBoxedName().getClass( classLoader, false )
835                                          : this.getJavaTypeName().getClass( classLoader, false ),
836                                          this.getValue() );
837
838            }
839        }
840        catch ( final ClassNotFoundException e )
841        {
842            throw new PropertyException( getMessage( "classNotFound", this.getName(), this.getType() ), e );
843        }
844    }
845
846    /**
847     * Gets the Java type name of the property.
848     *
849     * @return The Java type name of the type referenced by the property or {@code null}, if the property does not
850     * reference a type.
851     *
852     * @throws ModelObjectException if compiling the name of the type referenced by the property to a
853     * {@code JavaTypeName} fails.
854     *
855     * @since 1.4
856     */
857    public JavaTypeName getJavaTypeName() throws ModelObjectException
858    {
859        final String typeName = this.getType() == null
860                                ? this.getAny() == null
861                                  ? String.class.getName()
862                                  : Object.class.getName()
863                                : this.getType();
864
865        try
866        {
867            return JavaTypeName.parse( typeName );
868        }
869        catch ( final java.text.ParseException e )
870        {
871            throw new ModelObjectException( getMessage( "javaTypeNameParseException", typeName, getMessage( e ) ), e );
872        }
873    }
874
875    /**
876     * Gets the Java getter method name of the property.
877     *
878     * @return The Java getter method name of the property.
879     *
880     * @throws ModelObjectException if compiling the name of the type referenced by the property to a
881     * {@code JavaTypeName} fails or if compiling the name of the property to a {@code JavaIdentifier} fails.
882     *
883     * @since 1.4
884     *
885     * @see #getName()
886     */
887    public JavaIdentifier getJavaGetterMethodName() throws ModelObjectException
888    {
889        try
890        {
891            final JavaTypeName javaType = this.getJavaTypeName();
892            final String prefix = javaType.runtimeEquals( JavaTypeName.BOOLEAN )
893                                  || javaType.runtimeEquals( JavaTypeName.BOOLEAN_TYPE ) ? "is" : "get";
894
895            return JavaIdentifier.parse( prefix + JavaIdentifier.normalize(
896                this.getName() != null ? this.getName() : "", JavaIdentifier.NormalizationMode.CAMEL_CASE ) );
897
898        }
899        catch ( final java.text.ParseException e )
900        {
901            throw new ModelObjectException( getMessage( "javaIdentifierParseException", this.getName(),
902                                                        getMessage( e ) ), e );
903
904        }
905    }
906
907    /**
908     * Gets the Java setter method name of the property.
909     *
910     * @return The Java setter method name of the property.
911     *
912     * @throws ModelObjectException if compiling the name of the property to a {@code JavaIdentifier} fails.
913     *
914     * @since 1.4
915     *
916     * @see #getName()
917     */
918    public JavaIdentifier getJavaSetterMethodName() throws ModelObjectException
919    {
920        try
921        {
922            return JavaIdentifier.parse( "set" + JavaIdentifier.normalize(
923                this.getName() != null ? this.getName() : "", JavaIdentifier.NormalizationMode.CAMEL_CASE ) );
924
925        }
926        catch ( final java.text.ParseException e )
927        {
928            throw new ModelObjectException( getMessage( "javaIdentifierParseException", this.getName(),
929                                                        getMessage( e ) ), e );
930
931        }
932    }
933
934    /**
935     * Gets the Java variable name of the property.
936     *
937     * @return The Java variable name of the property.
938     *
939     * @throws ModelObjectException if compiling the name of the property to a {@code JavaIdentifier} fails.
940     *
941     * @since 1.4
942     *
943     * @see #getName()
944     */
945    public JavaIdentifier getJavaVariableName() throws ModelObjectException
946    {
947        try
948        {
949            return JavaIdentifier.normalize( this.getName() != null ? this.getName() : "",
950                                             JavaIdentifier.NormalizationMode.VARIABLE_NAME_CONVENTION );
951
952        }
953        catch ( final java.text.ParseException e )
954        {
955            throw new ModelObjectException( getMessage( "javaIdentifierParseException", this.getName(),
956                                                        getMessage( e ) ), e );
957
958        }
959    }
960
961    /**
962     * Gets the Java constant name of the message.
963     *
964     * @return The Java constant name of the message.
965     *
966     * @throws ModelObjectException if compiling the name of the property to a {@code JavaIdentifier} fails.
967     *
968     * @since 1.4
969     *
970     * @see #getName()
971     */
972    public JavaIdentifier getJavaConstantName() throws ModelObjectException
973    {
974        try
975        {
976            return JavaIdentifier.normalize( this.getName() != null ? this.getName() : "",
977                                             JavaIdentifier.NormalizationMode.CONSTANT_NAME_CONVENTION );
978
979        }
980        catch ( final java.text.ParseException e )
981        {
982            throw new ModelObjectException( getMessage( "javaIdentifierParseException", this.getName(),
983                                                        getMessage( e ) ), e );
984
985        }
986    }
987
988    private Object getJavaValue( final ClassLoader classLoader, final Object any, final Class<?> returnType )
989        throws PropertyException
990    {
991        if ( any != null )
992        {
993            final String methodName = "getJavaValue";
994
995            try
996            {
997                final java.lang.reflect.Method m = any.getClass().getMethod( methodName, ClassLoader.class );
998                final Object result = m.invoke( any, classLoader );
999
1000                if ( result != null && !returnType.isAssignableFrom( result.getClass() ) )
1001                {
1002                    throw new PropertyException( getMessage( "illegalMethodInvocationResult", methodName,
1003                                                             any.getClass().getName(), result.getClass().getName(),
1004                                                             returnType.getName() ) );
1005
1006                }
1007
1008                return result;
1009            }
1010            catch ( final IllegalAccessException e )
1011            {
1012                throw new PropertyException( getMessage( "methodAccessDenied", methodName,
1013                                                         any.getClass().getName() ), e );
1014
1015            }
1016            catch ( final IllegalArgumentException e )
1017            {
1018                throw new AssertionError( e );
1019            }
1020            catch ( final InvocationTargetException e )
1021            {
1022                throw new PropertyException( getMessage( "methodInvocationFailure", methodName,
1023                                                         any.getClass().getName() ), e );
1024
1025            }
1026            catch ( final SecurityException e )
1027            {
1028                throw new PropertyException( getMessage( "methodAccessDenied", methodName,
1029                                                         any.getClass().getName() ), e );
1030
1031            }
1032            catch ( final NoSuchMethodException e )
1033            {
1034                // Optional method not provided.
1035            }
1036        }
1037
1038        return any;
1039    }
1040
1041    private Object getJavaValue( final Class<?> type, final String value ) throws PropertyException
1042    {
1043        if ( value != null )
1044        {
1045            try
1046            {
1047                if ( type == Character.class )
1048                {
1049                    if ( value.length() != 1 )
1050                    {
1051                        throw new PropertyException( getMessage( "illegalValue", value, Character.class.getName() ) );
1052                    }
1053
1054                    return type.getConstructor( new Class<?>[]
1055                        {
1056                            char.class
1057                        } ).newInstance( new Object[]
1058                        {
1059                            value.charAt( 0 )
1060                        } );
1061
1062                }
1063                else if ( type == String.class )
1064                {
1065                    return value;
1066                }
1067                else
1068                {
1069                    return type.getConstructor( new Class<?>[]
1070                        {
1071                            String.class
1072                        } ).newInstance( value );
1073
1074                }
1075            }
1076            catch ( final InstantiationException e )
1077            {
1078                throw new PropertyException( getMessage( "instantiationException", type.getName() ), e );
1079            }
1080            catch ( final IllegalAccessException e )
1081            {
1082                throw new PropertyException( getMessage( "constructorAccessDenied", type.getName() ), e );
1083            }
1084            catch ( final IllegalArgumentException e )
1085            {
1086                throw new AssertionError( e );
1087            }
1088            catch ( final InvocationTargetException e )
1089            {
1090                throw new PropertyException( getMessage( "constructorInvocationFailure", type.getName() ), e );
1091            }
1092            catch ( final NoSuchMethodException e )
1093            {
1094                throw new PropertyException( getMessage( "constructorNotFound", type.getName() ), e );
1095            }
1096        }
1097
1098        return value;
1099    }
1100
1101    private static String getMessage( final Throwable t )
1102    {
1103        return t != null ? t.getMessage() != null ? t.getMessage() : getMessage( t.getCause() ) : null;
1104    }
1105
1106    private static String getMessage( final String key, final Object... arguments )
1107    {
1108        return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle(
1109            Property.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ).getString( key ), arguments );
1110
1111    }
1112      
1113}