1 | // |
2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 |
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: 2010.02.03 at 01:25:12 AM UTC |
6 | // |
7 | |
8 | |
9 | package org.jomc.model; |
10 | |
11 | import java.util.ArrayList; |
12 | import java.util.Iterator; |
13 | import java.util.List; |
14 | import javax.annotation.Generated; |
15 | import javax.xml.bind.annotation.XmlAccessType; |
16 | import javax.xml.bind.annotation.XmlAccessorType; |
17 | import javax.xml.bind.annotation.XmlAttribute; |
18 | import javax.xml.bind.annotation.XmlElement; |
19 | import javax.xml.bind.annotation.XmlType; |
20 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; |
21 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
22 | |
23 | |
24 | /** |
25 | * List of texts. |
26 | * |
27 | * <p>Java class for Texts complex type. |
28 | * |
29 | * <p>The following schema fragment specifies the expected content contained within this class. |
30 | * |
31 | * <pre> |
32 | * <complexType name="Texts"> |
33 | * <complexContent> |
34 | * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
35 | * <sequence> |
36 | * <element ref="{http://jomc.org/model}text" maxOccurs="unbounded"/> |
37 | * </sequence> |
38 | * <attribute name="defaultLanguage" use="required" type="{http://jomc.org/model}Language" /> |
39 | * </restriction> |
40 | * </complexContent> |
41 | * </complexType> |
42 | * </pre> |
43 | * |
44 | * |
45 | */ |
46 | @XmlAccessorType(XmlAccessType.FIELD) |
47 | @XmlType(name = "Texts", propOrder = { |
48 | "text" |
49 | }) |
50 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
51 | public class Texts implements Cloneable |
52 | { |
53 | |
54 | @XmlElement(required = true) |
55 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
56 | protected List<Text> text; |
57 | @XmlAttribute(required = true) |
58 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) |
59 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
60 | protected String defaultLanguage; |
61 | |
62 | /** |
63 | * Creates a new {@code Texts} instance. |
64 | * |
65 | */ |
66 | public Texts() { |
67 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
68 | super(); |
69 | } |
70 | |
71 | /** |
72 | * Creates a new {@code Texts} instance by deeply copying a given {@code Texts} instance. |
73 | * |
74 | * |
75 | * @param o |
76 | * The instance to copy. |
77 | * @throws NullPointerException |
78 | * if {@code o} is {@code null}. |
79 | */ |
80 | public Texts(final Texts o) { |
81 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
82 | super(); |
83 | if (o == null) { |
84 | throw new NullPointerException("Cannot create a copy of 'Texts' from 'null'."); |
85 | } |
86 | // 'Text' collection. |
87 | copyText(o.getText(), getText()); |
88 | // CBuiltinLeafInfo: java.lang.String |
89 | this.defaultLanguage = o.getDefaultLanguage(); |
90 | } |
91 | |
92 | /** |
93 | * Gets the value of the text property. |
94 | * |
95 | * <p> |
96 | * This accessor method returns a reference to the live list, |
97 | * not a snapshot. Therefore any modification you make to the |
98 | * returned list will be present inside the JAXB object. |
99 | * This is why there is not a <CODE>set</CODE> method for the text property. |
100 | * |
101 | * <p> |
102 | * For example, to add a new item, do as follows: |
103 | * <pre> |
104 | * getText().add(newItem); |
105 | * </pre> |
106 | * |
107 | * |
108 | * <p> |
109 | * Objects of the following type(s) are allowed in the list |
110 | * {@link Text } |
111 | * |
112 | * |
113 | */ |
114 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
115 | public List<Text> getText() { |
116 | if (text == null) { |
117 | text = new ArrayList<Text>(); |
118 | } |
119 | return this.text; |
120 | } |
121 | |
122 | /** |
123 | * Default text of this list. |
124 | * |
125 | * @return |
126 | * possible object is |
127 | * {@link String } |
128 | * |
129 | */ |
130 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
131 | public String getDefaultLanguage() { |
132 | return defaultLanguage; |
133 | } |
134 | |
135 | /** |
136 | * Sets the value of the defaultLanguage property. |
137 | * |
138 | * @param value |
139 | * allowed object is |
140 | * {@link String } |
141 | * |
142 | */ |
143 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
144 | public void setDefaultLanguage(String value) { |
145 | this.defaultLanguage = value; |
146 | } |
147 | |
148 | /** |
149 | * Copies all values of property {@code Text} deeply. |
150 | * |
151 | * @param target |
152 | * The target to copy {@code source} to. |
153 | * @param source |
154 | * The source to copy from. |
155 | * @throws NullPointerException |
156 | * if {@code source} or {@code target} is {@code null}. |
157 | */ |
158 | @SuppressWarnings("unchecked") |
159 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
160 | private static void copyText(final List<Text> source, final List<Text> target) { |
161 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
162 | if (!source.isEmpty()) { |
163 | for (Iterator it = source.iterator(); it.hasNext(); ) { |
164 | final Object next = it.next(); |
165 | if (next instanceof Text) { |
166 | // CClassInfo: org.jomc.model.Text |
167 | target.add(((Text) next).clone()); |
168 | continue; |
169 | } |
170 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
171 | throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Text' of class 'org.jomc.model.Texts'.")); |
172 | } |
173 | } |
174 | } |
175 | |
176 | /** |
177 | * Creates and returns a deep copy of this object. |
178 | * |
179 | * |
180 | * @return |
181 | * A deep copy of this object. |
182 | */ |
183 | @Override |
184 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2010-02-03T01:25:12+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") |
185 | public Texts clone() { |
186 | // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 |
187 | return new Texts(this); |
188 | } |
189 | |
190 | /** |
191 | * Gets a text for a given language. |
192 | * |
193 | * @param language The language of the text to return. |
194 | * |
195 | * @return The text with language {@code language} or the default text, if |
196 | * no text matching {@code language} is found. |
197 | * |
198 | * @throws NullPointerException if {@code language} is {@code null}. |
199 | */ |
200 | public Text getText( final String language ) |
201 | { |
202 | if ( language == null ) |
203 | { |
204 | throw new NullPointerException( "language" ); |
205 | } |
206 | |
207 | Text defaultText = null; |
208 | |
209 | for ( Text t : this.getText() ) |
210 | { |
211 | if ( t.getLanguage().equals( this.getDefaultLanguage() ) ) |
212 | { |
213 | defaultText = t; |
214 | } |
215 | if ( t.getLanguage().equals( language ) ) |
216 | { |
217 | return t; |
218 | } |
219 | } |
220 | |
221 | return defaultText; |
222 | } |
223 | |
224 | |
225 | } |