public abstract class ParameterSet extends Object implements Storable, Cloneable, GalaxyConvertible
Parameter
s. This is the base class for
other ParameterSet
s that provide more specialized methods, e.g. for
expanding the set of Parameter
s at runtime (
ExpandableParameterSet
) or defining an array of ParameterSet
s from a common template ( ArrayParameterSet
).Modifier and Type | Class and Description |
---|---|
protected class |
ParameterSet.ParameterList
Class for a
AnnotatedEntityList that automatically sets
the Parameter.parent field to the enclosing ParameterSet . |
Modifier and Type | Field and Description |
---|---|
protected String |
errorMessage
The error message of the last error or
null |
protected ParameterSet.ParameterList |
parameters
The set of parameters
|
protected Parameter |
parent
If this
ParameterSet is contained in a
Parameter , this variable holds a reference to that
Parameter . |
Modifier | Constructor and Description |
---|---|
|
ParameterSet()
Constructs a new
ParameterSet with empty parameter values. |
protected |
ParameterSet(ArrayList<Parameter> parameters)
|
protected |
ParameterSet(Parameter... parameters)
Constructs a
ParameterSet out of an array of Parameter s. |
|
ParameterSet(StringBuffer representation)
The standard constructor for the interface
Storable . |
Modifier and Type | Method and Description |
---|---|
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, boolean)
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[] |
getAllParameterNames()
Returns the names of all
Parameter s in this ParameterSet . |
static String |
getComment(Class<? extends ParameterSet> c)
Returns a comment for the class.
|
static String |
getComment(ParameterSet p)
Returns a comment for the
ParameterSet . |
String |
getErrorMessage()
Returns the message of the last error that occurred.
|
static int |
getIndex(String[] names,
Object[] values,
Comparable current,
boolean hasAlternative)
This method tries to find the correct name (
String ) for your
choice. |
static String |
getName(Class<? extends ParameterSet> c)
Returns a name for the class.
|
static String |
getName(ParameterSet p)
Returns a name for the
ParameterSet . |
int |
getNumberOfParameters()
Returns the number of parameters in the
ParameterSet . |
Parameter |
getParameterAt(int i)
Returns the
Parameter at position i . |
Parameter |
getParameterForName(String name)
Returns the
Parameter with name name . |
Parameter |
getParent()
|
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
Parameter s, which is a
ParameterSet.ParameterList . |
protected void |
initParameterList(int initCapacity)
Initializes the internal set of
Parameter s, which is a
ParameterSet.ParameterList , with an initial number of Parameter s of
initCapacity . |
boolean |
isAtomic()
Returns
true if this ParameterSet contains only
atomic parameters, i.e. |
boolean |
isComparable(ParameterSet p)
This method checks whether the given
ParameterSet is comparable to the current instance, i.e. |
boolean |
parametersLoaded()
Returns
true if the parameters of this ParameterSet
have been loaded. |
void |
reset()
Resets all
Parameter s in this ParameterSet to their
default values or null if not default value was provided. |
void |
setParent(Parameter parent)
|
void |
toGalaxy(String namePrefix,
String configPrefix,
int depth,
StringBuffer descBuffer,
StringBuffer configBuffer,
boolean addLine)
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. |
protected ParameterSet.ParameterList parameters
protected String errorMessage
null
protected Parameter parent
ParameterSet
is contained in a
Parameter
, this variable holds a reference to that
Parameter
.public ParameterSet()
ParameterSet
with empty parameter values.protected ParameterSet(Parameter... parameters)
ParameterSet
out of an array of Parameter
s.
The Parameter
s are not cloned, but passed by reference.parameters
- the Parameter
sprotected ParameterSet(ArrayList<Parameter> parameters)
ParameterSet
out of an ArrayList
of
Parameter
s. The Parameter
s are not cloned, but passed by
reference.parameters
- the Parameter
spublic 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
public static String getName(Class<? extends ParameterSet> c)
c
- the given class.ParameterSetContainer.ParameterSetContainer(Class)
,
AbstractSelectionParameter.AbstractSelectionParameter(String, String, boolean, Class...)
public static String getComment(Class<? extends ParameterSet> c)
c
- the given class.ParameterSetContainer.ParameterSetContainer(Class)
,
AbstractSelectionParameter.AbstractSelectionParameter(String, String, boolean, Class...)
public static String getName(ParameterSet p)
ParameterSet
.p
- the given ParameterSet
.ParameterSet
.ParameterSetContainer.ParameterSetContainer(ParameterSet)
,
AbstractSelectionParameter.AbstractSelectionParameter(String, String, boolean, ParameterSet...)
,
getName(Class)
,
Object.getClass()
public static String getComment(ParameterSet p)
ParameterSet
.p
- the given ParameterSet
.ParameterSet
.ParameterSetContainer.ParameterSetContainer(ParameterSet)
,
AbstractSelectionParameter.AbstractSelectionParameter(String, String, boolean, ParameterSet...)
,
getComment(Class)
,
Object.getClass()
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 AbstractSelectionParameter
s.names
- the namesvalues
- the values that can be setcurrent
- the value to be sethasAlternative
- indicates whether the last entry of names is an alternative
parameterStringIndexOutOfBoundsException
that has to be usedIllegalArgumentException
- if no match could be foundAbstractSelectionParameter
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 Object
ParameterSet
CloneNotSupportedException
protected final void initParameterList()
Parameter
s, which is a
ParameterSet.ParameterList
.protected final void initParameterList(int initCapacity)
Parameter
s, which is a
ParameterSet.ParameterList
, with an initial number of Parameter
s of
initCapacity
.initCapacity
- the initial number of Parameter
spublic boolean parametersLoaded()
true
if the parameters of this ParameterSet
have been loaded.public boolean isAtomic()
true
if this ParameterSet
contains only
atomic parameters, i.e. the parameters do not contain
ParameterSet
s 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
.null
public int getNumberOfParameters()
ParameterSet
.ParameterSet
public String[] getAllParameterNames()
Parameter
s in this ParameterSet
.Parameter
s in this ParameterSet
public Parameter getParameterForName(String name)
Parameter
with name name
.public Parameter getParameterAt(int i)
Parameter
at position i
.i
- the position in the ParameterSet
Parameter
at position i
public StringBuffer toXML()
Storable
StringBuffer
of an
instance of the implementing class.public void reset()
Parameter
s 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()
public void setParent(Parameter parent)
parent
- the new parentpublic void toGalaxy(String namePrefix, String configPrefix, int depth, StringBuffer descBuffer, StringBuffer configBuffer, boolean addLine) throws Exception
GalaxyConvertible
descBuffer
and variable configuration and appends it to configBuffer
. The variable configuration
is also used to parse user-supplied values returned by Galaxy.toGalaxy
in interface GalaxyConvertible
namePrefix
- 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 lineaddLine
- if true, a line is added before the title of a parameterException
- if the conversion failspublic void fromGalaxy(String namePrefix, StringBuffer command) throws Exception
GalaxyConvertible
command
in the format defined by configBuffer
of GalaxyConvertible.toGalaxy(String, String, int, StringBuffer, StringBuffer, boolean)
and sets the values of the Parameter
or ParameterSet
accordingly.fromGalaxy
in interface GalaxyConvertible
namePrefix
- the prefix of the variable namecommand
- the command stringException
- if the command string could not be parsedpublic boolean isComparable(ParameterSet p)
ParameterSet
is comparable to the current instance, i.e. whether
the Class
and the number of parameters are identical, and the individual Parameter
s are comparable.
In other words, the method returns true
if the ParameterSet
s only differ in their specific raw values.p
- the ParameterSet
for the comparisontrue
if the ParameterSet
s only differ in their values, otherwise false
Object.getClass()
,
getNumberOfParameters()
,
Parameter.isComparable(Parameter)