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: 2016.11.01 at 03:08:56 AM CET 006// 007 008 009package org.jomc.modlet; 010 011import javax.annotation.Generated; 012import javax.xml.bind.annotation.XmlAccessType; 013import javax.xml.bind.annotation.XmlAccessorType; 014import javax.xml.bind.annotation.XmlSeeAlso; 015import javax.xml.bind.annotation.XmlType; 016 017 018/** 019 * Base modlet object. 020 * 021 * <p>Java class for ModletObject complex type. 022 * 023 * <p>The following schema fragment specifies the expected content contained within this class. 024 * 025 * <pre> 026 * <complexType name="ModletObject"> 027 * <complexContent> 028 * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> 029 * </restriction> 030 * </complexContent> 031 * </complexType> 032 * </pre> 033 * 034 * 035 */ 036@XmlAccessorType(XmlAccessType.FIELD) 037@XmlType(name = "ModletObject", namespace = "http://jomc.org/modlet") 038@XmlSeeAlso({ 039 Schema.class, 040 Services.class, 041 Schemas.class, 042 Model.class, 043 Modlets.class, 044 Modlet.class, 045 Service.class, 046 Property.class 047}) 048@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-11-01T03:08:56+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") 049public class ModletObject implements Cloneable 050{ 051 052 053 /** 054 * Creates a new {@code ModletObject} instance. 055 * 056 */ 057 public ModletObject() { 058 // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 059 super(); 060 } 061 062 /** 063 * Creates a new {@code ModletObject} instance by deeply copying a given {@code ModletObject} instance. 064 * 065 * 066 * @param o 067 * The instance to copy. 068 * @throws NullPointerException 069 * if {@code o} is {@code null}. 070 */ 071 public ModletObject(final ModletObject o) { 072 // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 073 super(); 074 if (o == null) { 075 throw new NullPointerException("Cannot create a copy of 'ModletObject' from 'null'."); 076 } 077 } 078 079 /** 080 * Creates and returns a deep copy of this object. 081 * 082 * 083 * @return 084 * A deep copy of this object. 085 */ 086 @Override 087 @Generated(value = "com.sun.tools.xjc.Driver", date = "2016-11-01T03:08:56+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") 088 public ModletObject clone() { 089 try { 090 { 091 // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 092 final ModletObject clone = ((ModletObject) super.clone()); 093 return clone; 094 } 095 } catch (CloneNotSupportedException e) { 096 // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ 097 throw new AssertionError(e); 098 } 099 } 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 * @deprecated As of JOMC 1.8, removed without replacement. 108 */ 109 @Deprecated 110 public static final java.net.URI PUBLIC_ID; 111 112 static 113 { 114 try 115 { 116 PUBLIC_ID = new java.net.URI( MODEL_PUBLIC_ID ); 117 } 118 catch ( final java.net.URISyntaxException e ) 119 { 120 throw new AssertionError( e ); 121 } 122 } 123 124 /** 125 * Gets a single {@code JAXBElement} matching a namespace URI and local part from a given list of objects. 126 * 127 * @param any The list to search. 128 * @param namespaceURI The namespace URI of the {@code JAXBElement} to return. 129 * @param localPart The local part of the {@code JAXBElement} to return. 130 * 131 * @return The {@code JAXBElement} matching {@code namespaceURI} and {@code localPart} from the {@code any} list or 132 * {@code null} if no such element is found. 133 * 134 * @throws NullPointerException if {@code any}, {@code namespaceURI} or {@code localPart} is {@code null}. 135 * @throws IllegalStateException if {@code any} contains more than one matching element. 136 * 137 * @deprecated As of JOMC 1.1, please use method {@link #getAnyElement(java.util.List, java.lang.String, java.lang.String, java.lang.Class)}. 138 * This method will be removed in version 2.0. 139 */ 140 @Deprecated 141 protected javax.xml.bind.JAXBElement getAnyElement( final java.util.List<Object> any, final String namespaceURI, 142 final String localPart ) 143 { 144 if ( any == null ) 145 { 146 throw new NullPointerException( "any" ); 147 } 148 if ( namespaceURI == null ) 149 { 150 throw new NullPointerException( "namespaceURI" ); 151 } 152 if ( localPart == null ) 153 { 154 throw new NullPointerException( "localPart" ); 155 } 156 157 javax.xml.bind.JAXBElement<?> anyElement = null; 158 159 for ( int i = 0, s0 = any.size(); i < s0; i++ ) 160 { 161 final Object o = any.get( i ); 162 163 if ( o instanceof javax.xml.bind.JAXBElement<?> ) 164 { 165 final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o; 166 167 if ( namespaceURI.equals( e.getName().getNamespaceURI() ) 168 && localPart.equals( e.getName().getLocalPart() ) ) 169 { 170 if ( anyElement == null ) 171 { 172 anyElement = e; 173 } 174 else 175 { 176 throw new IllegalStateException( getMessage( "nonUniqueElement", this.getClass().getName(), 177 namespaceURI, localPart ) ); 178 179 } 180 } 181 } 182 } 183 184 return anyElement; 185 } 186 187 /** 188 * Gets a list containing all {@code JAXBElement}s matching a namespace URI and local part from a given list of 189 * objects. 190 * 191 * @param any The list to search. 192 * @param namespaceURI The namespace URI of the {@code JAXBElement}s to return. 193 * @param localPart The local part of the {@code JAXBElement}s to return. 194 * 195 * @return An unmodifiable list of all {@code JAXBElement}s matching {@code namespaceURI} and {@code localPart} from 196 * the {@code any} list - an empty list if no such elements are found. 197 * 198 * @throws NullPointerException if {@code any}, {@code namespaceURI} or {@code localPart} is {@code null}. 199 * 200 * @deprecated As of JOMC 1.1, please use method {@link #getAnyElements(java.util.List, java.lang.String, java.lang.String, java.lang.Class)}. 201 * This method will be removed in version 2.0. 202 */ 203 @Deprecated 204 protected java.util.List<javax.xml.bind.JAXBElement> getAnyElements( final java.util.List<Object> any, 205 final String namespaceURI, 206 final String localPart ) 207 { 208 if ( any == null ) 209 { 210 throw new NullPointerException( "any" ); 211 } 212 if ( namespaceURI == null ) 213 { 214 throw new NullPointerException( "namespaceURI" ); 215 } 216 if ( localPart == null ) 217 { 218 throw new NullPointerException( "localPart" ); 219 } 220 221 final java.util.List<javax.xml.bind.JAXBElement> anyElements = 222 new java.util.ArrayList<javax.xml.bind.JAXBElement>( any.size() ); 223 224 for ( int i = 0, s0 = any.size(); i < s0; i++ ) 225 { 226 final Object o = any.get( i ); 227 228 if ( o instanceof javax.xml.bind.JAXBElement<?> ) 229 { 230 final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o; 231 232 if ( namespaceURI.equals( e.getName().getNamespaceURI() ) 233 && localPart.equals( e.getName().getLocalPart() ) ) 234 { 235 anyElements.add( e ); 236 } 237 } 238 } 239 240 return java.util.Collections.unmodifiableList( anyElements ); 241 } 242 243 /** 244 * Gets a single {@code JAXBElement} matching a namespace URI and local part from a given list of objects. 245 * 246 * @param any The list to search. 247 * @param namespaceURI The namespace URI of the {@code JAXBElement} to return. 248 * @param localPart The local part of the {@code JAXBElement} to return. 249 * @param type The class of the type the element is bound to. 250 * @param <T> The type the element is bound to. 251 * 252 * @return The {@code JAXBElement} matching {@code namespaceURI} and {@code localPart} from the {@code any} list or 253 * {@code null} if no such element is found. 254 * 255 * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is 256 * {@code null}. 257 * @throws IllegalStateException if {@code any} contains more than one matching element. 258 * 259 * @since 1.1 260 */ 261 protected <T> javax.xml.bind.JAXBElement<T> getAnyElement( final java.util.List<Object> any, 262 final String namespaceURI, 263 final String localPart, 264 final Class<T> type ) 265 { 266 if ( any == null ) 267 { 268 throw new NullPointerException( "any" ); 269 } 270 if ( namespaceURI == null ) 271 { 272 throw new NullPointerException( "namespaceURI" ); 273 } 274 if ( localPart == null ) 275 { 276 throw new NullPointerException( "localPart" ); 277 } 278 if ( type == null ) 279 { 280 throw new NullPointerException( "type" ); 281 } 282 283 javax.xml.bind.JAXBElement<?> anyElement = null; 284 285 for ( int i = 0, s0 = any.size(); i < s0; i++ ) 286 { 287 final Object o = any.get( i ); 288 289 if ( o instanceof javax.xml.bind.JAXBElement<?> ) 290 { 291 final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o; 292 293 if ( namespaceURI.equals( e.getName().getNamespaceURI() ) 294 && localPart.equals( e.getName().getLocalPart() ) ) 295 { 296 if ( anyElement == null ) 297 { 298 anyElement = e; 299 } 300 else 301 { 302 throw new IllegalStateException( getMessage( "nonUniqueElement", this.getClass().getName(), 303 namespaceURI, localPart ) ); 304 305 } 306 } 307 } 308 } 309 310 if ( anyElement != null && anyElement.getValue() != null && anyElement.getValue().getClass().equals( type ) ) 311 { 312 @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> e = 313 (javax.xml.bind.JAXBElement<T>) anyElement; 314 315 return e; 316 } 317 318 return null; 319 } 320 321 /** 322 * Gets a list containing all {@code JAXBElement}s matching a namespace URI and local part from a given list of 323 * objects. 324 * 325 * @param any The list to search. 326 * @param namespaceURI The namespace URI of the {@code JAXBElement}s to return. 327 * @param localPart The local part of the {@code JAXBElement}s to return. 328 * @param type The class of the type the elements are bound to. 329 * @param <T> The type the elements are bound to. 330 * 331 * @return An unmodifiable list of all {@code JAXBElement}s matching {@code namespaceURI} and {@code localPart} from 332 * the {@code any} list - an empty list if no such elements are found. 333 * 334 * @throws NullPointerException if {@code any}, {@code namespaceURI}, {@code localPart} or {@code type} is 335 * {@code null}. 336 * 337 * @since 1.1 338 */ 339 protected <T> java.util.List<javax.xml.bind.JAXBElement<T>> getAnyElements( final java.util.List<Object> any, 340 final String namespaceURI, 341 final String localPart, 342 final Class<T> type ) 343 { 344 if ( any == null ) 345 { 346 throw new NullPointerException( "any" ); 347 } 348 if ( namespaceURI == null ) 349 { 350 throw new NullPointerException( "namespaceURI" ); 351 } 352 if ( localPart == null ) 353 { 354 throw new NullPointerException( "localPart" ); 355 } 356 if ( type == null ) 357 { 358 throw new NullPointerException( "type" ); 359 } 360 361 final java.util.List<javax.xml.bind.JAXBElement<T>> anyElements = 362 new java.util.ArrayList<javax.xml.bind.JAXBElement<T>>( any.size() ); 363 364 for ( int i = 0, s0 = any.size(); i < s0; i++ ) 365 { 366 final Object o = any.get( i ); 367 368 if ( o instanceof javax.xml.bind.JAXBElement<?> ) 369 { 370 final javax.xml.bind.JAXBElement<?> e = (javax.xml.bind.JAXBElement<?>) o; 371 372 if ( namespaceURI.equals( e.getName().getNamespaceURI() ) 373 && localPart.equals( e.getName().getLocalPart() ) 374 && e.getValue() != null && e.getValue().getClass().equals( type ) ) 375 { 376 @SuppressWarnings( "unchecked" ) final javax.xml.bind.JAXBElement<T> anyElement = 377 (javax.xml.bind.JAXBElement<T>) e; 378 379 anyElements.add( anyElement ); 380 } 381 } 382 } 383 384 return java.util.Collections.unmodifiableList( anyElements ); 385 } 386 387 /** 388 * Gets a single object matching a class from a given list of objects. 389 * 390 * @param any The list to search. 391 * @param clazz The class to return an instance of. 392 * @param <T> The type of the object to return. 393 * 394 * @return The instance of {@code clazz} from the {@code any} list or {@code null}, if no such instance is found. 395 * 396 * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}. 397 * @throws IllegalStateException if {@code any} contains more than one matching object. 398 */ 399 protected <T> T getAnyObject( final java.util.List<Object> any, final Class<T> clazz ) 400 { 401 if ( any == null ) 402 { 403 throw new NullPointerException( "any" ); 404 } 405 if ( clazz == null ) 406 { 407 throw new NullPointerException( "clazz" ); 408 } 409 410 T anyObject = null; 411 412 for ( int i = 0, s0 = any.size(); i < s0; i++ ) 413 { 414 Object o = any.get( i ); 415 416 if ( o instanceof javax.xml.bind.JAXBElement<?> ) 417 { 418 o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue(); 419 } 420 421 if ( clazz.equals( o.getClass() ) ) 422 { 423 if ( anyObject == null ) 424 { 425 @SuppressWarnings( "unchecked" ) final T object = (T) o; 426 anyObject = object; 427 } 428 else 429 { 430 throw new IllegalStateException( getMessage( "nonUniqueObject", this.getClass().getName(), 431 clazz.getName() ) ); 432 433 } 434 } 435 } 436 437 return anyObject; 438 } 439 440 /** 441 * Gets a list containing all objects matching a class from a given list of objects. 442 * 443 * @param any The list to search. 444 * @param clazz The class to return all instances of. 445 * @param <T> The type of the objects to return. 446 * 447 * @return An unmodifiable list of all instances of {@code clazz} from the {@code any} list - an empty list if no 448 * such objects are found. 449 * 450 * @throws NullPointerException if {@code any} or {@code clazz} is {@code null}. 451 */ 452 protected <T> java.util.List<T> getAnyObjects( final java.util.List<Object> any, final Class<T> clazz ) 453 { 454 if ( any == null ) 455 { 456 throw new NullPointerException( "any" ); 457 } 458 if ( clazz == null ) 459 { 460 throw new NullPointerException( "namespaceURI" ); 461 } 462 463 final java.util.List<T> anyElements = new java.util.ArrayList<T>( any.size() ); 464 465 for ( int i = 0, s0 = any.size(); i < s0; i++ ) 466 { 467 Object o = any.get( i ); 468 469 if ( o instanceof javax.xml.bind.JAXBElement<?> ) 470 { 471 o = ( (javax.xml.bind.JAXBElement<?>) o ).getValue(); 472 } 473 474 if ( clazz.equals( o.getClass() ) ) 475 { 476 @SuppressWarnings( "unchecked" ) final T object = (T) o; 477 anyElements.add( object ); 478 } 479 } 480 481 return java.util.Collections.unmodifiableList( anyElements ); 482 } 483 484 private static String getMessage( final String key, final Object... args ) 485 { 486 return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( 487 ModletObject.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ). 488 getString( key ), args ); 489 490 } 491 492}