public class SelectionParameter extends AbstractSelectionParameter implements Rangeable, GalaxyConvertible
ParameterSet
.ParameterSet
AbstractSelectionParameter.InconsistentCollectionException
errorMessage, parameters, userSelected
comment, datatype, name
Constructor and Description |
---|
SelectionParameter(DataType datatype,
String[] keys,
Object[] values,
String[] comments,
String name,
String comment,
boolean required)
Constructor for a
SelectionParameter . |
SelectionParameter(DataType datatype,
String[] keys,
Object[] values,
String name,
String comment,
boolean required)
Constructor for a
SelectionParameter . |
SelectionParameter(StringBuffer representation)
The standard constructor for the interface
Storable . |
SelectionParameter(String name,
String comment,
boolean required,
Class<? extends ParameterSet>... values)
|
SelectionParameter(String name,
String comment,
boolean required,
ParameterSet... values)
Constructor for a
SelectionParameter 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 void |
extractFurtherInfos(StringBuffer representation)
This method can be used in the constructor with parameter
StringBuffer to
extract the further information. |
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 int |
getDefault()
Returns the index of the default selected value.
|
String |
getErrorMessage()
If a value could not be set successfully this method returns the
corresponding error message.
|
int |
getSelected()
Returns the index of the selected value.
|
Object |
getValue()
Returns the value of the
AnnotatedEntity . |
String |
getXMLTag()
This method returns a tag used as outer tag of the XML description.
|
boolean |
hasDefault()
Returns
true , if this SelectionParameter has a
default value. |
boolean |
hasDefaultOrIsSet()
Returns
true if the parameter either has a default value or
the value was set by the user, false otherwise. |
boolean |
isSelected(int idx)
Returns
true if the option at position idx is
selected. |
void |
reset()
Resets the parameter and its contents to the default values or
null if no defaults are given. |
void |
setDefault(Object defaultValue)
Sets the default value of this
AbstractSelectionParameter to
defaultValue . |
void |
setValue(Object value)
Sets the selected value to the one that is specified by the key
value . |
String |
toString() |
check, checkValue, clone, createParameterSet, equals, getParametersInCollection, getRangedInstance, isAtomic, isComparable, isRangeable, isRequired, isSet, isUserSelected, setRangeable, toGalaxy
getComment, getDatatype, getName, toXML
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getRangedInstance, isRangeable
toGalaxy
public SelectionParameter(DataType datatype, String[] keys, Object[] values, String name, String comment, boolean required) throws AbstractSelectionParameter.InconsistentCollectionException, SimpleParameter.IllegalValueException, SimpleParameter.DatatypeNotValidException
SelectionParameter
.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 SelectionParameter
is
required, false
otherwiseInconsistentCollectionException
- 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.InconsistentCollectionException
AbstractSelectionParameter.AbstractSelectionParameter(DataType, String[], Object[], String[], String, String, boolean)
public SelectionParameter(DataType datatype, String[] keys, Object[] values, String[] comments, String name, String comment, boolean required) throws AbstractSelectionParameter.InconsistentCollectionException, SimpleParameter.IllegalValueException, SimpleParameter.DatatypeNotValidException
SelectionParameter
.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 SelectionParameter
is
required, false
otherwiseInconsistentCollectionException
- 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 valuesAbstractSelectionParameter.InconsistentCollectionException
AbstractSelectionParameter.createParameterSet(Object[], String[], String[])
public SelectionParameter(String name, String comment, boolean required, ParameterSet... values)
SelectionParameter
from an array of
ParameterSet
s. This constructor can be used to easily construct a
SelectionParameter
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
otherwiseAbstractSelectionParameter.createParameterSet(Object[], String[], String[])
public SelectionParameter(String name, String comment, boolean required, Class<? extends ParameterSet>... values)
SelectionParameter
from an array of
Class
es of ParameterSet
s. This constructor can be used to easily construct a
SelectionParameter
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 SelectionParameter(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
otherwiseAbstractSelectionParameter.createParameterSet(Object[], String[], String[])
public SelectionParameter(StringBuffer representation) throws NonParsableException
Storable
.
Restores an instance of SelectionParameter
from a XML
representation.representation
- the XML representation as StringBuffer
NonParsableException
- if the StringBuffer
representation
could
not be parsedpublic boolean hasDefault()
true
, if this SelectionParameter
has a
default value.hasDefault
in class AbstractSelectionParameter
SelectionParameter
has a default valueAbstractSelectionParameter.setDefault(Object)
public boolean hasDefaultOrIsSet()
Parameter
true
if the parameter either has a default value or
the value was set by the user, false
otherwise.hasDefaultOrIsSet
in class Parameter
true
if value has a default value or was set,
false
otherwisepublic String getErrorMessage()
Parameter
getErrorMessage
in class AbstractSelectionParameter
public String getXMLTag()
AnnotatedEntity
getXMLTag
in class AnnotatedEntity
protected void appendFurtherInfos(StringBuffer buf)
AnnotatedEntity
Storable.toXML()
to extract
further information (name, comment, datatype).appendFurtherInfos
in class AbstractSelectionParameter
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 AbstractSelectionParameter
representation
- a XML represenation of the main information as
StringBuffer
NonParsableException
- if the XML representation is not parsableAnnotatedEntity.AnnotatedEntity(StringBuffer)
public boolean isSelected(int idx)
true
if the option at position idx
is
selected.isSelected
in class AbstractSelectionParameter
idx
- the positiontrue
if the option at position idx
is
selected, false
otherwisepublic int getSelected()
protected int getDefault()
public void setValue(Object value) throws SimpleParameter.IllegalValueException
value
.setValue
in class Parameter
value
- the key of the desired valueSimpleParameter.IllegalValueException
- if the specified value is not valid for this
Parameter
public void setDefault(Object defaultValue) throws SimpleParameter.IllegalValueException
AbstractSelectionParameter
AbstractSelectionParameter
to
defaultValue
. This method also sets the current
value of this AbstractSelectionParameter
to the default
and resets it such that AbstractSelectionParameter.isUserSelected()
returns false
.setDefault
in class AbstractSelectionParameter
defaultValue
- the default valueSimpleParameter.IllegalValueException
public void reset()
Parameter
null
if no defaults are given.public Object getValue()
AnnotatedEntity
AnnotatedEntity
.getValue
in class AnnotatedEntity
AnnotatedEntity
public 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 parsed