org.jomc.modlet.Modlets Maven / Gradle / Ivy
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2013.01.04 at 08:47:18 AM MEZ
//
package org.jomc.modlet;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.annotation.Generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* List of modlets.
*
* Java class for Modlets complex type.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
* <complexType name="Modlets">
* <complexContent>
* <extension base="{http://jomc.org/modlet}ModletObject">
* <sequence>
* <element ref="{http://jomc.org/modlet}modlet" maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Modlets", namespace = "http://jomc.org/modlet", propOrder = {
"modlet"
})
@Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-04T08:47:18+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
public class Modlets
extends ModletObject
implements Cloneable
{
@XmlElement(namespace = "http://jomc.org/modlet")
@Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-04T08:47:18+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
protected List modlet;
/**
* Creates a new {@code Modlets} instance.
*
*/
public Modlets() {
// CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
super();
}
/**
* Creates a new {@code Modlets} instance by deeply copying a given {@code Modlets} instance.
*
*
* @param o
* The instance to copy.
* @throws NullPointerException
* if {@code o} is {@code null}.
*/
public Modlets(final Modlets o) {
// CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
super(o);
if (o == null) {
throw new NullPointerException("Cannot create a copy of 'Modlets' from 'null'.");
}
// 'Modlet' collection.
if (o.modlet!= null) {
copyModlet(o.getModlet(), this.getModlet());
}
}
/**
* Gets the value of the modlet property.
*
*
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a set
method for the modlet property.
*
*
* For example, to add a new item, do as follows:
*
* getModlet().add(newItem);
*
*
*
*
* Objects of the following type(s) are allowed in the list
* {@link Modlet }
*
*
*/
@Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-04T08:47:18+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
public List getModlet() {
if (modlet == null) {
modlet = new ArrayList();
}
return this.modlet;
}
/**
* Copies all values of property {@code Modlet} deeply.
*
* @param source
* The source to copy from.
* @param target
* The target to copy {@code source} to.
* @throws NullPointerException
* if {@code target} is {@code null}.
*/
@SuppressWarnings("unchecked")
@Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-04T08:47:18+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
private static void copyModlet(final List source, final List target) {
// CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
if ((source!= null)&&(!source.isEmpty())) {
for (final Iterator> it = source.iterator(); it.hasNext(); ) {
final Object next = it.next();
if (next instanceof Modlet) {
// CClassInfo: org.jomc.modlet.Modlet
target.add(((Modlet) next).clone());
continue;
}
// Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/
throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Modlet' of class 'org.jomc.modlet.Modlets'."));
}
}
}
/**
* Creates and returns a deep copy of this object.
*
*
* @return
* A deep copy of this object.
*/
@Override
@Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-04T08:47:18+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2")
public Modlets clone() {
{
// CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000
final Modlets clone = ((Modlets) super.clone());
// 'Modlet' collection.
if (this.modlet!= null) {
clone.modlet = null;
copyModlet(this.getModlet(), clone.getModlet());
}
return clone;
}
}
/**
* Gets a modlet for a given name from the list of modlets.
*
* @param name The name of the modlet to return.
*
* @return The first matching modlet or {@code null}, if no such modlet is found.
*
* @throws NullPointerException if {@code name} is {@code null}.
*
* @see #getModlet()
* @see Modlet#getName()
*/
public Modlet getModlet( final String name )
{
if ( name == null )
{
throw new NullPointerException( "name" );
}
for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ )
{
final Modlet m = this.getModlet().get( i );
if ( name.equals( m.getName() ) )
{
return m;
}
}
return null;
}
/**
* Merges modlets of a model from this list of modlets to a single modlet.
*
* @param name The name of the modlet to return.
* @param model The identifier of the model of the modlet to return.
*
* @return A modlet holding all modlet objects of the model identified by {@code model} from the list.
*
* @throws NullPointerException if {@code name} or {@code model} is {@code null}.
*
* @see #getModlet()
* @see Modlet#getModel()
*/
public Modlet getMergedModlet( final String name, final String model )
{
if ( name == null )
{
throw new NullPointerException( "name" );
}
if ( model == null )
{
throw new NullPointerException( "model" );
}
final Modlet mergedModlet = new Modlet();
mergedModlet.setName( name );
mergedModlet.setModel( model );
for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ )
{
final Modlet m = this.getModlet().get( i );
if ( model.equals( m.getModel() ) )
{
if ( m.getSchemas() != null )
{
if ( mergedModlet.getSchemas() == null )
{
mergedModlet.setSchemas( new Schemas() );
}
for ( int j = 0, s1 = m.getSchemas().getSchema().size(); j < s1; j++ )
{
final Schema s = m.getSchemas().getSchema().get( j );
if ( mergedModlet.getSchemas().getSchemaBySystemId( s.getSystemId() ) == null )
{
mergedModlet.getSchemas().getSchema().add( s );
}
}
}
if ( m.getServices() != null )
{
if ( mergedModlet.getServices() == null )
{
mergedModlet.setServices( new Services() );
}
for ( int j = 0, s1 = m.getServices().getService().size(); j < s1; j++ )
{
final Service s = m.getServices().getService().get( j );
boolean merged = false;
for ( Service mergedService : mergedModlet.getServices().getServices( s.getIdentifier() ) )
{
if ( mergedService.getClazz().equals( s.getClazz() ) )
{
if ( mergedService.getOrdinal() < s.getOrdinal() )
{
mergedService.setOrdinal( s.getOrdinal() );
}
merged = true;
}
}
if ( !merged )
{
mergedModlet.getServices().getService().add( s );
}
}
}
}
}
return mergedModlet;
}
/**
* Gets schemas for a model from this list of modlets.
*
* @param model The identifier of the model to return schemas of.
*
* @return A list of schemas for {@code model} or {@code null}, if no such schemas are found.
*
* @throws NullPointerException if {@code model} is {@code null}.
*
* @see #getModlet()
* @see Modlet#getModel()
*/
public Schemas getSchemas( final String model )
{
if ( model == null )
{
throw new NullPointerException( "model" );
}
final Schemas schemas = new Schemas();
final String projectName = getMessage( "projectName" );
for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ )
{
final Modlet m = this.getModlet().get( i );
if ( m.getSchemas() != null && ( m.getName().equals( projectName ) || model.equals( m.getModel() ) ) )
{
for ( int j = 0, s1 = m.getSchemas().getSchema().size(); j < s1; j++ )
{
schemas.getSchema().add( m.getSchemas().getSchema().get( j ) );
}
}
}
return schemas.getSchema().isEmpty() ? null : schemas;
}
/**
* Gets schemas for a public identifier from this list of modlets.
*
* @param publicId The public identifier of the schemas to return.
*
* @return A list of schemas matching {@code publicId} or {@code null}, if no such schemas are found.
*
* @throws NullPointerException if {@code publicId} is {@code null}.
*
* @see #getModlet()
* @see Modlet#getSchemas()
* @see Schemas#getSchemasByPublicId(java.net.URI)
* @since 1.2
*/
public Schemas getSchemas( final java.net.URI publicId )
{
if ( publicId == null )
{
throw new NullPointerException( "publicId" );
}
final Schemas schemas = new Schemas();
for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ )
{
final Modlet m = this.getModlet().get( i );
if ( m.getSchemas() != null )
{
schemas.getSchema().addAll( m.getSchemas().getSchemasByPublicId( publicId ) );
}
}
return schemas.getSchema().isEmpty() ? null : schemas;
}
/**
* Gets services for a model from this list of modlets.
*
* @param model The identifier of the model to return services of.
*
* @return A list of services for {@code model} or {@code null}, if no such services are found.
*
* @throws NullPointerException if {@code model} is {@code null}.
*
* @see #getModlet()
* @see Modlet#getModel()
*/
public Services getServices( final String model )
{
if ( model == null )
{
throw new NullPointerException( "model" );
}
final Services services = new Services();
final String projectName = getMessage( "projectName" );
for ( int i = 0, s0 = this.getModlet().size(); i < s0; i++ )
{
final Modlet m = this.getModlet().get( i );
if ( m.getServices() != null && ( m.getName().equals( projectName ) || model.equals( m.getModel() ) ) )
{
for ( int j = 0, s1 = m.getServices().getService().size(); j < s1; j++ )
{
services.getService().add( m.getServices().getService().get( j ) );
}
}
}
return services.getService().isEmpty() ? null : services;
}
private static String getMessage( final String key, final Object... args )
{
return java.text.MessageFormat.format( java.util.ResourceBundle.getBundle(
ModelContext.class.getName().replace( '.', '/' ), java.util.Locale.getDefault() ).getString( key ), args );
}
}