1 | // |
2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2 |
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: 2013.04.22 at 06:38:01 AM CEST |
6 | // |
7 | |
8 | |
9 | package org.jomc.modlet; |
10 | |
11 | import javax.annotation.Generated; |
12 | import javax.xml.bind.annotation.XmlAccessType; |
13 | import javax.xml.bind.annotation.XmlAccessorType; |
14 | import javax.xml.bind.annotation.XmlSeeAlso; |
15 | import javax.xml.bind.annotation.XmlType; |
16 | |
17 | |
18 | /** |
19 | * Base modlet object. |
20 | * |
21 | * <p>Java class for ModletObject complex type. |
22 | * |
23 | * <p>The following schema fragment specifies the expected content contained within this class. |
24 | * |
25 | * <pre> |
26 | * <complexType name="ModletObject"> |
27 | * <complexContent> |
28 | * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
29 | * </restriction> |
30 | * </complexContent> |
31 | * </complexType> |
32 | * </pre> |
33 | * |
34 | * |
35 | */ |
36 | @XmlAccessorType(XmlAccessType.FIELD) |
37 | @XmlType(name = "ModletObject", namespace = "http://jomc.org/modlet") |
38 | @XmlSeeAlso({ |
39 | Schema.class, |
40 | Services.class, |
41 | Schemas.class, |
42 | Model.class, |
43 | Modlets.class, |
44 | Modlet.class, |
45 | Service.class, |
46 | Property.class |
47 | }) |
48 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-22T06:38:01+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
49 | public class ModletObject implements Cloneable |
50 | { |
51 | |
52 | |
53 | /** |
54 | * Creates a new {@code ModletObject} instance. |
55 | * |
56 | */ |
57 | public ModletObject() { |
58 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
59 | super(); |
60 | } |
61 | |
62 | /** |
63 | * Creates a new {@code ModletObject} instance by deeply copying a given {@code ModletObject} instance. |
64 | * |
65 | * |
66 | * @param o |
67 | * The instance to copy. |
68 | * @throws NullPointerException |
69 | * if {@code o} is {@code null}. |
70 | */ |
71 | public ModletObject(final ModletObject o) { |
72 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
73 | super(); |
74 | if (o == null) { |
75 | throw new NullPointerException("Cannot create a copy of 'ModletObject' from 'null'."); |
76 | } |
77 | } |
78 | |
79 | /** |
80 | * Creates and returns a deep copy of this object. |
81 | * |
82 | * |
83 | * @return |
84 | * A deep copy of this object. |
85 | */ |
86 | @Override |
87 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-04-22T06:38:01+02:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
88 | public ModletObject clone() { |
89 | try { |
90 | { |
91 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
92 | final ModletObject clone = ((ModletObject) super.clone()); |
93 | return clone; |
94 | } |
95 | } catch (CloneNotSupportedException e) { |
96 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
97 | throw new AssertionError(e); |
98 | } |
99 | } |
100 | |
101 | /** Public identifier of the modlet model. */ |
102 | public static final String MODEL_PUBLIC_ID = "http://jomc.org/modlet"; |
103 | |
104 | /** |
105 | * Public identifier of the modlet schema. |
106 | * @since 1.2 |
107 | */ |
108 | public static final java.net.URI PUBLIC_ID; |
109 | |
110 | static |
111 | { |
112 | try |
113 | { |
114 | PUBLIC_ID = new java.net.URI( MODEL_PUBLIC_ID ); |
115 | } |
116 | catch ( final java.net.URISyntaxException e ) |
117 | { |
118 | throw new AssertionError( e ); |
119 | } |
120 | } |
121 | |
122 | /** |
123 | * Gets a single {@code JAXBElement} matching a namespace URI and local part from a given list of objects. |
124 | * |
125 | * @param any The list to search. |
126 | * @param namespaceURI The namespace URI of the {@code JAXBElement} to return. |
127 | * @param localPart The local part of the {@code JAXBElement} to return. |
128 | * |
129 | * @return The {@code JAXBElement} matching {@code namespaceURI} and {@code localPart} from the {@code any} list or |
130 | * {@code null} if no such element is found. |
131 | * |
132 | * @throws NullPointerException if {@code any}, {@code namespaceURI} or {@code localPart} is {@code null}. |
133 | * @throws IllegalStateException if {@code any} contains more than one matching element. |
134 | * |
135 | * @deprecated As of JOMC 1.1, please use method {@link #getAnyElement(java.util.List, java.lang.String, java.lang.String, java.lang.Class)}. |
136 | * This method will be removed in version 2.0. |
137 | */ |
138 | @Deprecated |
139 | protected javax.xml.bind.JAXBElement getAnyElement( final java.util.List<Object> any, final String namespaceURI, |
140 | final String localPart ) |
141 | { |
142 | if ( any == null ) |
143 | { |
144 | throw new NullPointerException( "any" ); |
145 | } |
146 | if ( namespaceURI == null ) |
147 | { |
148 | throw new NullPointerException( "namespaceURI" ); |
149 | } |
150 | if ( localPart == null ) |
151 | { |
152 | throw new NullPointerException( "localPart" ); |
153 | } |
154 | |
155 | javax.xml.bind.JAXBElement<?> anyElement = null; |
156 | |
157 | for ( int i = 0, s0 = any.size(); i < s0; i++ ) |
158 | { |
159 | final Object o = any.get( i ); |
160 | |
161 | if ( o instanceof javax.xml.bind.JAXBElement<?> ) |
162 | { |
163 | final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o; |
164 | |
165 | if ( namespaceURI.equals( e.getName().getNamespaceURI() ) |
166 | && localPart.equals( e.getName().getLocalPart() ) ) |
167 | { |
168 | if ( anyElement == null ) |
169 | { |
170 | anyElement = e; |
171 | } |
172 | else |
173 | { |
174 | throw new IllegalStateException( getMessage( "nonUniqueElement", this.getClass().getName(), |
175 | namespaceURI, localPart ) ); |
176 | |
177 | } |
178 | } |
179 | } |
180 | } |
181 | |
182 | return anyElement; |
183 | } |
184 | |
185 | /** |
186 | * Gets a list containing all {@code JAXBElement}s matching a namespace URI and local part from a given list of |
187 | * objects. |
188 | * |
189 | * @param any The list to search. |
190 | * @param namespaceURI The namespace URI of the {@code JAXBElement}s to return. |
191 | * @param localPart The local part of the {@code JAXBElement}s to return. |
192 | * |
193 | * @return An unmodifiable list of all {@code JAXBElement}s matching {@code namespaceURI} and {@code localPart} from |
194 | * the {@code any} list - an empty list if no such elements are found. |
195 | * |
196 | * @throws NullPointerException if {@code any}, {@code namespaceURI} or {@code localPart} is {@code null}. |
197 | * |
198 | * @deprecated As of JOMC 1.1, please use method {@link #getAnyElements(java.util.List, java.lang.String, java.lang.String, java.lang.Class)}. |
199 | * This method will be removed in version 2.0. |
200 | */ |
201 | @Deprecated |
202 | protected java.util.List<javax.xml.bind.JAXBElement> getAnyElements( final java.util.List<Object> any, |
203 | final String namespaceURI, |
204 | final String localPart ) |
205 | { |
206 | if ( any == null ) |
207 | { |
208 | throw new NullPointerException( "any" ); |
209 | } |
210 | if ( namespaceURI == null ) |
211 | { |
212 | throw new NullPointerException( "namespaceURI" ); |
213 | } |
214 | if ( localPart == null ) |
215 | { |
216 | throw new NullPointerException( "localPart" ); |
217 | } |
218 | |
219 | final java.util.List<javax.xml.bind.JAXBElement> anyElements = |
220 | new java.util.ArrayList<javax.xml.bind.JAXBElement>( any.size() ); |
221 | |
222 | for ( int i = 0, s0 = any.size(); i < s0; i++ ) |
223 | { |
224 | final Object o = any.get( i ); |
225 | |
226 | if ( o instanceof javax.xml.bind.JAXBElement<?> ) |
227 | { |
228 | final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o; |
229 | |
230 | if ( namespaceURI.equals( e.getName().getNamespaceURI() ) |
231 | && localPart.equals( e.getName().getLocalPart() ) ) |
232 | { |
233 | anyElements.add( e ); |
234 | } |
235 | } |
236 | } |
237 | |
238 | return java.util.Collections.unmodifiableList( anyElements ); |
239 | } |
240 | |
241 | /** |
242 | * Gets a single {@code JAXBElement} matching a namespace URI and local part from a given list of objects. |
243 | * |
244 | * @param any The list to search. |
245 | * @param namespaceURI The namespace URI of the {@code JAXBElement} to return. |
246 | * @param localPart The local part of the {@code JAXBElement} to return. |
247 | * @param type The class of the type the element is bound to. |
248 | * @param <T> The type the element is bound to. |
249 | * |
250 | * @return The {@code JAXBElement} matching {@code namespaceURI} and {@code localPart} from the {@code any} list or |
251 | * {@code null} if no such element is found. |
252 | * |
253 | * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is |
254 | * {@code null}. |
255 | * @throws IllegalStateException if {@code any} contains more than one matching element. |
256 | * |
257 | * @since 1.1 |
258 | */ |
259 | protected <T> javax.xml.bind.JAXBElement<T> getAnyElement( final java.util.List<Object> any, |
260 | final String namespaceURI, |
261 | final String localPart, |
262 | final Class<T> type ) |
263 | { |
264 | if ( any == null ) |
265 | { |
266 | throw new NullPointerException( "any" ); |
267 | } |
268 | if ( namespaceURI == null ) |
269 | { |
270 | throw new NullPointerException( "namespaceURI" ); |
271 | } |
272 | if ( localPart == null ) |
273 | { |
274 | throw new NullPointerException( "localPart" ); |
275 | } |
276 | if ( type == null ) |
277 | { |
278 | throw new NullPointerException( "type" ); |
279 | } |
280 | |
281 | javax.xml.bind.JAXBElement<?> anyElement = null; |
282 | |
283 | for ( int i = 0, s0 = any.size(); i < s0; i++ ) |
284 | { |
285 | final Object o = any.get( i ); |
286 | |
287 | if ( o instanceof javax.xml.bind.JAXBElement<?> ) |
288 | { |
289 | final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o; |
290 | |
291 | if ( namespaceURI.equals( e.getName().getNamespaceURI() ) |
292 | && localPart.equals( e.getName().getLocalPart() ) ) |
293 | { |
294 | if ( anyElement == null ) |
295 | { |
296 | anyElement = e; |
297 | } |
298 | else |
299 | { |
300 | throw new IllegalStateException( getMessage( "nonUniqueElement", this.getClass().getName(), |
301 | namespaceURI, localPart ) ); |
302 | |
303 | } |
304 | } |
305 | } |
306 | } |
307 | |
308 | if ( anyElement != null && anyElement.getValue() != null && anyElement.getValue().getClass().equals( type ) ) |
309 | { |
310 | @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> e = |
311 | (javax.xml.bind.JAXBElement<T>) anyElement; |
312 | |
313 | return e; |
314 | } |
315 | |
316 | return null; |
317 | } |
318 | |
319 | /** |
320 | * Gets a list containing all {@code JAXBElement}s matching a namespace URI and local part from a given list of |
321 | * objects. |
322 | * |
323 | * @param any The list to search. |
324 | * @param namespaceURI The namespace URI of the {@code JAXBElement}s to return. |
325 | * @param localPart The local part of the {@code JAXBElement}s to return. |
326 | * @param type The class of the type the elements are bound to. |
327 | * @param <T> The type the elements are bound to. |
328 | * |
329 | * @return An unmodifiable list of all {@code JAXBElement}s matching {@code namespaceURI} and {@code localPart} from |
330 | * the {@code any} list - an empty list if no such elements are found. |
331 | * |
332 | * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is |
333 | * {@code null}. |
334 | * |
335 | * @since 1.1 |
336 | */ |
337 | protected <T> java.util.List<javax.xml.bind.JAXBElement<T>> getAnyElements( final java.util.List<Object> any, |
338 | final String namespaceURI, |
339 | final String localPart, |
340 | final Class<T> type ) |
341 | { |
342 | if ( any == null ) |
343 | { |
344 | throw new NullPointerException( "any" ); |
345 | } |
346 | if ( namespaceURI == null ) |
347 | { |
348 | throw new NullPointerException( "namespaceURI" ); |
349 | } |
350 | if ( localPart == null ) |
351 | { |
352 | throw new NullPointerException( "localPart" ); |
353 | } |
354 | if ( type == null ) |
355 | { |
356 | throw new NullPointerException( "type" ); |
357 | } |
358 | |
359 | final java.util.List<javax.xml.bind.JAXBElement<T>> anyElements = |
360 | new java.util.ArrayList<javax.xml.bind.JAXBElement<T>>( any.size() ); |
361 | |
362 | for ( int i = 0, s0 = any.size(); i < s0; i++ ) |
363 | { |
364 | final Object o = any.get( i ); |
365 | |
366 | if ( o instanceof javax.xml.bind.JAXBElement<?> ) |
367 | { |
368 | final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o; |
369 | |
370 | if ( namespaceURI.equals( e.getName().getNamespaceURI() ) |
371 | && localPart.equals( e.getName().getLocalPart() ) |
372 | && e.getValue() != null && e.getValue().getClass().equals( type ) ) |
373 | { |
374 | @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> anyElement = |
375 | (javax.xml.bind.JAXBElement<T>) e; |
376 | |
377 | anyElements.add( anyElement ); |
378 | } |
379 | } |
380 | } |
381 | |
382 | return java.util.Collections.unmodifiableList( anyElements ); |
383 | } |
384 | |
385 | /** |
386 | * Gets a single object matching a class from a given list of objects. |
387 | * |
388 | * @param any The list to search. |
389 | * @param clazz The class to return an instance of. |
390 | * @param <T> The type of the object to return. |
391 | * |
392 | * @return The instance of {@code clazz} from the {@code any} list or {@code null}, if no such instance is found. |
393 | * |
394 | * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}. |
395 | * @throws IllegalStateException if {@code any} contains more than one matching object. |
396 | */ |
397 | protected <T> T getAnyObject( final java.util.List<Object> any, final Class<T> clazz ) |
398 | { |
399 | if ( any == null ) |
400 | { |
401 | throw new NullPointerException( "any" ); |
402 | } |
403 | if ( clazz == null ) |
404 | { |
405 | throw new NullPointerException( "clazz" ); |
406 | } |
407 | |
408 | T anyObject = null; |
409 | |
410 | for ( int i = 0, s0 = any.size(); i < s0; i++ ) |
411 | { |
412 | Object o = any.get( i ); |
413 | |
414 | if ( o instanceof javax.xml.bind.JAXBElement<?> ) |
415 | { |
416 | o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue(); |
417 | } |
418 | |
419 | if ( clazz.equals( o.getClass() ) ) |
420 | { |
421 | if ( anyObject == null ) |
422 | { |
423 | @SuppressWarnings( "unchecked" ) final T object = (T) o; |
424 | anyObject = object; |
425 | } |
426 | else |
427 | { |
428 | throw new IllegalStateException( getMessage( "nonUniqueObject", this.getClass().getName(), |
429 | clazz.getName() ) ); |
430 | |
431 | } |
432 | } |
433 | } |
434 | |
435 | return anyObject; |
436 | } |
437 | |
438 | /** |
439 | * Gets a list containing all objects matching a class from a given list of objects. |
440 | * |
441 | * @param any The list to search. |
442 | * @param clazz The class to return all instances of. |
443 | * @param <T> The type of the objects to return. |
444 | * |
445 | * @return An unmodifiable list of all instances of {@code clazz} from the {@code any} list - an empty list if no |
446 | * such objects are found. |
447 | * |
448 | * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}. |
449 | */ |
450 | protected <T> java.util.List<T> getAnyObjects( final java.util.List<Object> any, final Class<T> clazz ) |
451 | { |
452 | if ( any == null ) |
453 | { |
454 | throw new NullPointerException( "any" ); |
455 | } |
456 | if ( clazz == null ) |
457 | { |
458 | throw new NullPointerException( "namespaceURI" ); |
459 | } |
460 | |
461 | final java.util.List<T> anyElements = new java.util.ArrayList<T>( any.size() ); |
462 | |
463 | for ( int i = 0, s0 = any.size(); i < s0; i++ ) |
464 | { |
465 | Object o = any.get( i ); |
466 | |
467 | if ( o instanceof javax.xml.bind.JAXBElement<?> ) |
468 | { |
469 | o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue(); |
470 | } |
471 | |
472 | if ( clazz.equals( o.getClass() ) ) |
473 | { |
474 | @SuppressWarnings( "unchecked" ) final T object = (T) o; |
475 | anyElements.add( object ); |
476 | } |
477 | } |
478 | |
479 | return java.util.Collections.unmodifiableList( anyElements ); |
480 | } |
481 | |
482 | private static String getMessage( final String key, final Object... args ) |
483 | { |
484 | return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( |
485 | ModletObject.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ). |
486 | getString( key ), args ); |
487 | |
488 | } |
489 | |
490 | } |