EMMA Coverage Report (generated Thu Jan 03 04:54:40 CET 2013)
[all classes][org.jomc.model]

COVERAGE SUMMARY FOR SOURCE FILE [ModelObject.java]

nameclass, %method, %block, %line, %
ModelObject.java100% (1/1)55%  (11/20)41%  (277/678)40%  (54.8/137)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ModelObject100% (1/1)55%  (11/20)41%  (277/678)40%  (54.8/137)
ModelObject (ModelObject): void 0%   (0/1)0%   (0/75)0%   (0/9)
getAnyElements (List, String, String): List 0%   (0/1)0%   (0/66)0%   (0/14)
getAnyElements (List, String, String, Class): List 0%   (0/1)0%   (0/84)0%   (0/17)
getAnyObjects (List, Class): List 0%   (0/1)0%   (0/55)0%   (0/13)
getAuthors (): Authors 0%   (0/1)0%   (0/3)0%   (0/1)
setAuthors (Authors): void 0%   (0/1)0%   (0/4)0%   (0/2)
setCreateDate (XMLGregorianCalendar): void 0%   (0/1)0%   (0/4)0%   (0/2)
setDeprecated (Boolean): void 0%   (0/1)0%   (0/4)0%   (0/2)
setModelVersion (String): void 0%   (0/1)0%   (0/4)0%   (0/2)
isDeprecated (): boolean 100% (1/1)56%  (5/9)67%  (2/3)
clone (): ModelObject 100% (1/1)64%  (49/77)65%  (5.8/9)
getAnyElement (List, String, String, Class): JAXBElement 100% (1/1)65%  (69/106)62%  (13/21)
getAnyObject (List, Class): Object 100% (1/1)77%  (54/70)75%  (12/16)
getAnyElement (List, String, String): JAXBElement 100% (1/1)80%  (67/84)75%  (12/16)
ModelObject (): void 100% (1/1)100% (3/3)100% (2/2)
getCreateDate (): XMLGregorianCalendar 100% (1/1)100% (3/3)100% (1/1)
getDocumentation (): Texts 100% (1/1)100% (3/3)100% (1/1)
getMessage (String, Object []): String 100% (1/1)100% (12/12)100% (1/1)
getModelVersion (): String 100% (1/1)100% (8/8)100% (3/3)
setDocumentation (Texts): void 100% (1/1)100% (4/4)100% (2/2)

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: 2013.01.03 at 05:01:35 AM CET 
6//
7 
8 
9package org.jomc.model;
10 
11import javax.annotation.Generated;
12import javax.xml.bind.annotation.XmlAccessType;
13import javax.xml.bind.annotation.XmlAccessorType;
14import javax.xml.bind.annotation.XmlAttribute;
15import javax.xml.bind.annotation.XmlElement;
16import javax.xml.bind.annotation.XmlSeeAlso;
17import javax.xml.bind.annotation.XmlType;
18import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
19import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
20import javax.xml.datatype.XMLGregorianCalendar;
21 
22 
23/**
24 * Base model object.
25 * 
26 * <p>Java class for ModelObject complex type.
27 * 
28 * <p>The following schema fragment specifies the expected content contained within this class.
29 * 
30 * <pre>
31 * &lt;complexType name="ModelObject">
32 *   &lt;complexContent>
33 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
34 *       &lt;sequence>
35 *         &lt;element ref="{http://jomc.org/model}documentation" minOccurs="0"/>
36 *         &lt;element ref="{http://jomc.org/model}authors" minOccurs="0"/>
37 *       &lt;/sequence>
38 *       &lt;attribute name="modelVersion" type="{http://jomc.org/model}Version" default="1.2" />
39 *       &lt;attribute name="createDate" type="{http://jomc.org/model}DateTime" />
40 *       &lt;attribute name="deprecated" type="{http://jomc.org/model}Flag" default="false" />
41 *     &lt;/restriction>
42 *   &lt;/complexContent>
43 * &lt;/complexType>
44 * </pre>
45 * 
46 * 
47 */
48@XmlAccessorType(XmlAccessType.FIELD)
49@XmlType(name = "ModelObject", namespace = "http://jomc.org/model", propOrder = {
50    "documentation",
51    "authors"
52})
53@XmlSeeAlso({
54    Argument.class,
55    Module.class,
56    Implementations.class,
57    Property.class,
58    Properties.class,
59    Instances.class,
60    Persons.class,
61    Messages.class,
62    Specifications.class,
63    Message.class,
64    Person.class,
65    Authors.class,
66    Arguments.class,
67    Dependencies.class,
68    Implementation.class,
69    Specification.class,
70    Instance.class,
71    Modules.class,
72    ImplementationReference.class,
73    SpecificationReference.class,
74    MessageReference.class,
75    PropertyReference.class
76})
77@Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
78public class ModelObject implements Cloneable
79{
80 
81    @XmlElement(namespace = "http://jomc.org/model")
82    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
83    protected Texts documentation;
84    @XmlElement(namespace = "http://jomc.org/model")
85    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
86    protected Authors authors;
87    @XmlAttribute(name = "modelVersion")
88    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
89    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
90    protected String modelVersion;
91    @XmlAttribute(name = "createDate")
92    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
93    protected XMLGregorianCalendar createDate;
94    @XmlAttribute(name = "deprecated")
95    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
96    protected Boolean deprecated;
97 
98    /**
99     * Creates a new {@code ModelObject} instance.
100     * 
101     */
102    public ModelObject() {
103        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
104        super();
105    }
106 
107    /**
108     * Creates a new {@code ModelObject} instance by deeply copying a given {@code ModelObject} instance.
109     * 
110     * 
111     * @param o
112     *     The instance to copy.
113     * @throws NullPointerException
114     *     if {@code o} is {@code null}.
115     */
116    public ModelObject(final ModelObject o) {
117        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
118        super();
119        if (o == null) {
120            throw new NullPointerException("Cannot create a copy of 'ModelObject' from 'null'.");
121        }
122        // CClassInfo: org.jomc.model.Texts
123        this.documentation = ((o.documentation == null)?null:((o.getDocumentation() == null)?null:o.getDocumentation().clone()));
124        // CClassInfo: org.jomc.model.Authors
125        this.authors = ((o.authors == null)?null:((o.getAuthors() == null)?null:o.getAuthors().clone()));
126        // CBuiltinLeafInfo: java.lang.String
127        this.modelVersion = ((o.modelVersion == null)?null:o.getModelVersion());
128        // CBuiltinLeafInfo: javax.xml.datatype.XMLGregorianCalendar
129        this.createDate = ((o.createDate == null)?null:((o.getCreateDate() == null)?null:((XMLGregorianCalendar) o.getCreateDate().clone())));
130        // CBuiltinLeafInfo: java.lang.Boolean
131        this.deprecated = ((o.deprecated == null)?null:o.isDeprecated());
132    }
133 
134    /**
135     * Documentation of this object or {@code null}.
136     * 
137     * @return
138     *     possible object is
139     *     {@link Texts }
140     *     
141     */
142    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
143    public Texts getDocumentation() {
144        return documentation;
145    }
146 
147    /**
148     * Sets the value of the documentation property.
149     * 
150     * @param value
151     *     allowed object is
152     *     {@link Texts }
153     *     
154     */
155    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
156    public void setDocumentation(Texts value) {
157        this.documentation = value;
158    }
159 
160    /**
161     * Authors of this object or {@code null}.
162     * 
163     * @return
164     *     possible object is
165     *     {@link Authors }
166     *     
167     */
168    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
169    public Authors getAuthors() {
170        return authors;
171    }
172 
173    /**
174     * Sets the value of the authors property.
175     * 
176     * @param value
177     *     allowed object is
178     *     {@link Authors }
179     *     
180     */
181    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
182    public void setAuthors(Authors value) {
183        this.authors = value;
184    }
185 
186    /**
187     * Model version of this object.
188     * 
189     * @return
190     *     possible object is
191     *     {@link String }
192     *     
193     */
194    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
195    public String getModelVersion() {
196        if (modelVersion == null) {
197            return "1.2";
198        } else {
199            return modelVersion;
200        }
201    }
202 
203    /**
204     * Sets the value of the modelVersion property.
205     * 
206     * @param value
207     *     allowed object is
208     *     {@link String }
209     *     
210     */
211    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
212    public void setModelVersion(String value) {
213        this.modelVersion = value;
214    }
215 
216    /**
217     * The date this object got created or {@code null}.
218     * 
219     * @return
220     *     possible object is
221     *     {@link XMLGregorianCalendar }
222     *     
223     */
224    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
225    public XMLGregorianCalendar getCreateDate() {
226        return createDate;
227    }
228 
229    /**
230     * Sets the value of the createDate property.
231     * 
232     * @param value
233     *     allowed object is
234     *     {@link XMLGregorianCalendar }
235     *     
236     */
237    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
238    public void setCreateDate(XMLGregorianCalendar value) {
239        this.createDate = value;
240    }
241 
242    /**
243     * {@code true}, if this object is deprecated.
244     * 
245     * @return
246     *     possible object is
247     *     {@link Boolean }
248     *     
249     */
250    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
251    public boolean isDeprecated() {
252        if (deprecated == null) {
253            return false;
254        } else {
255            return deprecated;
256        }
257    }
258 
259    /**
260     * Sets the value of the deprecated property.
261     * 
262     * @param value
263     *     allowed object is
264     *     {@link Boolean }
265     *     
266     */
267    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
268    public void setDeprecated(Boolean value) {
269        this.deprecated = value;
270    }
271 
272    /**
273     * Creates and returns a deep copy of this object.
274     * 
275     * 
276     * @return
277     *     A deep copy of this object.
278     */
279    @Override
280    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
281    public ModelObject clone() {
282        try {
283            {
284                // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
285                final ModelObject clone = ((ModelObject) super.clone());
286                // CClassInfo: org.jomc.model.Texts
287                clone.documentation = ((this.documentation == null)?null:((this.getDocumentation() == null)?null:this.getDocumentation().clone()));
288                // CClassInfo: org.jomc.model.Authors
289                clone.authors = ((this.authors == null)?null:((this.getAuthors() == null)?null:this.getAuthors().clone()));
290                // CBuiltinLeafInfo: java.lang.String
291                clone.modelVersion = ((this.modelVersion == null)?null:this.getModelVersion());
292                // CBuiltinLeafInfo: javax.xml.datatype.XMLGregorianCalendar
293                clone.createDate = ((this.createDate == null)?null:((this.getCreateDate() == null)?null:((XMLGregorianCalendar) this.getCreateDate().clone())));
294                // CBuiltinLeafInfo: java.lang.Boolean
295                clone.deprecated = ((this.deprecated == null)?null:this.isDeprecated());
296                return clone;
297            }
298        } catch (CloneNotSupportedException e) {
299            // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
300            throw new AssertionError(e);
301        }
302    }
303    
304    /** Public identifier of the object management and configuration model. */
305    public static final String MODEL_PUBLIC_ID = "http://jomc.org/model";
306 
307    /**
308     * Gets a single {@code JAXBElement} matching a namespace URI and local part from a given list of objects.
309     *
310     * @param any The list to search.
311     * @param namespaceURI The namespace URI of the {@code JAXBElement} to return.
312     * @param localPart The local part of the {@code JAXBElement} to return.
313     *
314     * @return The {@code JAXBElement} matching {@code namespaceURI} and {@code localPart} from the {@code any} list or
315     * {@code null} if no such element is found.
316     *
317     * @throws NullPointerException if {@code any}, {@code namespaceURI} or {@code localPart} is {@code null}.
318     * @throws IllegalStateException if {@code any} contains more than one matching element.
319     *
320     * @deprecated As of JOMC 1.1, please use method {@link #getAnyElement(java.util.List, java.lang.String, java.lang.String, java.lang.Class)}.
321     * This method will be removed in version 2.0.
322     */
323    @Deprecated
324    protected javax.xml.bind.JAXBElement getAnyElement( final java.util.List<Object> any, final String namespaceURI,
325                                                        final String localPart )
326    {
327        if ( any == null )
328        {
329            throw new NullPointerException( "any" );
330        }
331        if ( namespaceURI == null )
332        {
333            throw new NullPointerException( "namespaceURI" );
334        }
335        if ( localPart == null )
336        {
337            throw new NullPointerException( "localPart" );
338        }
339 
340        javax.xml.bind.JAXBElement<?> anyElement = null;
341 
342        for ( int i = 0, s0 = any.size(); i < s0; i++ )
343        {
344            final Object o = any.get( i );
345 
346            if ( o instanceof javax.xml.bind.JAXBElement<?> )
347            {
348                final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;
349 
350                if ( namespaceURI.equals( e.getName().getNamespaceURI() )
351                     && localPart.equals( e.getName().getLocalPart() ) )
352                {
353                    if ( anyElement == null )
354                    {
355                        anyElement = e;
356                    }
357                    else
358                    {
359                        throw new IllegalStateException( getMessage( "nonUniqueElement", this.getClass().getName(),
360                                                                     namespaceURI, localPart ) );
361 
362                    }
363                }
364            }
365        }
366 
367        return anyElement;
368    }
369 
370    /**
371     * Gets a list containing all {@code JAXBElement}s matching a namespace URI and local part from a given list of
372     * objects.
373     *
374     * @param any The list to search.
375     * @param namespaceURI The namespace URI of the {@code JAXBElement}s to return.
376     * @param localPart The local part of the {@code JAXBElement}s to return.
377     *
378     * @return An unmodifiable list of all {@code JAXBElement}s matching {@code namespaceURI} and {@code localPart} from
379     * the {@code any} list - an empty list if no such elements are found.
380     *
381     * @throws NullPointerException if {@code any}, {@code namespaceURI} or {@code localPart} is {@code null}.
382     *
383     * @deprecated As of JOMC 1.1, please use method {@link #getAnyElements(java.util.List, java.lang.String, java.lang.String, java.lang.Class)}.
384     * This method will be removed in version 2.0.
385     */
386    @Deprecated
387    protected java.util.List<javax.xml.bind.JAXBElement> getAnyElements( final java.util.List<Object> any,
388                                                                         final String namespaceURI,
389                                                                         final String localPart )
390    {
391        if ( any == null )
392        {
393            throw new NullPointerException( "any" );
394        }
395        if ( namespaceURI == null )
396        {
397            throw new NullPointerException( "namespaceURI" );
398        }
399        if ( localPart == null )
400        {
401            throw new NullPointerException( "localPart" );
402        }
403 
404        final java.util.List<javax.xml.bind.JAXBElement> anyElements =
405            new java.util.ArrayList<javax.xml.bind.JAXBElement>( any.size() );
406 
407        for ( int i = 0, s0 = any.size(); i < s0; i++ )
408        {
409            final Object o = any.get( i );
410 
411            if ( o instanceof javax.xml.bind.JAXBElement<?> )
412            {
413                final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;
414 
415                if ( namespaceURI.equals( e.getName().getNamespaceURI() )
416                     && localPart.equals( e.getName().getLocalPart() ) )
417                {
418                    anyElements.add( e );
419                }
420            }
421        }
422 
423        return java.util.Collections.unmodifiableList( anyElements );
424    }
425 
426    /**
427     * Gets a single {@code JAXBElement} matching a namespace URI and local part from a given list of objects.
428     *
429     * @param any The list to search.
430     * @param namespaceURI The namespace URI of the {@code JAXBElement} to return.
431     * @param localPart The local part of the {@code JAXBElement} to return.
432     * @param type The class of the type the element is bound to.
433     * @param <T> The type the element is bound to.
434     *
435     * @return The {@code JAXBElement} matching {@code namespaceURI} and {@code localPart} from the {@code any} list or
436     * {@code null} if no such element is found.
437     *
438     * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is
439     * {@code null}.
440     * @throws IllegalStateException if {@code any} contains more than one matching element.
441     *
442     * @since 1.1
443     */
444    protected <T> javax.xml.bind.JAXBElement<T> getAnyElement( final java.util.List<Object> any,
445                                                               final String namespaceURI,
446                                                               final String localPart,
447                                                               final Class<T> type )
448    {
449        if ( any == null )
450        {
451            throw new NullPointerException( "any" );
452        }
453        if ( namespaceURI == null )
454        {
455            throw new NullPointerException( "namespaceURI" );
456        }
457        if ( localPart == null )
458        {
459            throw new NullPointerException( "localPart" );
460        }
461        if ( type == null )
462        {
463            throw new NullPointerException( "type" );
464        }
465 
466        javax.xml.bind.JAXBElement<?> anyElement = null;
467 
468        for ( int i = 0, s0 = any.size(); i < s0; i++ )
469        {
470            final Object o = any.get( i );
471 
472            if ( o instanceof javax.xml.bind.JAXBElement<?> )
473            {
474                final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;
475 
476                if ( namespaceURI.equals( e.getName().getNamespaceURI() )
477                     && localPart.equals( e.getName().getLocalPart() ) )
478                {
479                    if ( anyElement == null )
480                    {
481                        anyElement = e;
482                    }
483                    else
484                    {
485                        throw new IllegalStateException( getMessage( "nonUniqueElement", this.getClass().getName(),
486                                                                     namespaceURI, localPart ) );
487 
488                    }
489                }
490            }
491        }
492 
493        if ( anyElement != null && anyElement.getValue() != null && anyElement.getValue().getClass().equals( type ) )
494        {
495            @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> e =
496                (javax.xml.bind.JAXBElement<T>) anyElement;
497 
498            return e;
499        }
500 
501        return null;
502    }
503 
504    /**
505     * Gets a list containing all {@code JAXBElement}s matching a namespace URI and local part from a given list of
506     * objects.
507     *
508     * @param any The list to search.
509     * @param namespaceURI The namespace URI of the {@code JAXBElement}s to return.
510     * @param localPart The local part of the {@code JAXBElement}s to return.
511     * @param type The class of the type the elements are bound to.
512     * @param <T> The type the elements are bound to.
513     *
514     * @return An unmodifiable list of all {@code JAXBElement}s matching {@code namespaceURI} and {@code localPart} from
515     * the {@code any} list - an empty list if no such elements are found.
516     *
517     * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is
518     * {@code null}.
519     *
520     * @since 1.1
521     */
522    protected <T> java.util.List<javax.xml.bind.JAXBElement<T>> getAnyElements( final java.util.List<Object> any,
523                                                                                final String namespaceURI,
524                                                                                final String localPart,
525                                                                                final Class<T> type )
526    {
527        if ( any == null )
528        {
529            throw new NullPointerException( "any" );
530        }
531        if ( namespaceURI == null )
532        {
533            throw new NullPointerException( "namespaceURI" );
534        }
535        if ( localPart == null )
536        {
537            throw new NullPointerException( "localPart" );
538        }
539        if ( type == null )
540        {
541            throw new NullPointerException( "type" );
542        }
543 
544        final java.util.List<javax.xml.bind.JAXBElement<T>> anyElements =
545            new java.util.ArrayList<javax.xml.bind.JAXBElement<T>>( any.size() );
546 
547        for ( int i = 0, s0 = any.size(); i < s0; i++ )
548        {
549            final Object o = any.get( i );
550 
551            if ( o instanceof javax.xml.bind.JAXBElement<?> )
552            {
553                final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o;
554 
555                if ( namespaceURI.equals( e.getName().getNamespaceURI() )
556                     && localPart.equals( e.getName().getLocalPart() )
557                     && e.getValue() != null && e.getValue().getClass().equals( type ) )
558                {
559                    @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> anyElement =
560                        (javax.xml.bind.JAXBElement<T>) e;
561 
562                    anyElements.add( anyElement );
563                }
564            }
565        }
566 
567        return java.util.Collections.unmodifiableList( anyElements );
568    }
569 
570    /**
571     * Gets a single object matching a class from a given list of objects.
572     *
573     * @param any The list to search.
574     * @param clazz The class to return an instance of.
575     * @param <T> The type of the object to return.
576     *
577     * @return The instance of {@code clazz} from the {@code any} list or {@code null}, if no such instance is found.
578     *
579     * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}.
580     * @throws IllegalStateException if {@code any} contains more than one matching object.
581     */
582    protected <T> T getAnyObject( final java.util.List<Object> any, final Class<T> clazz )
583    {
584        if ( any == null )
585        {
586            throw new NullPointerException( "any" );
587        }
588        if ( clazz == null )
589        {
590            throw new NullPointerException( "clazz" );
591        }
592 
593        T anyObject = null;
594 
595        for ( int i = 0, s0 = any.size(); i < s0; i++ )
596        {
597            Object o = any.get( i );
598 
599            if ( o instanceof javax.xml.bind.JAXBElement<?> )
600            {
601                o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue();
602            }
603 
604            if ( clazz.equals( o.getClass() ) )
605            {
606                if ( anyObject == null )
607                {
608                    @SuppressWarnings( "unchecked" ) final T object = (T) o;
609                    anyObject = object;
610                }
611                else
612                {
613                    throw new IllegalStateException( getMessage( "nonUniqueObject", this.getClass().getName(),
614                                                                 clazz.getName() ) );
615 
616                }
617            }
618        }
619 
620        return anyObject;
621    }
622 
623    /**
624     * Gets a list containing all objects matching a class from a given list of objects.
625     *
626     * @param any The list to search.
627     * @param clazz The class to return all instances of.
628     * @param <T> The type of the objects to return.
629     *
630     * @return An unmodifiable list of all instances of {@code clazz} from the {@code any} list - an empty list if no
631     * such objects are found.
632     *
633     * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}.
634     */
635    protected <T> java.util.List<T> getAnyObjects( final java.util.List<Object> any, final Class<T> clazz )
636    {
637        if ( any == null )
638        {
639            throw new NullPointerException( "any" );
640        }
641        if ( clazz == null )
642        {
643            throw new NullPointerException( "namespaceURI" );
644        }
645 
646        final java.util.List<T> anyElements = new java.util.ArrayList<T>( any.size() );
647 
648        for ( int i = 0, s0 = any.size(); i < s0; i++ )
649        {
650            Object o = any.get( i );
651 
652            if ( o instanceof javax.xml.bind.JAXBElement<?> )
653            {
654                o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue();
655            }
656 
657            if ( clazz.equals( o.getClass() ) )
658            {
659                @SuppressWarnings( "unchecked" ) final T object = (T) o;
660                anyElements.add( object );
661            }
662        }
663 
664        return java.util.Collections.unmodifiableList( anyElements );
665    }
666 
667    private static String getMessage( final String key, final Object... args )
668    {
669        return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle(
670            ModelObject.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ).
671            getString( key ), args );
672 
673    }
674      
675}

[all classes][org.jomc.model]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov