001 //
002 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
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: 2012.04.26 at 04:53:34 AM CEST
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.XmlType;
020 import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
021 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
022
023
024 /**
025 * List of texts.
026 *
027 * <p>Java class for Texts complex type.
028 *
029 * <p>The following schema fragment specifies the expected content contained within this class.
030 *
031 * <pre>
032 * <complexType name="Texts">
033 * <complexContent>
034 * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
035 * <sequence>
036 * <element ref="{http://jomc.org/model}text" maxOccurs="unbounded"/>
037 * </sequence>
038 * <attribute name="defaultLanguage" use="required" type="{http://jomc.org/model}Language" />
039 * </restriction>
040 * </complexContent>
041 * </complexType>
042 * </pre>
043 *
044 *
045 */
046 @XmlAccessorType(XmlAccessType.FIELD)
047 @XmlType(name = "Texts", namespace = "http://jomc.org/model", propOrder = {
048 "text"
049 })
050 @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-04-26T04:53:34+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
051 public class Texts implements Cloneable
052 {
053
054 @XmlElement(namespace = "http://jomc.org/model", required = true)
055 @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-04-26T04:53:34+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
056 protected List<Text> text;
057 @XmlAttribute(name = "defaultLanguage", required = true)
058 @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
059 @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-04-26T04:53:34+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
060 protected String defaultLanguage;
061
062 /**
063 * Creates a new {@code Texts} instance.
064 *
065 */
066 public Texts() {
067 // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000
068 super();
069 }
070
071 /**
072 * Creates a new {@code Texts} instance by deeply copying a given {@code Texts} instance.
073 *
074 *
075 * @param o
076 * The instance to copy.
077 * @throws NullPointerException
078 * if {@code o} is {@code null}.
079 */
080 public Texts(final Texts o) {
081 // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000
082 super();
083 if (o == null) {
084 throw new NullPointerException("Cannot create a copy of 'Texts' from 'null'.");
085 }
086 // 'Text' collection.
087 if (o.text!= null) {
088 copyText(o.getText(), this.getText());
089 }
090 // CBuiltinLeafInfo: java.lang.String
091 this.defaultLanguage = ((o.defaultLanguage == null)?null:o.getDefaultLanguage());
092 }
093
094 /**
095 * Gets the value of the text property.
096 *
097 * <p>
098 * This accessor method returns a reference to the live list,
099 * not a snapshot. Therefore any modification you make to the
100 * returned list will be present inside the JAXB object.
101 * This is why there is not a <CODE>set</CODE> method for the text property.
102 *
103 * <p>
104 * For example, to add a new item, do as follows:
105 * <pre>
106 * getText().add(newItem);
107 * </pre>
108 *
109 *
110 * <p>
111 * Objects of the following type(s) are allowed in the list
112 * {@link Text }
113 *
114 *
115 */
116 @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-04-26T04:53:34+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
117 public List<Text> getText() {
118 if (text == null) {
119 text = new ArrayList<Text>();
120 }
121 return this.text;
122 }
123
124 /**
125 * Default text of this list.
126 *
127 * @return
128 * possible object is
129 * {@link String }
130 *
131 */
132 @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-04-26T04:53:34+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
133 public String getDefaultLanguage() {
134 return defaultLanguage;
135 }
136
137 /**
138 * Sets the value of the defaultLanguage property.
139 *
140 * @param value
141 * allowed object is
142 * {@link String }
143 *
144 */
145 @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-04-26T04:53:34+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
146 public void setDefaultLanguage(String value) {
147 this.defaultLanguage = value;
148 }
149
150 /**
151 * Copies all values of property {@code Text} deeply.
152 *
153 * @param source
154 * The source to copy from.
155 * @param target
156 * The target to copy {@code source} to.
157 * @throws NullPointerException
158 * if {@code target} is {@code null}.
159 */
160 @SuppressWarnings("unchecked")
161 @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-04-26T04:53:34+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
162 private static void copyText(final List<Text> source, final List<Text> target) {
163 // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000
164 if ((source!= null)&&(!source.isEmpty())) {
165 for (final Iterator<?> it = source.iterator(); it.hasNext(); ) {
166 final Object next = it.next();
167 if (next instanceof Text) {
168 // CClassInfo: org.jomc.model.Text
169 target.add(((Text) next).clone());
170 continue;
171 }
172 // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
173 throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Text' of class 'org.jomc.model.Texts'."));
174 }
175 }
176 }
177
178 /**
179 * Creates and returns a deep copy of this object.
180 *
181 *
182 * @return
183 * A deep copy of this object.
184 */
185 @Override
186 @Generated(value = "com.sun.tools.xjc.Driver", date = "2012-04-26T04:53:34+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
187 public Texts clone() {
188 try {
189 {
190 // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000
191 final Texts clone = ((Texts) super.clone());
192 // 'Text' collection.
193 if (this.text!= null) {
194 clone.text = null;
195 copyText(this.getText(), clone.getText());
196 }
197 // CBuiltinLeafInfo: java.lang.String
198 clone.defaultLanguage = ((this.defaultLanguage == null)?null:this.getDefaultLanguage());
199 return clone;
200 }
201 } catch (CloneNotSupportedException e) {
202 // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
203 throw new AssertionError(e);
204 }
205 }
206
207 /**
208 * Gets a text for a given language from the list of texts.
209 *
210 * @param language The language of the text to return.
211 *
212 * @return The first matching text or the default text, if no such text is found.
213 *
214 * @throws NullPointerException if {@code language} is {@code null}.
215 *
216 * @see #getText()
217 * @see #getDefaultLanguage()
218 * @see Text#getLanguage()
219 */
220 public Text getText( final String language )
221 {
222 if ( language == null )
223 {
224 throw new NullPointerException( "language" );
225 }
226
227 Text defaultText = null;
228
229 for ( int i = 0, s0 = this.getText().size(); i < s0; i++ )
230 {
231 final Text t = this.getText().get( i );
232
233 if ( t.getLanguage().equals( this.getDefaultLanguage() ) )
234 {
235 defaultText = t;
236 }
237 if ( t.getLanguage().equals( language ) )
238 {
239 return t;
240 }
241 }
242
243 return defaultText;
244 }
245
246 }