public class MultiSelectionParameter extends AbstractSelectionParameter implements RangeIterator
Parameter
that provides a collection of possible values.
The user can select one or more values out of the collection as values of
this Parameter
.AbstractSelectionParameter
AbstractSelectionParameter.InconsistentCollectionException
errorMessage, parameters, userSelected
comment, datatype, name
Constructor and Description |
---|
MultiSelectionParameter(DataType datatype,
String[] keys,
Object[] values,
String[] comments,
String name,
String comment,
boolean required)
Constructor for a
MultiSelectionParameter . |
MultiSelectionParameter(DataType datatype,
String[] keys,
Object[] values,
String name,
String comment,
boolean required)
Constructor for a
MultiSelectionParameter . |
MultiSelectionParameter(StringBuffer representation)
The standard constructor for the interface
Storable . |
MultiSelectionParameter(String name,
String comment,
boolean required,
Class<? extends ParameterSet>... values)
|
MultiSelectionParameter(String name,
String comment,
boolean required,
ParameterSet... values)
Creates a new
MultiSelectionParameter from an array of
ParameterSet s. |
Modifier and Type | Method and Description |
---|---|
protected void |
appendFurtherInfos(StringBuffer sup)
This method can be used in the method
Storable.toXML() to extract
further information (name, comment, datatype). |
boolean |
checkValue(Object value)
Returns
true if the key specified by value is
in the set of keys of this AbstractSelectionParameter . |
MultiSelectionParameter |
clone() |
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. |
int |
getNumberOfNexts(int afterIdx)
Returns the number of calls of
next() that can be called
before false is returned. |
int |
getNumberOfValues()
Returns the number of values in the collection.
|
int[] |
getSelected()
Returns the indexes of the selected options.
|
Object |
getValue()
Returns the value of the
AnnotatedEntity . |
Object |
getValueFor(int idx)
Returns the value of the option with no.
|
Object |
getValueFor(String key)
Returns the value for the option with key
key . |
Object[] |
getValues()
Returns the values of all selected options as an array.
|
String |
getXMLTag()
This method returns a tag used as outer tag of the XML description.
|
boolean |
hasDefault()
Returns
true , if this AbstractSelectionParameter 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 |
isRanged()
Returns
true if this RangeIterator is ranging over a
set of values. |
boolean |
isSelected(int idx)
Returns
true if the option at position idx is
selected. |
boolean |
isSelected(String key)
Returns the selection value of the option with key
key . |
boolean |
next()
Switches to the next value in the collection of values in the specified
range.
|
void |
reset()
Resets the parameter and its contents to the default values or
null if no defaults are given. |
void |
resetToFirst()
Resets the current value in the collection to the first value.
|
void |
setDefault(Object defaultValue)
Sets the default value of this
AbstractSelectionParameter to
defaultValue . |
void |
setDefaultSelected(int[] defaultSelection)
Sets the default selection of this
MultiSelectionParameter to
defaultSelection . |
boolean |
setSelected(int idx,
boolean selected)
Sets the selection of option with no.
|
boolean |
setSelected(String key,
boolean selected)
Sets the selection of the option with key
key to the value
of selected . |
void |
setValue(Object value)
Sets the value of this
Parameter to value . |
String |
valuesToString()
Returns a
String representation of the set of values. |
check, createParameterSet, equals, getErrorMessage, getParametersInCollection, getRangedInstance, isAtomic, isComparable, isRangeable, isRequired, isSet, isUserSelected, setRangeable, toGalaxy
getComment, getDatatype, getName, toXML
public MultiSelectionParameter(DataType datatype, String[] keys, Object[] values, String name, String comment, boolean required) throws AbstractSelectionParameter.InconsistentCollectionException, SimpleParameter.IllegalValueException, SimpleParameter.DatatypeNotValidException
MultiSelectionParameter
. The first
option in the selection is selected by default.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 the parameter is required,
false
otherwiseInconsistentCollectionException
- if the lengths of keys
and values
are 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
public MultiSelectionParameter(DataType datatype, String[] keys, Object[] values, String[] comments, String name, String comment, boolean required) throws AbstractSelectionParameter.InconsistentCollectionException, SimpleParameter.IllegalValueException, SimpleParameter.DatatypeNotValidException
MultiSelectionParameter
. The first
option in the selection is selected by default.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 values in the collectionname
- the name of the parametercomment
- a comment on the parameterrequired
- true
if the parameter is required,
false
otherwiseInconsistentCollectionException
- if the lengths of keys
and values
are 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
public MultiSelectionParameter(String name, String comment, boolean required, ParameterSet... values)
MultiSelectionParameter
from an array of
ParameterSet
s. The first option in the selection is selected by
default.values
- the options/values in the collectionname
- the name of this MultiSelectionParameter
comment
- the comment on this MultiSelectionParameter
required
- true
if this
MultiSelectionParameter
is required,
false
otherwisepublic MultiSelectionParameter(String name, String comment, boolean required, Class<? extends ParameterSet>... values)
MultiSelectionParameter
from an array of
Class
es of ParameterSet
s. The first option in the selection is selected by
default. It is the lazy evaluation variant of MultiSelectionParameter(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 this MultiSelectionParameter
comment
- the comment on this MultiSelectionParameter
required
- true
if this
MultiSelectionParameter
is required,
false
otherwisepublic MultiSelectionParameter(StringBuffer representation) throws NonParsableException
Storable
.
Creates a new MultiSelectionParameter
from its XML
representationrepresentation
- the XML representation as StringBuffer
NonParsableException
- if the StringBuffer
representation
could
not be parsedpublic MultiSelectionParameter clone() throws CloneNotSupportedException
clone
in class AbstractSelectionParameter
CloneNotSupportedException
public boolean setSelected(String key, boolean selected)
key
to the value
of selected
.key
- the key of the optionselected
- the selection valuetrue
if the key could be found and set,
false
otherwisepublic boolean isSelected(String key)
key
.key
- the key of the optionfalse
if no such option
existspublic Object getValueFor(String key)
key
.key
- the key of the optionnull
if the corresponding option either
does not exist or is not selectedpublic boolean checkValue(Object value)
AbstractSelectionParameter
true
if the key specified by value
is
in the set of keys of this AbstractSelectionParameter
.checkValue
in class AbstractSelectionParameter
value
- the value to be checkedtrue
if the key specified by value
is
in the set of keys of this AbstractSelectionParameter
,
false
otherwisepublic void setValue(Object value) throws SimpleParameter.IllegalValueException
Parameter
Parameter
to value
.setValue
in class Parameter
value
- the new value of the Parameter
SimpleParameter.IllegalValueException
- if the specified value is not valid for this
Parameter
public int[] getSelected()
public boolean setSelected(int idx, boolean selected)
idx
to
selected
.idx
- the index of the optionselected
- the selection valuetrue
if the option exists and could be set,
false
otherwisepublic boolean isSelected(int idx)
AbstractSelectionParameter
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 Object getValueFor(int idx)
idx
.idx
- the index of the optionnull
if the corresponding option either
does not exists or is not selectedpublic Object[] getValues()
public Object getValue()
AnnotatedEntity
AnnotatedEntity
.getValue
in class AnnotatedEntity
AnnotatedEntity
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 void reset()
Parameter
null
if no defaults are given.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 setDefaultSelected(int[] defaultSelection)
MultiSelectionParameter
to
defaultSelection
. This method also sets the current
selection of this MultiSelectionParameter
to the default
and resets it such that AbstractSelectionParameter.isUserSelected()
returns false
.defaultSelection
- the new default selectionpublic String getXMLTag()
AnnotatedEntity
getXMLTag
in class AnnotatedEntity
protected void appendFurtherInfos(StringBuffer sup)
AnnotatedEntity
Storable.toXML()
to extract
further information (name, comment, datatype).appendFurtherInfos
in class AbstractSelectionParameter
sup
- 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 next() throws ParameterException
RangeIterator
next
in interface RangeIterator
true
if the next element exists, false
otherwiseParameterException
- if the next value could not be fetchedpublic void resetToFirst()
RangeIterator
resetToFirst
in interface RangeIterator
public int getNumberOfValues()
RangeIterator
getNumberOfValues
in interface RangeIterator
public int getNumberOfNexts(int afterIdx)
next()
that can be called
before false
is returned.afterIdx
- the index after which shall be countednext()
public String valuesToString()
RangeIterator
String
representation of the set of values.valuesToString
in interface RangeIterator
String
representationpublic boolean isRanged()
RangeIterator
true
if this RangeIterator
is ranging over a
set of values.isRanged
in interface RangeIterator
true
if this RangeIterator
is ranging over a
set of values, false
otherwisepublic boolean hasDefault()
AbstractSelectionParameter
true
, if this AbstractSelectionParameter
has a
default value.hasDefault
in class AbstractSelectionParameter
AbstractSelectionParameter
has a default valueAbstractSelectionParameter.setDefault(Object)
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