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: 2012.05.23 at 02:54:23 AM CEST 
006    //
007    
008    
009    package org.jomc.tools.model;
010    
011    import javax.annotation.Generated;
012    import javax.xml.bind.annotation.XmlAccessType;
013    import javax.xml.bind.annotation.XmlAccessorType;
014    import javax.xml.bind.annotation.XmlAttribute;
015    import javax.xml.bind.annotation.XmlSeeAlso;
016    import javax.xml.bind.annotation.XmlType;
017    
018    
019    /**
020     * Base tools type.
021     * 
022     * <p>Java class for ToolsType complex type.
023     * 
024     * <p>The following schema fragment specifies the expected content contained within this class.
025     * 
026     * <pre>
027     * &lt;complexType name="ToolsType">
028     *   &lt;complexContent>
029     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
030     *       &lt;attribute name="modelVersion" type="{http://www.w3.org/2001/XMLSchema}string" default="1.2" />
031     *     &lt;/restriction>
032     *   &lt;/complexContent>
033     * &lt;/complexType>
034     * </pre>
035     * 
036     * 
037     */
038    @XmlAccessorType(XmlAccessType.FIELD)
039    @XmlType(name = "ToolsType", namespace = "http://jomc.org/tools/model")
040    @XmlSeeAlso({
041        SourceSectionType.class,
042        SourceSectionsType.class,
043        SourceFileType.class,
044        SourceFilesType.class
045    })
046    @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-05-23T02:54:23+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
047    public class ToolsType implements Cloneable
048    {
049    
050        @XmlAttribute(name = "modelVersion")
051        @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-05-23T02:54:23+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
052        protected String modelVersion;
053    
054        /**
055         * Creates a new {@code ToolsType} instance.
056         * 
057         */
058        public ToolsType() {
059            // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000
060            super();
061        }
062    
063        /**
064         * Creates a new {@code ToolsType} instance by deeply copying a given {@code ToolsType} instance.
065         * 
066         * 
067         * @param o
068         *     The instance to copy.
069         * @throws NullPointerException
070         *     if {@code o} is {@code null}.
071         */
072        public ToolsType(final ToolsType o) {
073            // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000
074            super();
075            if (o == null) {
076                throw new NullPointerException("Cannot create a copy of 'ToolsType' from 'null'.");
077            }
078            // CBuiltinLeafInfo: java.lang.String
079            this.modelVersion = ((o.modelVersion == null)?null:o.getModelVersion());
080        }
081    
082        /**
083         * Gets the value of the modelVersion property.
084         * 
085         * @return
086         *     possible object is
087         *     {@link String }
088         *     
089         */
090        @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-05-23T02:54:23+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
091        public String getModelVersion() {
092            if (modelVersion == null) {
093                return "1.2";
094            } else {
095                return modelVersion;
096            }
097        }
098    
099        /**
100         * Sets the value of the modelVersion property.
101         * 
102         * @param value
103         *     allowed object is
104         *     {@link String }
105         *     
106         */
107        @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-05-23T02:54:23+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
108        public void setModelVersion(String value) {
109            this.modelVersion = value;
110        }
111    
112        /**
113         * Creates and returns a deep copy of this object.
114         * 
115         * 
116         * @return
117         *     A deep copy of this object.
118         */
119        @Override
120        @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-05-23T02:54:23+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
121        public ToolsType clone() {
122            try {
123                {
124                    // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000
125                    final ToolsType clone = ((ToolsType) super.clone());
126                    // CBuiltinLeafInfo: java.lang.String
127                    clone.modelVersion = ((this.modelVersion == null)?null:this.getModelVersion());
128                    return clone;
129                }
130            } catch (CloneNotSupportedException e) {
131                // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
132                throw new AssertionError(e);
133            }
134        }
135        
136        /**
137         * Gets a single {@code JAXBElement} matching a namespace URI and local part from a given list of objects.
138         *
139         * @param any The list to search.
140         * @param namespaceURI The namespace URI of the {@code JAXBElement} to return.
141         * @param localPart The local part of the {@code JAXBElement} to return.
142         * @param type The class of the type the element is bound to.
143         * @param <T> The type the element is bound to.
144         *
145         * @return The {@code JAXBElement} matching {@code namespaceURI} and {@code localPart} from the {@code any} list or
146         * {@code null} if no such element is found.
147         *
148         * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is
149         * {@code null}.
150         * @throws IllegalStateException if {@code any} contains more than one matching element.
151         */
152        protected <T> javax.xml.bind.JAXBElement<T> getAnyElement( final java.util.List<Object> any,
153                                                                   final String namespaceURI,
154                                                                   final String localPart,
155                                                                   final Class<T> type )
156        {
157            if ( any == null )
158            {
159                throw new NullPointerException( "any" );
160            }
161            if ( namespaceURI == null )
162            {
163                throw new NullPointerException( "namespaceURI" );
164            }
165            if ( localPart == null )
166            {
167                throw new NullPointerException( "localPart" );
168            }
169            if ( type == null )
170            {
171                throw new NullPointerException( "type" );
172            }
173    
174            javax.xml.bind.JAXBElement<?> anyElement = null;
175    
176            for ( int i = 0, s0 = any.size(); i < s0; i++ )
177            {
178                final Object o = any.get( i );
179    
180                if ( o instanceof javax.xml.bind.JAXBElement<?> )
181                {
182                    final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;
183    
184                    if ( namespaceURI.equals( e.getName().getNamespaceURI() )
185                         && localPart.equals( e.getName().getLocalPart() ) )
186                    {
187                        if ( anyElement == null )
188                        {
189                            anyElement = e;
190                        }
191                        else
192                        {
193                            throw new IllegalStateException( getMessage( "nonUniqueElement", this.getClass().getName(),
194                                                                         namespaceURI, localPart ) );
195    
196                        }
197                    }
198                }
199            }
200    
201            if ( anyElement != null && anyElement.getValue() != null && anyElement.getValue().getClass().equals( type ) )
202            {
203                @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> e =
204                    (javax.xml.bind.JAXBElement<T>) anyElement;
205    
206                return e;
207            }
208    
209            return null;
210        }
211    
212        /**
213         * Gets a list containing all {@code JAXBElement}s matching a namespace URI and local part from a given list of
214         * objects.
215         *
216         * @param any The list to search.
217         * @param namespaceURI The namespace URI of the {@code JAXBElement}s to return.
218         * @param localPart The local part of the {@code JAXBElement}s to return.
219         * @param type The class of the type the elements are bound to.
220         * @param <T> The type the elements are bound to.
221         *
222         * @return An unmodifiable list of all {@code JAXBElement}s matching {@code namespaceURI} and {@code localPart} from
223         * the {@code any} list - an empty list if no such elements are found.
224         *
225         * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is
226         * {@code null}.
227         */
228        protected <T> java.util.List<javax.xml.bind.JAXBElement<T>> getAnyElements( final java.util.List<Object> any,
229                                                                                    final String namespaceURI,
230                                                                                    final String localPart,
231                                                                                    final Class<T> type )
232        {
233            if ( any == null )
234            {
235                throw new NullPointerException( "any" );
236            }
237            if ( namespaceURI == null )
238            {
239                throw new NullPointerException( "namespaceURI" );
240            }
241            if ( localPart == null )
242            {
243                throw new NullPointerException( "localPart" );
244            }
245            if ( type == null )
246            {
247                throw new NullPointerException( "type" );
248            }
249    
250            final java.util.List<javax.xml.bind.JAXBElement<T>> anyElements =
251                new java.util.ArrayList<javax.xml.bind.JAXBElement<T>>( any.size() );
252    
253            for ( int i = 0, s0 = any.size(); i < s0; i++ )
254            {
255                final Object o = any.get( i );
256    
257                if ( o instanceof javax.xml.bind.JAXBElement<?> )
258                {
259                    final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;
260    
261                    if ( namespaceURI.equals( e.getName().getNamespaceURI() )
262                         && localPart.equals( e.getName().getLocalPart() )
263                         && e.getValue() != null && e.getValue().getClass().equals( type ) )
264                    {
265                        @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> anyElement =
266                            (javax.xml.bind.JAXBElement<T>) e;
267    
268                        anyElements.add( anyElement );
269                    }
270                }
271            }
272    
273            return java.util.Collections.unmodifiableList( anyElements );
274        }
275    
276        /**
277         * Gets a single object matching a class from a given list of objects.
278         *
279         * @param any The list to search.
280         * @param clazz The class to return an instance of.
281         * @param <T> The type of the object to return.
282         *
283         * @return The instance of {@code clazz} from the {@code any} list or {@code null}, if no such instance is found.
284         *
285         * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}.
286         * @throws IllegalStateException if {@code any} contains more than one matching object.
287         */
288        protected <T> T getAnyObject( final java.util.List<Object> any, final Class<T> clazz )
289        {
290            if ( any == null )
291            {
292                throw new NullPointerException( "any" );
293            }
294            if ( clazz == null )
295            {
296                throw new NullPointerException( "clazz" );
297            }
298    
299            T anyObject = null;
300    
301            for ( int i = 0, s0 = any.size(); i < s0; i++ )
302            {
303                Object o = any.get( i );
304    
305                if ( o instanceof javax.xml.bind.JAXBElement<?> )
306                {
307                    o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue();
308                }
309    
310                if ( clazz.equals( o.getClass() ) )
311                {
312                    if ( anyObject == null )
313                    {
314                        @SuppressWarnings( "unchecked" ) final T object = (T) o;
315                        anyObject = object;
316                    }
317                    else
318                    {
319                        throw new IllegalStateException( getMessage( "nonUniqueObject", this.getClass().getName(),
320                                                                     clazz.getName() ) );
321    
322                    }
323                }
324            }
325    
326            return anyObject;
327        }
328    
329        /**
330         * Gets a list containing all objects matching a class from a given list of objects.
331         *
332         * @param any The list to search.
333         * @param clazz The class to return all instances of.
334         * @param <T> The type of the objects to return.
335         *
336         * @return An unmodifiable list of all instances of {@code clazz} from the {@code any} list - an empty list if no
337         * such objects are found.
338         *
339         * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}.
340         */
341        protected <T> java.util.List<T> getAnyObjects( final java.util.List<Object> any, final Class<T> clazz )
342        {
343            if ( any == null )
344            {
345                throw new NullPointerException( "any" );
346            }
347            if ( clazz == null )
348            {
349                throw new NullPointerException( "namespaceURI" );
350            }
351    
352            final java.util.List<T> anyElements = new java.util.ArrayList<T>( any.size() );
353    
354            for ( int i = 0, s0 = any.size(); i < s0; i++ )
355            {
356                Object o = any.get( i );
357    
358                if ( o instanceof javax.xml.bind.JAXBElement<?> )
359                {
360                    o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue();
361                }
362    
363                if ( clazz.equals( o.getClass() ) )
364                {
365                    @SuppressWarnings( "unchecked" ) final T object = (T) o;
366                    anyElements.add( object );
367                }
368            }
369    
370            return java.util.Collections.unmodifiableList( anyElements );
371        }
372    
373        private static String getMessage( final String key, final Object... args )
374        {
375            return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle(
376                ToolsType.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ).
377                getString( key ), args );
378        }
379          
380    }