1
2
3
4
5
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 @XmlAccessorType(XmlAccessType.FIELD)
47 @XmlType(name = "Texts", namespace = "http://jomc.org/model", propOrder = {
48 "text"
49 })
50 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
51 public class Texts implements Cloneable
52 {
53
54 @XmlElement(namespace = "http://jomc.org/model", required = true)
55 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
56 protected List<Text> text;
57 @XmlAttribute(name = "defaultLanguage", required = true)
58 @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
59 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
60 protected String defaultLanguage;
61
62
63
64
65
66 public Texts() {
67
68 super();
69 }
70
71
72
73
74
75
76
77
78
79
80 public Texts(final Texts o) {
81
82 super();
83 if (o == null) {
84 throw new NullPointerException("Cannot create a copy of 'Texts' from 'null'.");
85 }
86
87 if (o.text!= null) {
88 copyText(o.getText(), this.getText());
89 }
90
91 this.defaultLanguage = ((o.defaultLanguage == null)?null:o.getDefaultLanguage());
92 }
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01: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
126
127
128
129
130
131
132 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
133 public String getDefaultLanguage() {
134 return defaultLanguage;
135 }
136
137
138
139
140
141
142
143
144
145 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
146 public void setDefaultLanguage(String value) {
147 this.defaultLanguage = value;
148 }
149
150
151
152
153
154
155
156
157
158
159
160 @SuppressWarnings("unchecked")
161 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
162 private static void copyText(final List<Text> source, final List<Text> target) {
163
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
169 target.add(((Text) next).clone());
170 continue;
171 }
172
173 throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Text' of class 'org.jomc.model.Texts'."));
174 }
175 }
176 }
177
178
179
180
181
182
183
184
185 @Override
186 @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-03T05:01:35+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
187 public Texts clone() {
188 try {
189 {
190
191 final Texts clone = ((Texts) super.clone());
192
193 if (this.text!= null) {
194 clone.text = null;
195 copyText(this.getText(), clone.getText());
196 }
197
198 clone.defaultLanguage = ((this.defaultLanguage == null)?null:this.getDefaultLanguage());
199 return clone;
200 }
201 } catch (CloneNotSupportedException e) {
202
203 throw new AssertionError(e);
204 }
205 }
206
207
208
209
210
211
212
213
214
215
216
217
218
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().equalsIgnoreCase( this.getDefaultLanguage() ) )
234 {
235 defaultText = t;
236 }
237 if ( t.getLanguage().equalsIgnoreCase( language ) )
238 {
239 return t;
240 }
241 }
242
243 return defaultText;
244 }
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261 public Text getText( final java.util.Locale locale )
262 {
263 if ( locale == null )
264 {
265 throw new NullPointerException( "locale" );
266 }
267
268 Text defaultText = null;
269
270 for ( int i = 0, s0 = this.getText().size(); i < s0; i++ )
271 {
272 final Text t = this.getText().get( i );
273
274 if ( t.getLanguage().equalsIgnoreCase( this.getDefaultLanguage() ) )
275 {
276 defaultText = t;
277 }
278 if ( t.getLanguage().equalsIgnoreCase( locale.getLanguage() ) )
279 {
280 return t;
281 }
282 }
283
284 return defaultText;
285 }
286
287 }