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.04.01 at 02:20:36 AM CEST 
006    //
007    
008    
009    package org.jomc.modlet;
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.XmlSeeAlso;
015    import javax.xml.bind.annotation.XmlType;
016    
017    
018    /**
019     * Base modlet object.
020     * 
021     * <p>Java class for ModletObject complex type.
022     * 
023     * <p>The following schema fragment specifies the expected content contained within this class.
024     * 
025     * <pre>
026     * &lt;complexType name="ModletObject">
027     *   &lt;complexContent>
028     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
029     *     &lt;/restriction>
030     *   &lt;/complexContent>
031     * &lt;/complexType>
032     * </pre>
033     * 
034     * 
035     */
036    @XmlAccessorType(XmlAccessType.FIELD)
037    @XmlType(name = "ModletObject", namespace = "http://jomc.org/modlet")
038    @XmlSeeAlso({
039        Schema.class,
040        Services.class,
041        Schemas.class,
042        Model.class,
043        Modlets.class,
044        Modlet.class,
045        Service.class,
046        Property.class
047    })
048    @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-04-01T02:20:36+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
049    public class ModletObject implements Cloneable
050    {
051    
052    
053        /**
054         * Creates a new {@code ModletObject} instance.
055         * 
056         */
057        public ModletObject() {
058            // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000
059            super();
060        }
061    
062        /**
063         * Creates a new {@code ModletObject} instance by deeply copying a given {@code ModletObject} instance.
064         * 
065         * 
066         * @param o
067         *     The instance to copy.
068         * @throws NullPointerException
069         *     if {@code o} is {@code null}.
070         */
071        public ModletObject(final ModletObject o) {
072            // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000
073            super();
074            if (o == null) {
075                throw new NullPointerException("Cannot create a copy of 'ModletObject' from 'null'.");
076            }
077        }
078    
079        /**
080         * Creates and returns a deep copy of this object.
081         * 
082         * 
083         * @return
084         *     A deep copy of this object.
085         */
086        @Override
087        @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-04-01T02:20:36+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
088        public ModletObject clone() {
089            try {
090                {
091                    // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000
092                    final ModletObject clone = ((ModletObject) super.clone());
093                    return clone;
094                }
095            } catch (CloneNotSupportedException e) {
096                // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
097                throw new AssertionError(e);
098            }
099        }
100        
101        /** Public identifier of the modlet model. */
102        public static final String MODEL_PUBLIC_ID = "http://jomc.org/modlet";
103    
104        /**
105         * Public identifier of the modlet schema.
106         * @since 1.2
107         */
108        public static final java.net.URI PUBLIC_ID;
109    
110        static
111        {
112            try
113            {
114                PUBLIC_ID = new java.net.URI( MODEL_PUBLIC_ID );
115            }
116            catch ( final java.net.URISyntaxException e )
117            {
118                throw new AssertionError( e );
119            }
120        }
121    
122        /**
123         * Gets a single {@code JAXBElement} matching a namespace URI and local part from a given list of objects.
124         *
125         * @param any The list to search.
126         * @param namespaceURI The namespace URI of the {@code JAXBElement} to return.
127         * @param localPart The local part of the {@code JAXBElement} to return.
128         *
129         * @return The {@code JAXBElement} matching {@code namespaceURI} and {@code localPart} from the {@code any} list or
130         * {@code null} if no such element is found.
131         *
132         * @throws NullPointerException if {@code any}, {@code namespaceURI} or {@code localPart} is {@code null}.
133         * @throws IllegalStateException if {@code any} contains more than one matching element.
134         *
135         * @deprecated As of JOMC 1.1, please use method {@link #getAnyElement(java.util.List, java.lang.String, java.lang.String, java.lang.Class)}.
136         * This method will be removed in version 2.0.
137         */
138        @Deprecated
139        protected javax.xml.bind.JAXBElement getAnyElement( final java.util.List<Object> any, final String namespaceURI,
140                                                            final String localPart )
141        {
142            if ( any == null )
143            {
144                throw new NullPointerException( "any" );
145            }
146            if ( namespaceURI == null )
147            {
148                throw new NullPointerException( "namespaceURI" );
149            }
150            if ( localPart == null )
151            {
152                throw new NullPointerException( "localPart" );
153            }
154    
155            javax.xml.bind.JAXBElement<?> anyElement = null;
156    
157            for ( int i = 0, s0 = any.size(); i < s0; i++ )
158            {
159                final Object o = any.get( i );
160    
161                if ( o instanceof javax.xml.bind.JAXBElement<?> )
162                {
163                    final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;
164    
165                    if ( namespaceURI.equals( e.getName().getNamespaceURI() )
166                         && localPart.equals( e.getName().getLocalPart() ) )
167                    {
168                        if ( anyElement == null )
169                        {
170                            anyElement = e;
171                        }
172                        else
173                        {
174                            throw new IllegalStateException( getMessage( "nonUniqueElement", this.getClass().getName(),
175                                                                         namespaceURI, localPart ) );
176    
177                        }
178                    }
179                }
180            }
181    
182            return anyElement;
183        }
184    
185        /**
186         * Gets a list containing all {@code JAXBElement}s matching a namespace URI and local part from a given list of
187         * objects.
188         *
189         * @param any The list to search.
190         * @param namespaceURI The namespace URI of the {@code JAXBElement}s to return.
191         * @param localPart The local part of the {@code JAXBElement}s to return.
192         *
193         * @return An unmodifiable list of all {@code JAXBElement}s matching {@code namespaceURI} and {@code localPart} from
194         * the {@code any} list - an empty list if no such elements are found.
195         *
196         * @throws NullPointerException if {@code any}, {@code namespaceURI} or {@code localPart} is {@code null}.
197         *
198         * @deprecated As of JOMC 1.1, please use method {@link #getAnyElements(java.util.List, java.lang.String, java.lang.String, java.lang.Class)}.
199         * This method will be removed in version 2.0.
200         */
201        @Deprecated
202        protected java.util.List<javax.xml.bind.JAXBElement> getAnyElements( final java.util.List<Object> any,
203                                                                             final String namespaceURI,
204                                                                             final String localPart )
205        {
206            if ( any == null )
207            {
208                throw new NullPointerException( "any" );
209            }
210            if ( namespaceURI == null )
211            {
212                throw new NullPointerException( "namespaceURI" );
213            }
214            if ( localPart == null )
215            {
216                throw new NullPointerException( "localPart" );
217            }
218    
219            final java.util.List<javax.xml.bind.JAXBElement> anyElements =
220                new java.util.ArrayList<javax.xml.bind.JAXBElement>( any.size() );
221    
222            for ( int i = 0, s0 = any.size(); i < s0; i++ )
223            {
224                final Object o = any.get( i );
225    
226                if ( o instanceof javax.xml.bind.JAXBElement<?> )
227                {
228                    final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;
229    
230                    if ( namespaceURI.equals( e.getName().getNamespaceURI() )
231                         && localPart.equals( e.getName().getLocalPart() ) )
232                    {
233                        anyElements.add( e );
234                    }
235                }
236            }
237    
238            return java.util.Collections.unmodifiableList( anyElements );
239        }
240    
241        /**
242         * Gets a single {@code JAXBElement} matching a namespace URI and local part from a given list of objects.
243         *
244         * @param any The list to search.
245         * @param namespaceURI The namespace URI of the {@code JAXBElement} to return.
246         * @param localPart The local part of the {@code JAXBElement} to return.
247         * @param type The class of the type the element is bound to.
248         * @param <T> The type the element is bound to.
249         *
250         * @return The {@code JAXBElement} matching {@code namespaceURI} and {@code localPart} from the {@code any} list or
251         * {@code null} if no such element is found.
252         *
253         * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is
254         * {@code null}.
255         * @throws IllegalStateException if {@code any} contains more than one matching element.
256         *
257         * @since 1.1
258         */
259        protected <T> javax.xml.bind.JAXBElement<T> getAnyElement( final java.util.List<Object> any,
260                                                                   final String namespaceURI,
261                                                                   final String localPart,
262                                                                   final Class<T> type )
263        {
264            if ( any == null )
265            {
266                throw new NullPointerException( "any" );
267            }
268            if ( namespaceURI == null )
269            {
270                throw new NullPointerException( "namespaceURI" );
271            }
272            if ( localPart == null )
273            {
274                throw new NullPointerException( "localPart" );
275            }
276            if ( type == null )
277            {
278                throw new NullPointerException( "type" );
279            }
280    
281            javax.xml.bind.JAXBElement<?> anyElement = null;
282    
283            for ( int i = 0, s0 = any.size(); i < s0; i++ )
284            {
285                final Object o = any.get( i );
286    
287                if ( o instanceof javax.xml.bind.JAXBElement<?> )
288                {
289                    final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;
290    
291                    if ( namespaceURI.equals( e.getName().getNamespaceURI() )
292                         && localPart.equals( e.getName().getLocalPart() ) )
293                    {
294                        if ( anyElement == null )
295                        {
296                            anyElement = e;
297                        }
298                        else
299                        {
300                            throw new IllegalStateException( getMessage( "nonUniqueElement", this.getClass().getName(),
301                                                                         namespaceURI, localPart ) );
302    
303                        }
304                    }
305                }
306            }
307    
308            if ( anyElement != null && anyElement.getValue() != null && anyElement.getValue().getClass().equals( type ) )
309            {
310                @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> e =
311                    (javax.xml.bind.JAXBElement<T>) anyElement;
312    
313                return e;
314            }
315    
316            return null;
317        }
318    
319        /**
320         * Gets a list containing all {@code JAXBElement}s matching a namespace URI and local part from a given list of
321         * objects.
322         *
323         * @param any The list to search.
324         * @param namespaceURI The namespace URI of the {@code JAXBElement}s to return.
325         * @param localPart The local part of the {@code JAXBElement}s to return.
326         * @param type The class of the type the elements are bound to.
327         * @param <T> The type the elements are bound to.
328         *
329         * @return An unmodifiable list of all {@code JAXBElement}s matching {@code namespaceURI} and {@code localPart} from
330         * the {@code any} list - an empty list if no such elements are found.
331         *
332         * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is
333         * {@code null}.
334         *
335         * @since 1.1
336         */
337        protected <T> java.util.List<javax.xml.bind.JAXBElement<T>> getAnyElements( final java.util.List<Object> any,
338                                                                                    final String namespaceURI,
339                                                                                    final String localPart,
340                                                                                    final Class<T> type )
341        {
342            if ( any == null )
343            {
344                throw new NullPointerException( "any" );
345            }
346            if ( namespaceURI == null )
347            {
348                throw new NullPointerException( "namespaceURI" );
349            }
350            if ( localPart == null )
351            {
352                throw new NullPointerException( "localPart" );
353            }
354            if ( type == null )
355            {
356                throw new NullPointerException( "type" );
357            }
358    
359            final java.util.List<javax.xml.bind.JAXBElement<T>> anyElements =
360                new java.util.ArrayList<javax.xml.bind.JAXBElement<T>>( any.size() );
361    
362            for ( int i = 0, s0 = any.size(); i < s0; i++ )
363            {
364                final Object o = any.get( i );
365    
366                if ( o instanceof javax.xml.bind.JAXBElement<?> )
367                {
368                    final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;
369    
370                    if ( namespaceURI.equals( e.getName().getNamespaceURI() )
371                         && localPart.equals( e.getName().getLocalPart() )
372                         && e.getValue() != null && e.getValue().getClass().equals( type ) )
373                    {
374                        @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> anyElement =
375                            (javax.xml.bind.JAXBElement<T>) e;
376    
377                        anyElements.add( anyElement );
378                    }
379                }
380            }
381    
382            return java.util.Collections.unmodifiableList( anyElements );
383        }
384    
385        /**
386         * Gets a single object matching a class from a given list of objects.
387         *
388         * @param any The list to search.
389         * @param clazz The class to return an instance of.
390         * @param <T> The type of the object to return.
391         *
392         * @return The instance of {@code clazz} from the {@code any} list or {@code null}, if no such instance is found.
393         *
394         * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}.
395         * @throws IllegalStateException if {@code any} contains more than one matching object.
396         */
397        protected <T> T getAnyObject( final java.util.List<Object> any, final Class<T> clazz )
398        {
399            if ( any == null )
400            {
401                throw new NullPointerException( "any" );
402            }
403            if ( clazz == null )
404            {
405                throw new NullPointerException( "clazz" );
406            }
407    
408            T anyObject = null;
409    
410            for ( int i = 0, s0 = any.size(); i < s0; i++ )
411            {
412                Object o = any.get( i );
413    
414                if ( o instanceof javax.xml.bind.JAXBElement<?> )
415                {
416                    o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue();
417                }
418    
419                if ( clazz.equals( o.getClass() ) )
420                {
421                    if ( anyObject == null )
422                    {
423                        @SuppressWarnings( "unchecked" ) final T object = (T) o;
424                        anyObject = object;
425                    }
426                    else
427                    {
428                        throw new IllegalStateException( getMessage( "nonUniqueObject", this.getClass().getName(),
429                                                                     clazz.getName() ) );
430    
431                    }
432                }
433            }
434    
435            return anyObject;
436        }
437    
438        /**
439         * Gets a list containing all objects matching a class from a given list of objects.
440         *
441         * @param any The list to search.
442         * @param clazz The class to return all instances of.
443         * @param <T> The type of the objects to return.
444         *
445         * @return An unmodifiable list of all instances of {@code clazz} from the {@code any} list - an empty list if no
446         * such objects are found.
447         *
448         * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}.
449         */
450        protected <T> java.util.List<T> getAnyObjects( final java.util.List<Object> any, final Class<T> clazz )
451        {
452            if ( any == null )
453            {
454                throw new NullPointerException( "any" );
455            }
456            if ( clazz == null )
457            {
458                throw new NullPointerException( "namespaceURI" );
459            }
460    
461            final java.util.List<T> anyElements = new java.util.ArrayList<T>( any.size() );
462    
463            for ( int i = 0, s0 = any.size(); i < s0; i++ )
464            {
465                Object o = any.get( i );
466    
467                if ( o instanceof javax.xml.bind.JAXBElement<?> )
468                {
469                    o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue();
470                }
471    
472                if ( clazz.equals( o.getClass() ) )
473                {
474                    @SuppressWarnings( "unchecked" ) final T object = (T) o;
475                    anyElements.add( object );
476                }
477            }
478    
479            return java.util.Collections.unmodifiableList( anyElements );
480        }
481    
482        private static String getMessage( final String key, final Object... args )
483        {
484            return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle(
485                ModletObject.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ).
486                getString( key ), args );
487    
488        }
489          
490    }