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