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.11.18 at 06:28:36 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.XmlAttribute;
018    import javax.xml.bind.annotation.XmlElement;
019    import javax.xml.bind.annotation.XmlSchemaType;
020    import javax.xml.bind.annotation.XmlType;
021    import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
022    import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
023    
024    
025    /**
026     * List of texts.
027     * @see Text
028     * 
029     * 
030     * 
031     */
032    @XmlAccessorType(XmlAccessType.FIELD)
033    @XmlType(name = "Texts", propOrder = {
034        "text"
035    })
036    @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-11-18T06:28:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
037    public class Texts implements Cloneable
038    {
039    
040        @XmlElement(required = true)
041        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-11-18T06:28:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
042        protected List<Text> text;
043        @XmlAttribute(required = true)
044        @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
045        @XmlSchemaType(name = "language")
046        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-11-18T06:28:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
047        protected String defaultLanguage;
048    
049        /**
050         * Creates a new {@code Texts} instance.
051         * 
052         */
053        public Texts() {
054            // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000
055            super();
056        }
057    
058        /**
059         * Creates a new {@code Texts} instance by deeply copying a given {@code Texts} instance.
060         * 
061         * 
062         * @param o
063         *     The instance to copy.
064         * @throws NullPointerException
065         *     if {@code o} is {@code null}.
066         */
067        public Texts(final Texts o) {
068            // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000
069            super();
070            if (o == null) {
071                throw new NullPointerException("Cannot create a copy of 'Texts' from 'null'.");
072            }
073            // 'Text' collection.
074            copyText(o.getText(), getText());
075            // CBuiltinLeafInfo: java.lang.String
076            this.defaultLanguage = o.getDefaultLanguage();
077        }
078    
079        /**
080         * Gets the value of the text property.
081         * 
082         * <p>
083         * This accessor method returns a reference to the live list,
084         * not a snapshot. Therefore any modification you make to the
085         * returned list will be present inside the JAXB object.
086         * This is why there is not a <CODE>set</CODE> method for the text property.
087         * 
088         * <p>
089         * For example, to add a new item, do as follows:
090         * <pre>
091         *    getText().add(newItem);
092         * </pre>
093         * 
094         * 
095         * <p>
096         * Objects of the following type(s) are allowed in the list
097         * {@link Text }
098         * 
099         * 
100         */
101        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-11-18T06:28:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
102        public List<Text> getText() {
103            if (text == null) {
104                text = new ArrayList<Text>();
105            }
106            return this.text;
107        }
108    
109        /**
110         * Default text of this list.
111         * 
112         * @return
113         *     possible object is
114         *     {@link String }
115         *     
116         */
117        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-11-18T06:28:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
118        public String getDefaultLanguage() {
119            return defaultLanguage;
120        }
121    
122        /**
123         * Sets the value of the defaultLanguage property.
124         * 
125         * @param value
126         *     allowed object is
127         *     {@link String }
128         *     
129         */
130        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-11-18T06:28:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
131        public void setDefaultLanguage(String value) {
132            this.defaultLanguage = value;
133        }
134    
135        /**
136         * Copies all values of property {@code Text} deeply.
137         * 
138         * @param target
139         *     The target to copy {@code source} to.
140         * @param source
141         *     The source to copy from.
142         * @throws NullPointerException
143         *     if {@code source} or {@code target} is {@code null}.
144         */
145        @SuppressWarnings("unchecked")
146        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-11-18T06:28:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
147        private static void copyText(final List<Text> source, final List<Text> target) {
148            // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000
149            if (!source.isEmpty()) {
150                for (Iterator it = source.iterator(); it.hasNext(); ) {
151                    final Object next = it.next();
152                    if (next instanceof Text) {
153                        // CClassInfo: org.jomc.model.Text
154                        target.add(((Text) next).clone());
155                        continue;
156                    }
157                    // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
158                    throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Text' of class 'org.jomc.model.Texts'."));
159                }
160            }
161        }
162    
163        /**
164         * Creates and returns a deep copy of this object.
165         * 
166         * 
167         * @return
168         *     A deep copy of this object.
169         */
170        @Override
171        @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-11-18T06:28:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833")
172        public Texts clone() {
173            // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000
174            return new Texts(this);
175        }
176        
177        /**
178         * Gets a text for a given language.
179         *
180         * @param language The language of the text to return.
181         *
182         * @return The text with language {@code language} or the default text, if
183         * no text matching {@code language} is found.
184         *
185         * @throws NullPointerException if {@code language} is {@code null}.
186         */
187        public Text getText( final String language )
188        {
189            if ( language == null )
190            {
191                throw new NullPointerException( "language" );
192            }
193    
194            Text defaultText = null;
195    
196            for ( Text t : this.getText() )
197            {
198                if ( t.getLanguage().equals( this.getDefaultLanguage() ) )
199                {
200                    defaultText = t;
201                }
202                if ( t.getLanguage().equals( language ) )
203                {
204                    return t;
205                }
206            }
207    
208            return defaultText;
209        }
210    
211          
212    }