001    //
002    // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 
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: 2009.10.04 at 12:50:46 AM UTC 
006    //
007    
008    
009    package org.jomc.model;
010    
011    import java.util.ArrayList;
012    import java.util.Iterator;
013    import java.util.List;
014    import javax.annotation.Generated;
015    import javax.xml.bind.annotation.XmlAccessType;
016    import javax.xml.bind.annotation.XmlAccessorType;
017    import javax.xml.bind.annotation.XmlType;
018    
019    
020    /**
021     * List of messages.
022     * @see Message
023     * 
024     * 
025     * 
026     */
027    @XmlAccessorType(XmlAccessType.FIELD)
028    @XmlType(name = "Messages", propOrder = {
029        "message",
030        "reference"
031    })
032    @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-10-04T12:50:46+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
033    public class Messages
034        extends ModelObject
035        implements Cloneable
036    {
037    
038        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-10-04T12:50:46+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
039        protected List<Message> message;
040        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-10-04T12:50:46+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
041        protected List<MessageReference> reference;
042    
043        /**
044         * Creates a new {@code Messages} instance.
045         * 
046         */
047        public Messages() {
048             // CC-XJC Version 1.0 Build 2009-09-18T15:48:40+0000
049            super();
050        }
051    
052        /**
053         * Creates a new {@code Messages} instance by deeply copying a given instance.
054         * 
055         * @param o
056         *     The instance to copy or {@code null}.
057         */
058        public Messages(final Messages o) {
059             // CC-XJC Version 1.0 Build 2009-09-18T15:48:40+0000
060            super(o);
061            if (o!= null) {
062                {
063                    // 'Message' collection.
064                    copyMessage(o.getMessage(), getMessage());
065                    // 'Reference' collection.
066                    copyReference(o.getReference(), getReference());
067                }
068            }
069        }
070    
071        /**
072         * Gets the value of the message property.
073         * 
074         * <p>
075         * This accessor method returns a reference to the live list,
076         * not a snapshot. Therefore any modification you make to the
077         * returned list will be present inside the JAXB object.
078         * This is why there is not a <CODE>set</CODE> method for the message property.
079         * 
080         * <p>
081         * For example, to add a new item, do as follows:
082         * <pre>
083         *    getMessage().add(newItem);
084         * </pre>
085         * 
086         * 
087         * <p>
088         * Objects of the following type(s) are allowed in the list
089         * {@link Message }
090         * 
091         * 
092         */
093        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-10-04T12:50:46+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
094        public List<Message> getMessage() {
095            if (message == null) {
096                message = new ArrayList<Message>();
097            }
098            return this.message;
099        }
100    
101        /**
102         * Gets the value of the reference property.
103         * 
104         * <p>
105         * This accessor method returns a reference to the live list,
106         * not a snapshot. Therefore any modification you make to the
107         * returned list will be present inside the JAXB object.
108         * This is why there is not a <CODE>set</CODE> method for the reference property.
109         * 
110         * <p>
111         * For example, to add a new item, do as follows:
112         * <pre>
113         *    getReference().add(newItem);
114         * </pre>
115         * 
116         * 
117         * <p>
118         * Objects of the following type(s) are allowed in the list
119         * {@link MessageReference }
120         * 
121         * 
122         */
123        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-10-04T12:50:46+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
124        public List<MessageReference> getReference() {
125            if (reference == null) {
126                reference = new ArrayList<MessageReference>();
127            }
128            return this.reference;
129        }
130    
131        /**
132         * Copies all values of property {@code Message} deeply.
133         * 
134         * @param target
135         *     The target to copy {@code source} to.
136         * @param source
137         *     The source to copy from.
138         * @throws NullPointerException
139         *     if {@code source} or {@code target} is {@code null}.
140         */
141        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-10-04T12:50:46+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
142        private static void copyMessage(final List<Message> source, final List<Message> target) {
143            // CC-XJC Version 1.0 Build 2009-09-18T15:48:40+0000
144            if (!source.isEmpty()) {
145                for (Iterator it = source.iterator(); it.hasNext(); ) {
146                    final Object next = it.next();
147                    if (next instanceof Message) {
148                        // CClassInfo: org.jomc.model.Message
149                        target.add(((Message) next).clone());
150                        continue;
151                    }
152                    // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
153                    throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Message' of class 'org.jomc.model.Messages'."));
154                }
155            }
156        }
157    
158        /**
159         * Copies all values of property {@code Reference} deeply.
160         * 
161         * @param target
162         *     The target to copy {@code source} to.
163         * @param source
164         *     The source to copy from.
165         * @throws NullPointerException
166         *     if {@code source} or {@code target} is {@code null}.
167         */
168        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-10-04T12:50:46+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
169        private static void copyReference(final List<MessageReference> source, final List<MessageReference> target) {
170            // CC-XJC Version 1.0 Build 2009-09-18T15:48:40+0000
171            if (!source.isEmpty()) {
172                for (Iterator it = source.iterator(); it.hasNext(); ) {
173                    final Object next = it.next();
174                    if (next instanceof MessageReference) {
175                        // CClassInfo: org.jomc.model.MessageReference
176                        target.add(((MessageReference) next).clone());
177                        continue;
178                    }
179                    // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
180                    throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Reference' of class 'org.jomc.model.Messages'."));
181                }
182            }
183        }
184    
185        /**
186         * Creates and returns a deep copy of this object.
187         * 
188         * 
189         * @return
190         *     A deep copy of this object.
191         */
192        @Override
193        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-10-04T12:50:46+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
194        public Messages clone() {
195             // CC-XJC Version 1.0 Build 2009-09-18T15:48:40+0000
196            return new Messages(this);
197        }
198        
199        /**
200         * Gets a message for a given name from the list of messages.
201         *
202         * @param name The name of the message to return.
203         *
204         * @return The message with name {@code name} from the list or {@code null},
205         * if no message matching {@code name} is found.
206         *
207         * @throws NullPointerException if {@code name} is {@code null}.
208         *
209         * @see #getMessage()
210         */
211        public Message getMessage( final String name )
212        {
213            if ( name == null )
214            {
215                throw new NullPointerException( "name" );
216            }
217    
218            for ( Message m : this.getMessage() )
219            {
220                if ( name.equals( m.getName() ) )
221                {
222                    return m;
223                }
224            }
225    
226            return null;
227        }
228    
229        /**
230         * Gets a message reference for a given name from the list of references.
231         *
232         * @param name The name of the message reference to return.
233         *
234         * @return The message reference with name {@code name} from the list or
235         * {@code null}, if no message reference matching {@code name} is found.
236         *
237         * @throws NullPointerException if {@code name} is {@code null}.
238         *
239         * @see #getReference()
240         */
241        public MessageReference getReference( final String name )
242        {
243            if ( name == null )
244            {
245                throw new NullPointerException( "name" );
246            }
247    
248            for ( MessageReference r : this.getReference() )
249            {
250                if ( name.equals( r.getName() ) )
251                {
252                    return r;
253                }
254            }
255    
256            return null;
257        }
258    
259          
260    }