View Javadoc
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: 2015.05.31 at 05:43:54 PM CEST 
6   //
7   
8   
9   package org.jomc.tools.model;
10  
11  import javax.annotation.Generated;
12  import javax.xml.bind.annotation.XmlAccessType;
13  import javax.xml.bind.annotation.XmlAccessorType;
14  import javax.xml.bind.annotation.XmlAttribute;
15  import javax.xml.bind.annotation.XmlSeeAlso;
16  import javax.xml.bind.annotation.XmlType;
17  
18  
19  /**
20   * Base tools type.
21   * 
22   * <p>Java class for ToolsType complex type.
23   * 
24   * <p>The following schema fragment specifies the expected content contained within this class.
25   * 
26   * <pre>
27   * &lt;complexType name="ToolsType">
28   *   &lt;complexContent>
29   *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
30   *       &lt;attribute name="modelVersion" type="{http://www.w3.org/2001/XMLSchema}string" default="1.6" />
31   *     &lt;/restriction>
32   *   &lt;/complexContent>
33   * &lt;/complexType>
34   * </pre>
35   * 
36   * 
37   */
38  @XmlAccessorType(XmlAccessType.FIELD)
39  @XmlType(name = "ToolsType", namespace = "http://jomc.org/tools/model")
40  @XmlSeeAlso({
41      SourceSectionType.class,
42      SourceSectionsType.class,
43      SourceFileType.class,
44      SourceFilesType.class,
45      TemplateParameterType.class
46  })
47  @Generated(value = "com.sun.tools.xjc.Driver", date = "2015-05-31T05:43:54+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
48  public class ToolsType implements Cloneable
49  {
50  
51      @XmlAttribute(name = "modelVersion")
52      @Generated(value = "com.sun.tools.xjc.Driver", date = "2015-05-31T05:43:54+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
53      protected String modelVersion;
54  
55      /**
56       * Creates a new {@code ToolsType} instance.
57       * 
58       */
59      public ToolsType() {
60          // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
61          super();
62      }
63  
64      /**
65       * Creates a new {@code ToolsType} instance by deeply copying a given {@code ToolsType} instance.
66       * 
67       * 
68       * @param o
69       *     The instance to copy.
70       * @throws NullPointerException
71       *     if {@code o} is {@code null}.
72       */
73      public ToolsType(final ToolsType o) {
74          // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
75          super();
76          if (o == null) {
77              throw new NullPointerException("Cannot create a copy of 'ToolsType' from 'null'.");
78          }
79          // CBuiltinLeafInfo: java.lang.String
80          this.modelVersion = ((o.modelVersion == null)?null:o.getModelVersion());
81      }
82  
83      /**
84       * Gets the value of the modelVersion property.
85       * 
86       * @return
87       *     possible object is
88       *     {@link String }
89       *     
90       */
91      @Generated(value = "com.sun.tools.xjc.Driver", date = "2015-05-31T05:43:54+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
92      public String getModelVersion() {
93          if (modelVersion == null) {
94              return "1.6";
95          } else {
96              return modelVersion;
97          }
98      }
99  
100     /**
101      * Sets the value of the modelVersion property.
102      * 
103      * @param value
104      *     allowed object is
105      *     {@link String }
106      *     
107      */
108     @Generated(value = "com.sun.tools.xjc.Driver", date = "2015-05-31T05:43:54+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
109     public void setModelVersion(String value) {
110         this.modelVersion = value;
111     }
112 
113     /**
114      * Creates and returns a deep copy of this object.
115      * 
116      * 
117      * @return
118      *     A deep copy of this object.
119      */
120     @Override
121     @Generated(value = "com.sun.tools.xjc.Driver", date = "2015-05-31T05:43:54+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
122     public ToolsType clone() {
123         try {
124             {
125                 // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
126                 final ToolsType clone = ((ToolsType) super.clone());
127                 // CBuiltinLeafInfo: java.lang.String
128                 clone.modelVersion = ((this.modelVersion == null)?null:this.getModelVersion());
129                 return clone;
130             }
131         } catch (CloneNotSupportedException e) {
132             // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
133             throw new AssertionError(e);
134         }
135     }
136     
137     /**
138      * Gets a single {@code JAXBElement} matching a namespace URI and local part from a given list of objects.
139      *
140      * @param any The list to search.
141      * @param namespaceURI The namespace URI of the {@code JAXBElement} to return.
142      * @param localPart The local part of the {@code JAXBElement} to return.
143      * @param type The class of the type the element is bound to.
144      * @param <T> The type the element is bound to.
145      *
146      * @return The {@code JAXBElement} matching {@code namespaceURI} and {@code localPart} from the {@code any} list or
147      * {@code null} if no such element is found.
148      *
149      * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is
150      * {@code null}.
151      * @throws IllegalStateException if {@code any} contains more than one matching element.
152      */
153     protected <T> javax.xml.bind.JAXBElement<T> getAnyElement( final java.util.List<Object> any,
154                                                                final String namespaceURI,
155                                                                final String localPart,
156                                                                final Class<T> type )
157     {
158         if ( any == null )
159         {
160             throw new NullPointerException( "any" );
161         }
162         if ( namespaceURI == null )
163         {
164             throw new NullPointerException( "namespaceURI" );
165         }
166         if ( localPart == null )
167         {
168             throw new NullPointerException( "localPart" );
169         }
170         if ( type == null )
171         {
172             throw new NullPointerException( "type" );
173         }
174 
175         javax.xml.bind.JAXBElement<?> anyElement = null;
176 
177         for ( int i = 0, s0 = any.size(); i < s0; i++ )
178         {
179             final Object o = any.get( i );
180 
181             if ( o instanceof javax.xml.bind.JAXBElement<?> )
182             {
183                 final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;
184 
185                 if ( namespaceURI.equals( e.getName().getNamespaceURI() )
186                      && localPart.equals( e.getName().getLocalPart() ) )
187                 {
188                     if ( anyElement == null )
189                     {
190                         anyElement = e;
191                     }
192                     else
193                     {
194                         throw new IllegalStateException( getMessage( "nonUniqueElement", this.getClass().getName(),
195                                                                      namespaceURI, localPart ) );
196 
197                     }
198                 }
199             }
200         }
201 
202         if ( anyElement != null && anyElement.getValue() != null && anyElement.getValue().getClass().equals( type ) )
203         {
204             @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> e =
205                 (javax.xml.bind.JAXBElement<T>) anyElement;
206 
207             return e;
208         }
209 
210         return null;
211     }
212 
213     /**
214      * Gets a list containing all {@code JAXBElement}s matching a namespace URI and local part from a given list of
215      * objects.
216      *
217      * @param any The list to search.
218      * @param namespaceURI The namespace URI of the {@code JAXBElement}s to return.
219      * @param localPart The local part of the {@code JAXBElement}s to return.
220      * @param type The class of the type the elements are bound to.
221      * @param <T> The type the elements are bound to.
222      *
223      * @return An unmodifiable list of all {@code JAXBElement}s matching {@code namespaceURI} and {@code localPart} from
224      * the {@code any} list - an empty list if no such elements are found.
225      *
226      * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is
227      * {@code null}.
228      */
229     protected <T> java.util.List<javax.xml.bind.JAXBElement<T>> getAnyElements( final java.util.List<Object> any,
230                                                                                 final String namespaceURI,
231                                                                                 final String localPart,
232                                                                                 final Class<T> type )
233     {
234         if ( any == null )
235         {
236             throw new NullPointerException( "any" );
237         }
238         if ( namespaceURI == null )
239         {
240             throw new NullPointerException( "namespaceURI" );
241         }
242         if ( localPart == null )
243         {
244             throw new NullPointerException( "localPart" );
245         }
246         if ( type == null )
247         {
248             throw new NullPointerException( "type" );
249         }
250 
251         final java.util.List<javax.xml.bind.JAXBElement<T>> anyElements =
252             new java.util.ArrayList<javax.xml.bind.JAXBElement<T>>( any.size() );
253 
254         for ( int i = 0, s0 = any.size(); i < s0; i++ )
255         {
256             final Object o = any.get( i );
257 
258             if ( o instanceof javax.xml.bind.JAXBElement<?> )
259             {
260                 final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;
261 
262                 if ( namespaceURI.equals( e.getName().getNamespaceURI() )
263                      && localPart.equals( e.getName().getLocalPart() )
264                      && e.getValue() != null && e.getValue().getClass().equals( type ) )
265                 {
266                     @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> anyElement =
267                         (javax.xml.bind.JAXBElement<T>) e;
268 
269                     anyElements.add( anyElement );
270                 }
271             }
272         }
273 
274         return java.util.Collections.unmodifiableList( anyElements );
275     }
276 
277     /**
278      * Gets a single object matching a class from a given list of objects.
279      *
280      * @param any The list to search.
281      * @param clazz The class to return an instance of.
282      * @param <T> The type of the object to return.
283      *
284      * @return The instance of {@code clazz} from the {@code any} list or {@code null}, if no such instance is found.
285      *
286      * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}.
287      * @throws IllegalStateException if {@code any} contains more than one matching object.
288      */
289     protected <T> T getAnyObject( final java.util.List<Object> any, final Class<T> clazz )
290     {
291         if ( any == null )
292         {
293             throw new NullPointerException( "any" );
294         }
295         if ( clazz == null )
296         {
297             throw new NullPointerException( "clazz" );
298         }
299 
300         T anyObject = null;
301 
302         for ( int i = 0, s0 = any.size(); i < s0; i++ )
303         {
304             Object o = any.get( i );
305 
306             if ( o instanceof javax.xml.bind.JAXBElement<?> )
307             {
308                 o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue();
309             }
310 
311             if ( clazz.equals( o.getClass() ) )
312             {
313                 if ( anyObject == null )
314                 {
315                     @SuppressWarnings( "unchecked" ) final T object = (T) o;
316                     anyObject = object;
317                 }
318                 else
319                 {
320                     throw new IllegalStateException( getMessage( "nonUniqueObject", this.getClass().getName(),
321                                                                  clazz.getName() ) );
322 
323                 }
324             }
325         }
326 
327         return anyObject;
328     }
329 
330     /**
331      * Gets a list containing all objects matching a class from a given list of objects.
332      *
333      * @param any The list to search.
334      * @param clazz The class to return all instances of.
335      * @param <T> The type of the objects to return.
336      *
337      * @return An unmodifiable list of all instances of {@code clazz} from the {@code any} list - an empty list if no
338      * such objects are found.
339      *
340      * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}.
341      */
342     protected <T> java.util.List<T> getAnyObjects( final java.util.List<Object> any, final Class<T> clazz )
343     {
344         if ( any == null )
345         {
346             throw new NullPointerException( "any" );
347         }
348         if ( clazz == null )
349         {
350             throw new NullPointerException( "namespaceURI" );
351         }
352 
353         final java.util.List<T> anyElements = new java.util.ArrayList<T>( any.size() );
354 
355         for ( int i = 0, s0 = any.size(); i < s0; i++ )
356         {
357             Object o = any.get( i );
358 
359             if ( o instanceof javax.xml.bind.JAXBElement<?> )
360             {
361                 o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue();
362             }
363 
364             if ( clazz.equals( o.getClass() ) )
365             {
366                 @SuppressWarnings( "unchecked" ) final T object = (T) o;
367                 anyElements.add( object );
368             }
369         }
370 
371         return java.util.Collections.unmodifiableList( anyElements );
372     }
373 
374     private static String getMessage( final String key, final Object... args )
375     {
376         return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle(
377             ToolsType.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ).
378             getString( key ), args );
379     }
380       
381 }