|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.jstacs.parameters.ParameterSet
public abstract class ParameterSet
(Container) class for a set of Parameters. This is the base class for
other ParameterSets that provide more specialized methods, e.g. for
expanding the set of Parameters at runtime (
ExpandableParameterSet ) or defining an array of ParameterSet
s from a common template ( ArrayParameterSet ).
| Nested Class Summary | |
|---|---|
class |
ParameterSet.ParameterList
Class for a List of Parameters that basically
has the same functionality as ArrayList, but additionally takes
care of the references Parameter.parent. |
| Field Summary | |
|---|---|
protected String |
errorMessage
The error message of the last error or null |
protected ParameterSet.ParameterList |
parameters
The set of parameters |
protected ParameterSetContainer |
parent
If this ParameterSet is contained in a
ParameterSetContainer, this variable holds a reference to that
ParameterSetContainer. |
protected boolean |
ranged
Indicates if the Parameters of this ParameterSet that
implement Rangeable and return true shall be
replaced by their ranged instances |
| Constructor Summary | |
|---|---|
|
ParameterSet()
Constructs a new ParameterSet with empty parameter values. |
protected |
ParameterSet(ArrayList<Parameter> parameters)
Constructs a ParameterSet out of an ArrayList of
Parameters. |
protected |
ParameterSet(Parameter[] parameters)
Constructs a ParameterSet out of an array of Parameters. |
|
ParameterSet(StringBuffer representation)
The standard constructor for the interface Storable. |
| Method Summary | |
|---|---|
ParameterSet |
clone()
Creates a full clone (deep copy) of this ParameterSet. |
void |
fromGalaxy(String namePrefix,
StringBuffer command)
Parses the contents of command in the format defined by configBuffer of GalaxyConvertible.toGalaxy(String, String, int, StringBuffer, StringBuffer)
and sets the values of the Parameter or ParameterSet accordingly. |
protected void |
fromXML(StringBuffer representation)
Parses the instance fields of a ParameterSet from the XML
representation as returned by toXML(). |
String |
getErrorMessage()
Returns the message of the last error that occurred. |
long |
getId()
Returns the id of this ParameterSet. |
static int |
getIndex(String[] names,
Object[] values,
Comparable current,
boolean hasAlternative)
This method tries to find the correct name ( String) for your
choice. |
int |
getNumberOfParameters()
Returns the number of parameters in the ParameterSet. |
int |
getNumberOfValues()
Returns the number of values in the collection. |
Parameter |
getParameterAt(int i)
Returns the Parameter at position i. |
ParameterSetContainer |
getParent()
Returns the enclosing ParameterSetContainer of this
ParameterSet or null if none exists. |
boolean |
hasDefaultOrIsSet()
Returns true if all parameters in this ParameterSet
are either set by the user or have default values. |
protected void |
initParameterList()
Initializes the internal set of Parameters, which is a
ParameterSet.ParameterList. |
protected void |
initParameterList(int initCapacity)
Initializes the internal set of Parameters, which is a
ParameterSet.ParameterList, with an initial number of Parameters of
initCapacity. |
boolean |
isAtomic()
Returns true if this ParameterSet contains only
atomic parameters, i.e. the parameters do not contain
ParameterSets themselves. |
boolean |
isRanged()
Returns true if this RangeIterator is ranging over a
set of values. |
protected abstract void |
loadParameters()
Loads the parameters for this ParameterSet. |
void |
makeRanged()
Replaces all Parameters in this ParameterSet by their
equivalents implementing the Rangeable interface. |
boolean |
next()
Switches to the next value in the collection of values in the specified range. |
boolean |
parametersLoaded()
Returns true if the parameters of this ParameterSet
have already been loaded using loadParameters(). |
protected void |
propagateId()
Propagates the id of this ParameterSet to all Parameters
above and below in the hierarchy. |
protected void |
recieveId()
Searches for all Parameter.neededReferenceIds in the hierarchy
below this ParameterSet and sets the corresponding
Parameter.neededReferences. |
protected void |
replaceParametersWithRangedInstance()
Replaces all Parameters in this ParameterSet by their
equivalents implementing the Rangeable interface. |
void |
reset()
Resets all Parameters in this ParameterSet to their
default values or null if not default value was provided. |
void |
resetToFirst()
Resets the current value in the collection to the first value. |
void |
setParent(ParameterSetContainer parent)
Sets the enclosing ParameterSetContainer of this
ParameterSet to parent. |
void |
simplify()
Simplifies all Parameters in this ParameterSet. |
void |
toGalaxy(String namePrefix,
String configPrefix,
int depth,
StringBuffer descBuffer,
StringBuffer configBuffer)
Creates an Galaxy XML-representation of the parameters and appends it to descBuffer
and variable configuration and appends it to configBuffer. |
StringBuffer |
toXML()
This method returns an XML representation as StringBuffer of an
instance of the implementing class. |
String |
valuesToString()
Returns a String representation of the set of values. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ParameterSet.ParameterList parameters
protected String errorMessage
null
protected boolean ranged
Parameters of this ParameterSet that
implement Rangeable and return true shall be
replaced by their ranged instances
protected ParameterSetContainer parent
ParameterSet is contained in a
ParameterSetContainer, this variable holds a reference to that
ParameterSetContainer.
| Constructor Detail |
|---|
public ParameterSet()
ParameterSet with empty parameter values. The
set of parameters is loaded by the method loadParameters() as
soon as one of the accession methods, e.g.
getNumberOfParameters(), is called.
protected ParameterSet(Parameter[] parameters)
ParameterSet out of an array of Parameters.
The Parameters are not cloned, but passed by reference.
parameters - the Parametersprotected ParameterSet(ArrayList<Parameter> parameters)
ParameterSet out of an ArrayList of
Parameters. The Parameters are not cloned, but passed by
reference.
parameters - the Parameters
public ParameterSet(StringBuffer representation)
throws NonParsableException
Storable.
Constructs a ParameterSet out of an XML representation.
representation - the XML representation as StringBuffer
NonParsableException - if the ParameterSet could not be reconstructed out of
the StringBuffer representation| Method Detail |
|---|
public static int getIndex(String[] names,
Object[] values,
Comparable current,
boolean hasAlternative)
throws IllegalArgumentException
String) for your
choice. This method is useful if you handle CollectionParameters.
names - the namesvalues - the values that can be setcurrent - the value to be sethasAlternative - indicates whether the last entry of names is an alternative
parameter
StringIndexOutOfBoundsException that has to be used
IllegalArgumentException - if no match could be foundCollectionParameter
public ParameterSet clone()
throws CloneNotSupportedException
ParameterSet. As a
convenience-method the user can use
fillWithStandardFieldsForClone(ParameterSet) on a newly
created instance of a subclass of ParameterSet to obtain a
clone/copy of all standard member variables (those already defined in
ParameterSet) in the passed ParameterSet. Using this
method, the cloning process becomes merely three-step:ParameterSet, most
likely with an empty constructor or the one taking just the instance
class.
this.fillWithStandardFieldsForClone on this
instance.
Object's method
Object.clone().
clone in class ObjectParameterSet
CloneNotSupportedExceptionprotected final void initParameterList()
Parameters, which is a
ParameterSet.ParameterList.
protected final void initParameterList(int initCapacity)
Parameters, which is a
ParameterSet.ParameterList, with an initial number of Parameters of
initCapacity.
initCapacity - the initial number of Parameters
protected abstract void loadParameters()
throws Exception
ParameterSet. This is in most cases
done by calling initParameterList() or
initParameterList(int) to initialize
parameters and afterwards filling
parameters with instances of subclasses of
Parameter.
Exception - if the parameters could not be loadedParameter,
parameters,
initParameterList(),
initParameterList(int)public boolean parametersLoaded()
true if the parameters of this ParameterSet
have already been loaded using loadParameters().
public boolean isAtomic()
true if this ParameterSet contains only
atomic parameters, i.e. the parameters do not contain
ParameterSets themselves.
true if the ParameterSet contains only
atomic parameters, false otherwisepublic boolean hasDefaultOrIsSet()
true if all parameters in this ParameterSet
are either set by the user or have default values. If any additional
constraints are required on your parameters you should either specify
some ParameterValidator on these parameters or implement these
constraints by overriding this method in your implementation of
ParameterSet. It is recommended to specify a useful remark which
constraint failed in the member-variable errorMessage, which
will be displayed to the user. In the overriding method
super.hasDefaultOrIsSet() should be called prior to
checking specific constraints.
true if all parameters have some allowed value set,
false otherwisepublic String getErrorMessage()
null.
nullpublic int getNumberOfParameters()
ParameterSet.
ParameterSetpublic Parameter getParameterAt(int i)
Parameter at position i.
i - the position in the ParameterSet.ParameterList
Parameter at position i
public void makeRanged()
throws Exception
Parameters in this ParameterSet by their
equivalents implementing the Rangeable interface.
Exception - if these instances could not be createdreplaceParametersWithRangedInstance()
public boolean next()
throws ParameterException
RangeIterator
next in interface RangeIteratortrue if the next element exists, false
otherwise
ParameterException - if the next value could not be fetchedpublic void resetToFirst()
RangeIterator
resetToFirst in interface RangeIteratorpublic int getNumberOfValues()
RangeIterator
getNumberOfValues in interface RangeIteratorpublic boolean isRanged()
RangeIteratortrue if this RangeIterator is ranging over a
set of values.
isRanged in interface RangeIteratortrue if this RangeIterator is ranging over a
set of values, false otherwisepublic String valuesToString()
RangeIteratorString representation of the set of values.
valuesToString in interface RangeIteratorString representation
protected void replaceParametersWithRangedInstance()
throws Exception
Parameters in this ParameterSet by their
equivalents implementing the Rangeable interface.
Exception - if these instances could not be createdmakeRanged()public StringBuffer toXML()
StorableStringBuffer of an
instance of the implementing class.
toXML in interface Storablepublic void simplify()
Parameters in this ParameterSet.
Parameter.simplify()public void reset()
Parameters in this ParameterSet to their
default values or null if not default value was provided.
Parameter.reset()
protected void fromXML(StringBuffer representation)
throws NonParsableException
ParameterSet from the XML
representation as returned by toXML().
representation - the XML representation as StringBuffer
NonParsableException - if the XML code could not be parsedtoXML()protected void recieveId()
Parameter.neededReferenceIds in the hierarchy
below this ParameterSet and sets the corresponding
Parameter.neededReferences.
protected void propagateId()
ParameterSet to all Parameters
above and below in the hierarchy.
public long getId()
ParameterSet.
ParameterSetpublic ParameterSetContainer getParent()
ParameterSetContainer of this
ParameterSet or null if none exists.
ParameterSetContainer (parent)public void setParent(ParameterSetContainer parent)
ParameterSetContainer of this
ParameterSet to parent.
parent - the new parent
public void toGalaxy(String namePrefix,
String configPrefix,
int depth,
StringBuffer descBuffer,
StringBuffer configBuffer)
throws Exception
GalaxyConvertibledescBuffer
and variable configuration and appends it to configBuffer. The variable configuation
is also used to parse user-supplied values returned by Galaxy.
toGalaxy in interface GalaxyConvertiblenamePrefix - the prefix of the variable name used in GalaxyconfigPrefix - the prefix for conditionalsdepth - the depth in the parameter hierarchy, used for graphical representation of nestingdescBuffer - the buffer for the parameter descriptionconfigBuffer - the buffer for the configuration line
Exception - if the conversion fails
public void fromGalaxy(String namePrefix,
StringBuffer command)
throws Exception
GalaxyConvertiblecommand in the format defined by configBuffer of GalaxyConvertible.toGalaxy(String, String, int, StringBuffer, StringBuffer)
and sets the values of the Parameter or ParameterSet accordingly.
fromGalaxy in interface GalaxyConvertiblenamePrefix - the prefix of the variable namecommand - the command string
Exception - if the command string could not be parsed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||