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

COVERAGE SUMMARY FOR SOURCE FILE [Modlets.java]

nameclass, %method, %block, %line, %
Modlets.java100% (1/1)64%  (7/11)48%  (236/494)40%  (37/92)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Modlets100% (1/1)64%  (7/11)48%  (236/494)40%  (37/92)
Modlets (Modlets): void 0%   (0/1)0%   (0/19)0%   (0/6)
clone (): Modlets 0%   (0/1)0%   (0/17)0%   (0/5)
copyModlet (List, List): void 0%   (0/1)0%   (0/39)0%   (0/8)
getMergedModlet (String, String): Modlet 0%   (0/1)0%   (0/163)0%   (0/32)
getModlet (String): Modlet 100% (1/1)85%  (28/33)86%  (6/7)
getSchemas (URI): Schemas 100% (1/1)89%  (42/47)88%  (7/8)
getSchemas (String): Schemas 100% (1/1)93%  (70/75)90%  (9/10)
getServices (String): Services 100% (1/1)93%  (70/75)90%  (9/10)
Modlets (): void 100% (1/1)100% (3/3)100% (2/2)
getMessage (String, Object []): String 100% (1/1)100% (12/12)100% (1/1)
getModlet (): List 100% (1/1)100% (11/11)100% (3/3)

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 04:56:19 AM CET 
6//
7 
8 
9package org.jomc.modlet;
10 
11import java.util.ArrayList;
12import java.util.Iterator;
13import java.util.List;
14import javax.annotation.Generated;
15import javax.xml.bind.annotation.XmlAccessType;
16import javax.xml.bind.annotation.XmlAccessorType;
17import javax.xml.bind.annotation.XmlElement;
18import javax.xml.bind.annotation.XmlType;
19 
20 
21/**
22 * List of modlets.
23 * 
24 * <p>Java class for Modlets complex type.
25 * 
26 * <p>The following schema fragment specifies the expected content contained within this class.
27 * 
28 * <pre>
29 * &lt;complexType name="Modlets">
30 *   &lt;complexContent>
31 *     &lt;extension base="{http://jomc.org/modlet}ModletObject">
32 *       &lt;sequence>
33 *         &lt;element ref="{http://jomc.org/modlet}modlet" maxOccurs="unbounded" minOccurs="0"/>
34 *       &lt;/sequence>
35 *     &lt;/extension>
36 *   &lt;/complexContent>
37 * &lt;/complexType>
38 * </pre>
39 * 
40 * 
41 */
42@XmlAccessorType(XmlAccessType.FIELD)
43@XmlType(name = "Modlets", namespace = "http://jomc.org/modlet", propOrder = {
44    "modlet"
45})
46@Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T04:56:19+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
47public class Modlets
48    extends ModletObject
49    implements Cloneable
50{
51 
52    @XmlElement(namespace = "http://jomc.org/modlet")
53    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T04:56:19+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
54    protected List<Modlet> modlet;
55 
56    /**
57     * Creates a new {@code Modlets} instance.
58     * 
59     */
60    public Modlets() {
61        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
62        super();
63    }
64 
65    /**
66     * Creates a new {@code Modlets} instance by deeply copying a given {@code Modlets} instance.
67     * 
68     * 
69     * @param o
70     *     The instance to copy.
71     * @throws NullPointerException
72     *     if {@code o} is {@code null}.
73     */
74    public Modlets(final Modlets o) {
75        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
76        super(o);
77        if (o == null) {
78            throw new NullPointerException("Cannot create a copy of 'Modlets' from 'null'.");
79        }
80        // 'Modlet' collection.
81        if (o.modlet!= null) {
82            copyModlet(o.getModlet(), this.getModlet());
83        }
84    }
85 
86    /**
87     * Gets the value of the modlet property.
88     * 
89     * <p>
90     * This accessor method returns a reference to the live list,
91     * not a snapshot. Therefore any modification you make to the
92     * returned list will be present inside the JAXB object.
93     * This is why there is not a <CODE>set</CODE> method for the modlet property.
94     * 
95     * <p>
96     * For example, to add a new item, do as follows:
97     * <pre>
98     *    getModlet().add(newItem);
99     * </pre>
100     * 
101     * 
102     * <p>
103     * Objects of the following type(s) are allowed in the list
104     * {@link Modlet }
105     * 
106     * 
107     */
108    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T04:56:19+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
109    public List<Modlet> getModlet() {
110        if (modlet == null) {
111            modlet = new ArrayList<Modlet>();
112        }
113        return this.modlet;
114    }
115 
116    /**
117     * Copies all values of property {@code Modlet} deeply.
118     * 
119     * @param source
120     *     The source to copy from.
121     * @param target
122     *     The target to copy {@code source} to.
123     * @throws NullPointerException
124     *     if {@code target} is {@code null}.
125     */
126    @SuppressWarnings("unchecked")
127    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T04:56:19+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
128    private static void copyModlet(final List<Modlet> source, final List<Modlet> target) {
129        // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
130        if ((source!= null)&&(!source.isEmpty())) {
131            for (final Iterator<?> it = source.iterator(); it.hasNext(); ) {
132                final Object next = it.next();
133                if (next instanceof Modlet) {
134                    // CClassInfo: org.jomc.modlet.Modlet
135                    target.add(((Modlet) next).clone());
136                    continue;
137                }
138                // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
139                throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Modlet' of class 'org.jomc.modlet.Modlets'."));
140            }
141        }
142    }
143 
144    /**
145     * Creates and returns a deep copy of this object.
146     * 
147     * 
148     * @return
149     *     A deep copy of this object.
150     */
151    @Override
152    @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T04:56:19+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
153    public Modlets clone() {
154        {
155            // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
156            final Modlets clone = ((Modlets) super.clone());
157            // 'Modlet' collection.
158            if (this.modlet!= null) {
159                clone.modlet = null;
160                copyModlet(this.getModlet(), clone.getModlet());
161            }
162            return clone;
163        }
164    }
165    
166    /**
167     * Gets a modlet for a given name from the list of modlets.
168     *
169     * @param name The name of the modlet to return.
170     *
171     * @return The first matching modlet or {@code null}, if no such modlet is found.
172     *
173     * @throws NullPointerException if {@code name} is {@code null}.
174     *
175     * @see #getModlet()
176     * @see Modlet#getName()
177     */
178    public Modlet getModlet( final String name )
179    {
180        if ( name == null )
181        {
182            throw new NullPointerException( "name" );
183        }
184 
185        for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ )
186        {
187            final Modlet m = this.getModlet().get( i );
188 
189            if ( name.equals( m.getName() ) )
190            {
191                return m;
192            }
193        }
194 
195        return null;
196    }
197 
198    /**
199     * Merges modlets of a model from this list of modlets to a single modlet.
200     *
201     * @param name The name of the modlet to return.
202     * @param model The identifier of the model of the modlet to return.
203     *
204     * @return A modlet holding all modlet objects of the model identified by {@code model} from the list.
205     *
206     * @throws NullPointerException if {@code name} or {@code model} is {@code null}.
207     *
208     * @see #getModlet()
209     * @see Modlet#getModel()
210     */
211    public Modlet getMergedModlet( final String name, final String model )
212    {
213        if ( name == null )
214        {
215            throw new NullPointerException( "name" );
216        }
217        if ( model == null )
218        {
219            throw new NullPointerException( "model" );
220        }
221 
222        final Modlet mergedModlet = new Modlet();
223        mergedModlet.setName( name );
224        mergedModlet.setModel( model );
225 
226        for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ )
227        {
228            final Modlet m = this.getModlet().get( i );
229 
230            if ( model.equals( m.getModel() ) )
231            {
232                if ( m.getSchemas() != null )
233                {
234                    if ( mergedModlet.getSchemas() == null )
235                    {
236                        mergedModlet.setSchemas( new Schemas() );
237                    }
238 
239                    for ( int j = 0, s1 = m.getSchemas().getSchema().size(); j < s1; j++ )
240                    {
241                        final Schema s = m.getSchemas().getSchema().get( j );
242 
243                        if ( mergedModlet.getSchemas().getSchemaBySystemId( s.getSystemId() ) == null )
244                        {
245                            mergedModlet.getSchemas().getSchema().add( s );
246                        }
247                    }
248                }
249 
250                if ( m.getServices() != null )
251                {
252                    if ( mergedModlet.getServices() == null )
253                    {
254                        mergedModlet.setServices( new Services() );
255                    }
256 
257                    for ( int j = 0, s1 = m.getServices().getService().size(); j < s1; j++ )
258                    {
259                        final Service s = m.getServices().getService().get( j );
260                        boolean merged = false;
261 
262                        for ( Service mergedService : mergedModlet.getServices().getServices( s.getIdentifier() ) )
263                        {
264                            if ( mergedService.getClazz().equals( s.getClazz() ) )
265                            {
266                                if ( mergedService.getOrdinal() < s.getOrdinal() )
267                                {
268                                    mergedService.setOrdinal( s.getOrdinal() );
269                                }
270 
271                                merged = true;
272                            }
273                        }
274 
275                        if ( !merged )
276                        {
277                            mergedModlet.getServices().getService().add( s );
278                        }
279                    }
280                }
281            }
282        }
283 
284        return mergedModlet;
285    }
286 
287    /**
288     * Gets schemas for a model from this list of modlets.
289     *
290     * @param model The identifier of the model to return schemas of.
291     *
292     * @return A list of schemas for {@code model} or {@code null}, if no such schemas are found.
293     *
294     * @throws NullPointerException if {@code model} is {@code null}.
295     *
296     * @see #getModlet()
297     * @see Modlet#getModel()
298     */
299    public Schemas getSchemas( final String model )
300    {
301        if ( model == null )
302        {
303            throw new NullPointerException( "model" );
304        }
305 
306        final Schemas schemas = new Schemas();
307        final String projectName = getMessage( "projectName" );
308 
309        for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ )
310        {
311            final Modlet m = this.getModlet().get( i );
312 
313            if ( m.getSchemas() != null && ( m.getName().equals( projectName ) || model.equals( m.getModel() ) ) )
314            {
315                for ( int j = 0, s1 = m.getSchemas().getSchema().size(); j < s1; j++ )
316                {
317                    schemas.getSchema().add( m.getSchemas().getSchema().get( j ) );
318                }
319            }
320        }
321 
322        return schemas.getSchema().isEmpty() ? null : schemas;
323    }
324 
325    /**
326     * Gets schemas for a public identifier from this list of modlets.
327     *
328     * @param publicId The public identifier of the schemas to return.
329     *
330     * @return A list of schemas matching {@code publicId} or {@code null}, if no such schemas are found.
331     *
332     * @throws NullPointerException if {@code publicId} is {@code null}.
333     *
334     * @see #getModlet()
335     * @see Modlet#getSchemas()
336     * @see Schemas#getSchemasByPublicId(java.net.URI)
337     * @since 1.2
338     */
339    public Schemas getSchemas( final java.net.URI publicId )
340    {
341        if ( publicId == null )
342        {
343            throw new NullPointerException( "publicId" );
344        }
345 
346        final Schemas schemas = new Schemas();
347 
348        for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ )
349        {
350            final Modlet m = this.getModlet().get( i );
351 
352            if ( m.getSchemas() != null )
353            {
354                schemas.getSchema().addAll( m.getSchemas().getSchemasByPublicId( publicId ) );
355            }
356        }
357 
358        return schemas.getSchema().isEmpty() ? null : schemas;
359    }
360 
361    /**
362     * Gets services for a model from this list of modlets.
363     *
364     * @param model The identifier of the model to return services of.
365     *
366     * @return A list of services for {@code model} or {@code null}, if no such services are found.
367     *
368     * @throws NullPointerException if {@code model} is {@code null}.
369     *
370     * @see #getModlet()
371     * @see Modlet#getModel()
372     */
373    public Services getServices( final String model )
374    {
375        if ( model == null )
376        {
377            throw new NullPointerException( "model" );
378        }
379 
380        final Services services = new Services();
381        final String projectName = getMessage( "projectName" );
382 
383        for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ )
384        {
385            final Modlet m = this.getModlet().get( i );
386 
387            if ( m.getServices() != null && ( m.getName().equals( projectName ) || model.equals( m.getModel() ) ) )
388            {
389                for ( int j = 0, s1 = m.getServices().getService().size(); j < s1; j++ )
390                {
391                    services.getService().add( m.getServices().getService().get( j ) );
392                }
393            }
394        }
395 
396        return services.getService().isEmpty() ? null : services;
397    }
398 
399    private static String getMessage( final String key, final Object... args )
400    {
401        return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle(
402            ModelContext.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ).getString( key ), args );
403 
404    }
405      
406}

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