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