public abstract class AbstractSelectionParameter extends Parameter implements Rangeable, GalaxyConvertible
ParameterSet
.ParameterSet
Modifier and Type | Class and Description |
---|---|
class |
AbstractSelectionParameter.InconsistentCollectionException
This exception is thrown if the
AbstractSelectionParameter is
inconsistent for some reason. |
Modifier and Type | Field and Description |
---|---|
protected String |
errorMessage
If a value was illegal for the collection parameter, this field holds the
error message.
|
protected ParameterSet |
parameters
The internal
ParameterSet that holds the possible values |
protected boolean |
userSelected
true if the user has selected an item |
comment, datatype, name
Constructor and Description |
---|
AbstractSelectionParameter(DataType datatype,
String[] keys,
Object[] values,
String[] comments,
String name,
String comment,
boolean required)
Constructor for a
AbstractSelectionParameter . |
AbstractSelectionParameter(DataType datatype,
String[] keys,
Object[] values,
String name,
String comment,
boolean required)
Constructor for a
AbstractSelectionParameter of SimpleParameter s. |
AbstractSelectionParameter(StringBuffer representation)
The standard constructor for the interface
Storable . |
AbstractSelectionParameter(String name,
String comment,
boolean required,
Class<? extends ParameterSet>... values)
|
AbstractSelectionParameter(String name,
String comment,
boolean required,
ParameterSet... values)
Constructor for a
AbstractSelectionParameter from an array of
ParameterSet s. |
Modifier and Type | Method and Description |
---|---|
protected void |
appendFurtherInfos(StringBuffer buf)
This method can be used in the method
Storable.toXML() to extract
further information (name, comment, datatype). |
protected int |
check(Object value)
MSPDTest whether a given
value can be used in Parameter.setValue(Object) . |
boolean |
checkValue(Object value)
Returns
true if the key specified by value is
in the set of keys of this AbstractSelectionParameter . |
AbstractSelectionParameter |
clone() |
protected void |
createParameterSet(Object[] values,
String[] keys,
String[] comments)
Creates a new
ParameterSet from an array of values, an array of
names and an array of comments. |
boolean |
equals(Object o2) |
protected void |
extractFurtherInfos(StringBuffer representation)
This method can be used in the constructor with parameter
StringBuffer to
extract the further information. |
String |
getErrorMessage()
If a value could not be set successfully this method returns the
corresponding error message.
|
ParameterSet |
getParametersInCollection()
Returns the possible values in this collection.
|
MultiSelectionParameter |
getRangedInstance()
Returns an instance of
RangeIterator that has the same properties
as the current instance, but accepts a range or list of values. |
abstract boolean |
hasDefault()
Returns
true , if this AbstractSelectionParameter has a
default value. |
boolean |
isAtomic()
Returns
true if the parameter is of an atomic data type,
false otherwise. |
boolean |
isComparable(Parameter p)
This method checks whether the given
Parameter is comparable to the current instance, i.e. |
boolean |
isRangeable()
Returns
true if the parameters can be varied over a range of
values. |
boolean |
isRequired()
|
abstract boolean |
isSelected(int idx)
Returns
true if the option at position idx is
selected. |
boolean |
isSet()
Returns
true if the parameter was set by the user,
false otherwise. |
boolean |
isUserSelected()
Returns
true if the value was selected by the user. |
abstract void |
setDefault(Object defaultValue)
Sets the default value of this
AbstractSelectionParameter to
defaultValue . |
void |
setRangeable(boolean rangeable)
Sets the value returned by
isRangeable() to
rangeable . |
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 . |
getParent, hasDefaultOrIsSet, reset, setParent, setValue
getComment, getDatatype, getName, getValue, getXMLTag, toXML
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
fromGalaxy
protected ParameterSet parameters
ParameterSet
that holds the possible valuesprotected boolean userSelected
true
if the user has selected an itemprotected String errorMessage
public AbstractSelectionParameter(DataType datatype, String[] keys, Object[] values, String name, String comment, boolean required) throws AbstractSelectionParameter.InconsistentCollectionException, SimpleParameter.IllegalValueException, SimpleParameter.DatatypeNotValidException
AbstractSelectionParameter
of SimpleParameter
s.datatype
- the data type of the parameters in the collectionkeys
- the keys/names of the values in the collection, this is the
name the user will see in the user interfacevalues
- the values the names stand for, this array must be of the same
length as keys
, a key at a certain position
belongs to the value at the same position in the arrayname
- the name of the parametercomment
- a comment on the parameterrequired
- true
if this AbstractSelectionParameter
is
required, false
otherwiseAbstractSelectionParameter.InconsistentCollectionException
- if the length of keys
and the
values
is different or the collection is
inconsistent for some other reasonSimpleParameter.IllegalValueException
- if one of the values in values
is not of type
datatype
SimpleParameter.DatatypeNotValidException
- if the datatype
is not one of the allowed valuesAbstractSelectionParameter(DataType, String[], Object[], String[], String, String, boolean)
,
SimpleParameter
public AbstractSelectionParameter(DataType datatype, String[] keys, Object[] values, String[] comments, String name, String comment, boolean required) throws AbstractSelectionParameter.InconsistentCollectionException, SimpleParameter.IllegalValueException, SimpleParameter.DatatypeNotValidException
AbstractSelectionParameter
.datatype
- the data type of the parameters in the collectionkeys
- the keys/names of the values in the collection, this is the
name the user will see in the user interfacevalues
- the values the names stand for, this array must be of the same
length as keys
, a key at a certain position
belongs to the value at the same position in the arraycomments
- the comments on the possible valuesname
- the name of the parametercomment
- a comment on the parameterrequired
- true
if the AbstractSelectionParameter
is
required, false
otherwiseAbstractSelectionParameter.InconsistentCollectionException
- if the length of keys
and values
is
different or the collection is inconsistent for some other
reasonSimpleParameter.IllegalValueException
- if one of the values in values
is not of type
datatype
SimpleParameter.DatatypeNotValidException
- if the datatype
is not one of the allowed valuescreateParameterSet(Object[], String[], String[])
public AbstractSelectionParameter(String name, String comment, boolean required, ParameterSet... values)
AbstractSelectionParameter
from an array of
ParameterSet
s. This constructor can be used to easily construct a
AbstractSelectionParameter
that lets the user select from a list of
possible options that all require an own set of Parameter
s to be
instantiated.values
- the array of ParameterSet
sname
- the name of the parametercomment
- a comment on the parameterrequired
- true
if the parameter is required,
false
otherwisecreateParameterSet(Object[], String[], String[])
,
ParameterSet.getName(ParameterSet)
,
ParameterSet.getComment(ParameterSet)
public AbstractSelectionParameter(String name, String comment, boolean required, Class<? extends ParameterSet>... values)
AbstractSelectionParameter
from an array of
Class
es of ParameterSet
s. This constructor can be used to easily construct a
AbstractSelectionParameter
that lets the user select from a list of
possible options that all require an own set of Parameter
s to be
instantiated. It is the lazy evaluation variant of AbstractSelectionParameter(String, String, boolean, ParameterSet...)
,
i.e., the ParameterSet
s are only created if necessary.values
- the array of Class
es of ParameterSet
sname
- the name of the parametercomment
- a comment on the parameterrequired
- true
if the parameter is required,
false
otherwisecreateParameterSet(Object[], String[], String[])
,
ParameterSet.getName(ParameterSet)
,
ParameterSet.getComment(ParameterSet)
public AbstractSelectionParameter(StringBuffer representation) throws NonParsableException
Storable
.
Restores an instance of AbstractSelectionParameter
from a XML
representation.representation
- the XML representation as StringBuffer
NonParsableException
- if the StringBuffer
representation
could
not be parsedprotected void createParameterSet(Object[] values, String[] keys, String[] comments) throws SimpleParameter.DatatypeNotValidException, SimpleParameter.IllegalValueException, AbstractSelectionParameter.InconsistentCollectionException
ParameterSet
from an array of values, an array of
names and an array of comments.values
- the values the names stand for, this array must be of the same
length as keys
, a key at a certain position
belongs to the value at the same position in the arraykeys
- the keys/names of the values in the collection, this is the
name the user will see in the user interfacecomments
- the comments on the possible valuesSimpleParameter.IllegalValueException
- if one of the values in values
is not of type
datatype
SimpleParameter.DatatypeNotValidException
- if the data type is not allowed, i.e. is not one of the
primitive data types, String
or
DataType.PARAMETERSET
AbstractSelectionParameter.InconsistentCollectionException
- if the internally used keys are not uniquepublic AbstractSelectionParameter clone() throws CloneNotSupportedException
clone
in class Parameter
CloneNotSupportedException
public boolean isAtomic()
Parameter
true
if the parameter is of an atomic data type,
false
otherwise.public abstract boolean hasDefault()
true
, if this AbstractSelectionParameter
has a
default value.AbstractSelectionParameter
has a default valuesetDefault(Object)
public boolean isSet()
Parameter
true
if the parameter was set by the user,
false
otherwise.public ParameterSet getParametersInCollection()
public void setRangeable(boolean rangeable)
isRangeable()
to
rangeable
.rangeable
- the new valuepublic boolean isComparable(Parameter p)
Parameter
Parameter
is comparable to the current instance, i.e. whether
the Class
, the DataType
, the name and the comment are identical. If necessary, all these
characteristics are checked recursively.
In other words, the method returns true
if the parameters only differ in their specific raw values.isComparable
in class Parameter
p
- the Parameter
for the comparisontrue
if the parameters only differ in their values, otherwise false
Object.getClass()
,
AnnotatedEntity.getDatatype()
,
AnnotatedEntity.getName()
,
AnnotatedEntity.getComment()
,
DataType.PARAMETERSET
,
ParameterSet.isComparable(ParameterSet)
public boolean isRangeable()
Rangeable
true
if the parameters can be varied over a range of
values.isRangeable
in interface Rangeable
true
if the parameter can be varied,
false
otherwiseprotected int check(Object value)
value
can be used in Parameter.setValue(Object)
.
If so, the index of corresponding option is returned, otherwise -1.value
- the value to be checkederrorMessage
,
checkValue(Object)
public boolean checkValue(Object value)
true
if the key specified by value
is
in the set of keys of this AbstractSelectionParameter
.checkValue
in class Parameter
value
- the value to be checkedtrue
if the key specified by value
is
in the set of keys of this AbstractSelectionParameter
,
false
otherwisepublic String getErrorMessage()
Parameter
getErrorMessage
in class Parameter
protected void appendFurtherInfos(StringBuffer buf)
AnnotatedEntity
Storable.toXML()
to extract
further information (name, comment, datatype).appendFurtherInfos
in class Parameter
buf
- a XML representation of the main information as
StringBuffer
Storable.toXML()
protected void extractFurtherInfos(StringBuffer representation) throws NonParsableException
AnnotatedEntity
StringBuffer
to
extract the further information.extractFurtherInfos
in class Parameter
representation
- a XML represenation of the main information as
StringBuffer
NonParsableException
- if the XML representation is not parsableAnnotatedEntity.AnnotatedEntity(StringBuffer)
public boolean isRequired()
Parameter
isRequired
in class Parameter
true
if the Parameter
is required,
false
otherwisepublic abstract boolean isSelected(int idx)
true
if the option at position idx
is
selected.idx
- the positiontrue
if the option at position idx
is
selected, false
otherwisepublic boolean isUserSelected()
true
if the value was selected by the user.true
if the value was selected by the user.public abstract void setDefault(Object defaultValue) throws Exception
AbstractSelectionParameter
to
defaultValue
. This method also sets the current
value of this AbstractSelectionParameter
to the default
and resets it such that isUserSelected()
returns false
.setDefault
in class Parameter
defaultValue
- the default valueException
- if the default value is not an appropriate value for this
Parameter
public MultiSelectionParameter getRangedInstance() throws Exception
Rangeable
RangeIterator
that has the same properties
as the current instance, but accepts a range or list of values. These
values can be obtained by the methods of RangeIterator
.getRangedInstance
in interface Rangeable
Exception
- is thrown if Rangeable.isRangeable()
returns
false
or the ranged instance could not be
created for some other reasonpublic 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 fails