/** * Gets an implementation for an index. * * @param index the index of the implementation to return. * * @return a reference to the implementation at {@code index}. * * @throws IndexOutOfBoundsException if {@code index} is negativ, * greater than or equal to {@code size()}. */ public final Implementation getImplementation( final int index ) { if ( index < 0 || index >= this.size() ) { throw new ArrayIndexOutOfBoundsException( index ); } return this.getImplementations()[index]; }
/** * Gets a collection of all implementations of all modules held by the * instance. * * @return a reference to all implementations of all modules held by the * instance. */ public Implementations getImplementations() { if ( this.implementations == null ) { this.implementations = new Implementations(); } final Collection col = new ArrayList( this.implementations.size() ); for ( int i = this.size() - 1; i >= 0; i-- ) { final Module mod = this.getModule( i ); for ( int j = mod.getImplementations().size() - 1; j >= 0; j-- ) { col.add( mod.getImplementations().getImplementation( j ) ); } } this.implementations.setImplementations( (Implementation[]) col.toArray( new Implementation[ col.size() ] ) ); return this.implementations; }
/** * Creates a string representing the properties of the instance. * * @return a string representing the properties of the instance. */ private String internalString() { final StringBuffer buf = new StringBuffer( 200 ).append( '{' ); buf.append( this.internalString( this ) ); final Implementation[] impls = this.getImplementations(); for ( int i = impls.length - 1; i >= 0; i-- ) { buf.append( ", [" ).append( i ).append( "]=" ). append( impls[i] ); } buf.append( '}' ); return buf.toString(); }
/** * Creates and returns a deep copy of this object. * * @return a clone of this instance. */ public Object clone() { try { final Implementations ret = (Implementations) super.clone(); final Implementation[] impls = this.getImplementations(); final Implementation[] cloned = new Implementation[ impls.length ]; for ( int i = impls.length - 1; i >= 0; i-- ) { cloned[i] = (Implementation) impls[i].clone(); } ret.setImplementations( cloned ); return ret; } catch ( final CloneNotSupportedException e ) { throw new AssertionError( e ); } }
value.size() != 1 ) for ( int i = value.size() - 1; i >= 0; i-- ) value.getImplementation( i ).getName(), value.getImplementation( i ) ) != null ) value.getImplementation( i ).getName() );
Arrays.asList( spec.getImplementations(). getImplementations() ) ); final Implementations impls = new Implementations(); impls.setImplementations( (Implementation[]) col.toArray( new Implementation[ col.size() ] ) );
/** * Gets the number of implementations held by the instance. * * @return the number of implementations held by the instance. */ public final int size() { return this.getImplementations().length; }
final Implementations impls = new Implementations(); impls.setModelVersion( modelVersion ); impls.setImplementations( (Implementation[]) list.toArray( new Implementation[ list.size() ] ) );
/** * Setter for property {@code multiplicity}. * * @param value the new implementation multiplicity of the specification. * * @throws IllegalArgumentException if {@code value} is not equal to one of * the constants {@code MULTIPLICITY_ONE} or {@code MULTIPLICITY_MANY}. * @throws MultiplicityConstraintException if {@code value} equals * {@code MULTIPLICITY_ONE} and the specification currently has more than * one implementation defined. * * @see #MULTIPLICITY_ONE * @see #MULTIPLICITY_MANY */ public void setMultiplicity( final int value ) { if ( value != MULTIPLICITY_ONE && value != MULTIPLICITY_MANY ) { throw new IllegalArgumentException( Integer.toString( value ) ); } if ( value == MULTIPLICITY_ONE && this.getImplementations().size() > 1 ) { throw new MultiplicityConstraintException( this.getIdentifier() ); } this.multiplicity = value; }
/** * Gets all available implementations of the specification. * * @return all available implementations of the specification. */ public Implementations getImplementations() { if ( this.implementations == null ) { this.implementations = new Implementations(); } return this.implementations; }
/** * Returns a string representation of the object. * * @return a string representation of the object. */ public String toString() { return super.toString() + this.internalString(); }
append( ", implementations={" ); for ( int i = this.getImplementations().size() - 1; i >= 0; i-- ) this.getImplementations().getImplementation( i );
/** * Resolves application messages for a given exception by querying any * available {@code ExceptionMessageResolver} implementation stopping at the * first implementation not returning {@code null}. * * @param exception The exception to resolve application messages for. * * @throws NullPointerException if {@code exception} is {@code null}. */ private Message[] resolveMessages( final Exception exception ) { if ( exception == null ) { throw new NullPointerException( "exception" ); } Message[] messages = null; final Specification spec = ModelFactory.getModel().getModules(). getSpecification( ExceptionMessageResolver.class.getName() ); final Implementation[] resolvers = spec.getImplementations(). getImplementations(); for ( int i = resolvers.length - 1; i >= 0 && messages == null; i-- ) { final ExceptionMessageResolver resolver = (ExceptionMessageResolver) ContainerFactory.getContainer(). getObject( ExceptionMessageResolver.class, resolvers[i].getName() ); messages = resolver.resolve( exception ); } return messages; }
/** * Gets the implementations of the module. * * @return implementations of the module. */ public Implementations getImplementations() { if ( this.implementations == null ) { this.implementations = new Implementations(); } return this.implementations; }
for ( int i = this.modules.getImplementations().size() - 1; i >= 0; i-- ) getImplementation( i ); getImplementations().getImplementations(); tmp[current.length] = defaultImpl; final Implementations impls = new Implementations(); impls.setImplementations( tmp );
for ( int j = mod.getImplementations().size() - 1; j >= 0; j-- ) mod.getImplementations().getImplementation( j );
/** * Indicates whether some other object is equal to this one by comparing * the values of all properties. * * @param o the reference object with which to compare. * * @return {@code true} if this object is the same as {@code o}; * {@code false} otherwise. */ public boolean equals( final Object o ) { boolean equal = this == o; if ( !equal && o instanceof Implementations ) { final Implementations that = (Implementations) o; final Collection these = Arrays.asList( this.getImplementations() ); final Collection those = Arrays.asList( that.getImplementations() ); equal = this.size() == that.size() && these.containsAll( those ); } return equal; }
getSpecification( SequenceValidator.class.getName() ); final Implementation[] validators = spec.getImplementations(). getImplementations();
public JFileChooser getSaveAsFileChooser() { if(this.saveAsFileChooser == null) { this.saveAsFileChooser = new JFileChooser(); this.saveAsFileChooser.setAcceptAllFileFilterUsed(false); this.saveAsFileChooser.setMultiSelectionEnabled(false); final Implementations formatters = ModelFactory.getModel().getModules(). getSpecification(PhysicalFileFormatter.class.getName()). getImplementations(); for(int i = formatters.size() - 1; i >= 0; i--) { final PhysicalFileFormatter formatter = (PhysicalFileFormatter) ContainerFactory. getContainer().getImplementation( PhysicalFileFormatter.class, formatters.getImplementation(i).getName()); this.saveAsFileChooser.addChoosableFileFilter( new PhysicalFileFormatterFileFilter(formatter)); } } return this.saveAsFileChooser; }
getSpecification( SequenceValidator.class.getName() ); final Implementation[] validators = spec.getImplementations(). getImplementations();