| 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: 2014.03.26 at 03:22:30 PM CET |
| 6 | // |
| 7 | |
| 8 | |
| 9 | package org.jomc.modlet; |
| 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.XmlElement; |
| 18 | import javax.xml.bind.annotation.XmlType; |
| 19 | |
| 20 | |
| 21 | /** |
| 22 | * List of modlets. |
| 23 | * |
| 24 | * <p>Java class for Modlets complex type. |
| 25 | * |
| 26 | * <p>The following schema fragment specifies the expected content contained within this class. |
| 27 | * |
| 28 | * <pre> |
| 29 | * <complexType name="Modlets"> |
| 30 | * <complexContent> |
| 31 | * <extension base="{http://jomc.org/modlet}ModletObject"> |
| 32 | * <sequence> |
| 33 | * <element ref="{http://jomc.org/modlet}modlet" maxOccurs="unbounded" minOccurs="0"/> |
| 34 | * </sequence> |
| 35 | * </extension> |
| 36 | * </complexContent> |
| 37 | * </complexType> |
| 38 | * </pre> |
| 39 | * |
| 40 | * |
| 41 | */ |
| 42 | @XmlAccessorType(XmlAccessType.FIELD) |
| 43 | @XmlType(name = "Modlets", namespace = "http://jomc.org/modlet", propOrder = { |
| 44 | "modlet" |
| 45 | }) |
| 46 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:22:29+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
| 47 | public class Modlets |
| 48 | extends ModletObject |
| 49 | implements Cloneable |
| 50 | { |
| 51 | |
| 52 | @XmlElement(namespace = "http://jomc.org/modlet") |
| 53 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:22:29+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
| 54 | protected List<Modlet> modlet; |
| 55 | |
| 56 | /** |
| 57 | * Creates a new {@code Modlets} instance. |
| 58 | * |
| 59 | */ |
| 60 | public Modlets() { |
| 61 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
| 62 | super(); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Creates a new {@code Modlets} instance by deeply copying a given {@code Modlets} instance. |
| 67 | * |
| 68 | * |
| 69 | * @param o |
| 70 | * The instance to copy. |
| 71 | * @throws NullPointerException |
| 72 | * if {@code o} is {@code null}. |
| 73 | */ |
| 74 | public Modlets(final Modlets o) { |
| 75 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
| 76 | super(o); |
| 77 | if (o == null) { |
| 78 | throw new NullPointerException("Cannot create a copy of 'Modlets' from 'null'."); |
| 79 | } |
| 80 | // 'Modlet' collection. |
| 81 | if (o.modlet!= null) { |
| 82 | copyModlet(o.getModlet(), this.getModlet()); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Gets the value of the modlet property. |
| 88 | * |
| 89 | * <p> |
| 90 | * This accessor method returns a reference to the live list, |
| 91 | * not a snapshot. Therefore any modification you make to the |
| 92 | * returned list will be present inside the JAXB object. |
| 93 | * This is why there is not a <CODE>set</CODE> method for the modlet property. |
| 94 | * |
| 95 | * <p> |
| 96 | * For example, to add a new item, do as follows: |
| 97 | * <pre> |
| 98 | * getModlet().add(newItem); |
| 99 | * </pre> |
| 100 | * |
| 101 | * |
| 102 | * <p> |
| 103 | * Objects of the following type(s) are allowed in the list |
| 104 | * {@link Modlet } |
| 105 | * |
| 106 | * |
| 107 | */ |
| 108 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:22:29+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
| 109 | public List<Modlet> getModlet() { |
| 110 | if (modlet == null) { |
| 111 | modlet = new ArrayList<Modlet>(); |
| 112 | } |
| 113 | return this.modlet; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Copies all values of property {@code Modlet} deeply. |
| 118 | * |
| 119 | * @param source |
| 120 | * The source to copy from. |
| 121 | * @param target |
| 122 | * The target to copy {@code source} to. |
| 123 | * @throws NullPointerException |
| 124 | * if {@code target} is {@code null}. |
| 125 | */ |
| 126 | @SuppressWarnings("unchecked") |
| 127 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:22:29+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
| 128 | private static void copyModlet(final List<Modlet> source, final List<Modlet> target) { |
| 129 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
| 130 | if ((source!= null)&&(!source.isEmpty())) { |
| 131 | for (final Iterator<?> it = source.iterator(); it.hasNext(); ) { |
| 132 | final Object next = it.next(); |
| 133 | if (next instanceof Modlet) { |
| 134 | // CClassInfo: org.jomc.modlet.Modlet |
| 135 | target.add(((Modlet) next).clone()); |
| 136 | continue; |
| 137 | } |
| 138 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
| 139 | throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Modlet' of class 'org.jomc.modlet.Modlets'.")); |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Creates and returns a deep copy of this object. |
| 146 | * |
| 147 | * |
| 148 | * @return |
| 149 | * A deep copy of this object. |
| 150 | */ |
| 151 | @Override |
| 152 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-03-26T03:22:29+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
| 153 | public Modlets clone() { |
| 154 | { |
| 155 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
| 156 | final Modlets clone = ((Modlets) super.clone()); |
| 157 | // 'Modlet' collection. |
| 158 | if (this.modlet!= null) { |
| 159 | clone.modlet = null; |
| 160 | copyModlet(this.getModlet(), clone.getModlet()); |
| 161 | } |
| 162 | return clone; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Gets a modlet for a given name from the list of modlets. |
| 168 | * |
| 169 | * @param name The name of the modlet to return. |
| 170 | * |
| 171 | * @return The first matching modlet or {@code null}, if no such modlet is found. |
| 172 | * |
| 173 | * @throws NullPointerException if {@code name} is {@code null}. |
| 174 | * |
| 175 | * @see #getModlet() |
| 176 | * @see Modlet#getName() |
| 177 | */ |
| 178 | public Modlet getModlet( final String name ) |
| 179 | { |
| 180 | if ( name == null ) |
| 181 | { |
| 182 | throw new NullPointerException( "name" ); |
| 183 | } |
| 184 | |
| 185 | for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ ) |
| 186 | { |
| 187 | final Modlet m = this.getModlet().get( i ); |
| 188 | |
| 189 | if ( name.equals( m.getName() ) ) |
| 190 | { |
| 191 | return m; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | return null; |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * Merges modlets of a model from this list of modlets to a single modlet. |
| 200 | * |
| 201 | * @param name The name of the modlet to return. |
| 202 | * @param model The identifier of the model of the modlet to return. |
| 203 | * |
| 204 | * @return A modlet holding all modlet objects of the model identified by {@code model} from the list. |
| 205 | * |
| 206 | * @throws NullPointerException if {@code name} or {@code model} is {@code null}. |
| 207 | * |
| 208 | * @see #getModlet() |
| 209 | * @see Modlet#getModel() |
| 210 | */ |
| 211 | public Modlet getMergedModlet( final String name, final String model ) |
| 212 | { |
| 213 | if ( name == null ) |
| 214 | { |
| 215 | throw new NullPointerException( "name" ); |
| 216 | } |
| 217 | if ( model == null ) |
| 218 | { |
| 219 | throw new NullPointerException( "model" ); |
| 220 | } |
| 221 | |
| 222 | final Modlet mergedModlet = new Modlet(); |
| 223 | mergedModlet.setName( name ); |
| 224 | mergedModlet.setModel( model ); |
| 225 | |
| 226 | for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ ) |
| 227 | { |
| 228 | final Modlet m = this.getModlet().get( i ); |
| 229 | |
| 230 | if ( model.equals( m.getModel() ) ) |
| 231 | { |
| 232 | if ( m.getSchemas() != null ) |
| 233 | { |
| 234 | if ( mergedModlet.getSchemas() == null ) |
| 235 | { |
| 236 | mergedModlet.setSchemas( new Schemas() ); |
| 237 | } |
| 238 | |
| 239 | for ( int j = 0, s1 = m.getSchemas().getSchema().size(); j < s1; j++ ) |
| 240 | { |
| 241 | final Schema s = m.getSchemas().getSchema().get( j ); |
| 242 | |
| 243 | if ( mergedModlet.getSchemas().getSchemaBySystemId( s.getSystemId() ) == null ) |
| 244 | { |
| 245 | mergedModlet.getSchemas().getSchema().add( s ); |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | if ( m.getServices() != null ) |
| 251 | { |
| 252 | if ( mergedModlet.getServices() == null ) |
| 253 | { |
| 254 | mergedModlet.setServices( new Services() ); |
| 255 | } |
| 256 | |
| 257 | for ( int j = 0, s1 = m.getServices().getService().size(); j < s1; j++ ) |
| 258 | { |
| 259 | final Service s = m.getServices().getService().get( j ); |
| 260 | boolean merged = false; |
| 261 | |
| 262 | for ( Service mergedService : mergedModlet.getServices().getServices( s.getIdentifier() ) ) |
| 263 | { |
| 264 | if ( mergedService.getClazz().equals( s.getClazz() ) ) |
| 265 | { |
| 266 | if ( mergedService.getOrdinal() < s.getOrdinal() ) |
| 267 | { |
| 268 | mergedService.setOrdinal( s.getOrdinal() ); |
| 269 | } |
| 270 | |
| 271 | merged = true; |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | if ( !merged ) |
| 276 | { |
| 277 | mergedModlet.getServices().getService().add( s ); |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | return mergedModlet; |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Gets schemas for a model from this list of modlets. |
| 289 | * |
| 290 | * @param model The identifier of the model to return schemas of. |
| 291 | * |
| 292 | * @return A list of schemas for {@code model} or {@code null}, if no such schemas are found. |
| 293 | * |
| 294 | * @throws NullPointerException if {@code model} is {@code null}. |
| 295 | * |
| 296 | * @see #getModlet() |
| 297 | * @see Modlet#getModel() |
| 298 | */ |
| 299 | public Schemas getSchemas( final String model ) |
| 300 | { |
| 301 | if ( model == null ) |
| 302 | { |
| 303 | throw new NullPointerException( "model" ); |
| 304 | } |
| 305 | |
| 306 | final Schemas schemas = new Schemas(); |
| 307 | |
| 308 | for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ ) |
| 309 | { |
| 310 | final Modlet m = this.getModlet().get( i ); |
| 311 | |
| 312 | if ( m.getSchemas() != null && ( ModletObject.MODEL_PUBLIC_ID.equals( m.getModel() ) |
| 313 | || model.equals( m.getModel() ) ) ) |
| 314 | { |
| 315 | for ( int j = 0, s1 = m.getSchemas().getSchema().size(); j < s1; j++ ) |
| 316 | { |
| 317 | schemas.getSchema().add( m.getSchemas().getSchema().get( j ) ); |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | return schemas.getSchema().isEmpty() ? null : schemas; |
| 323 | } |
| 324 | |
| 325 | /** |
| 326 | * Gets schemas for a public identifier from this list of modlets. |
| 327 | * |
| 328 | * @param publicId The public identifier of the schemas to return. |
| 329 | * |
| 330 | * @return A list of schemas matching {@code publicId} or {@code null}, if no such schemas are found. |
| 331 | * |
| 332 | * @throws NullPointerException if {@code publicId} is {@code null}. |
| 333 | * |
| 334 | * @see #getModlet() |
| 335 | * @see Modlet#getSchemas() |
| 336 | * @see Schemas#getSchemasByPublicId(java.net.URI) |
| 337 | * @since 1.2 |
| 338 | */ |
| 339 | public Schemas getSchemas( final java.net.URI publicId ) |
| 340 | { |
| 341 | if ( publicId == null ) |
| 342 | { |
| 343 | throw new NullPointerException( "publicId" ); |
| 344 | } |
| 345 | |
| 346 | final Schemas schemas = new Schemas(); |
| 347 | |
| 348 | for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ ) |
| 349 | { |
| 350 | final Modlet m = this.getModlet().get( i ); |
| 351 | |
| 352 | if ( m.getSchemas() != null ) |
| 353 | { |
| 354 | schemas.getSchema().addAll( m.getSchemas().getSchemasByPublicId( publicId ) ); |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | return schemas.getSchema().isEmpty() ? null : schemas; |
| 359 | } |
| 360 | |
| 361 | /** |
| 362 | * Gets services for a model from this list of modlets. |
| 363 | * |
| 364 | * @param model The identifier of the model to return services of. |
| 365 | * |
| 366 | * @return A list of services for {@code model} or {@code null}, if no such services are found. |
| 367 | * |
| 368 | * @throws NullPointerException if {@code model} is {@code null}. |
| 369 | * |
| 370 | * @see #getModlet() |
| 371 | * @see Modlet#getModel() |
| 372 | */ |
| 373 | public Services getServices( final String model ) |
| 374 | { |
| 375 | if ( model == null ) |
| 376 | { |
| 377 | throw new NullPointerException( "model" ); |
| 378 | } |
| 379 | |
| 380 | final Services services = new Services(); |
| 381 | |
| 382 | for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ ) |
| 383 | { |
| 384 | final Modlet m = this.getModlet().get( i ); |
| 385 | |
| 386 | if ( m.getServices() != null && ( ModletObject.MODEL_PUBLIC_ID.equals( m.getModel() ) |
| 387 | || model.equals( m.getModel() ) ) ) |
| 388 | { |
| 389 | for ( int j = 0, s1 = m.getServices().getService().size(); j < s1; j++ ) |
| 390 | { |
| 391 | services.getService().add( m.getServices().getService().get( j ) ); |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | return services.getService().isEmpty() ? null : services; |
| 397 | } |
| 398 | |
| 399 | } |