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.AbstractSelectionParameterAbstractSelectionParameter.InconsistentCollectionExceptionerrorMessage, parameters, userSelectedcomment, 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
ParameterSets. |
| 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, toGalaxygetComment, getDatatype, getName, toXMLpublic 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
datatypeSimpleParameter.DatatypeNotValidException - if the datatype is not one of the allowed valuesAbstractSelectionParameter.InconsistentCollectionExceptionpublic 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
datatypeSimpleParameter.DatatypeNotValidException - if the datatype is not one of the allowed valuesAbstractSelectionParameter.InconsistentCollectionExceptionpublic MultiSelectionParameter(String name, String comment, boolean required, ParameterSet... values)
MultiSelectionParameter from an array of
ParameterSets. The first option in the selection is selected by
default.values - the options/values in the collectionname - the name of this MultiSelectionParametercomment - the comment on this MultiSelectionParameterrequired - true if this
MultiSelectionParameter is required,
false otherwisepublic MultiSelectionParameter(String name, String comment, boolean required, Class<? extends ParameterSet>... values)
MultiSelectionParameter from an array of
Classes of ParameterSets. 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 ParameterSets are only created if necessary.values - the array of Classes of ParameterSetsname - the name of this MultiSelectionParametercomment - the comment on this MultiSelectionParameterrequired - 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 StringBufferNonParsableException - if the StringBuffer representation could
not be parsedpublic MultiSelectionParameter clone() throws CloneNotSupportedException
clone in class AbstractSelectionParameterCloneNotSupportedExceptionpublic 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)
AbstractSelectionParametertrue if the key specified by value is
in the set of keys of this AbstractSelectionParameter.checkValue in class AbstractSelectionParametervalue - 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
ParameterParameter to value.setValue in class Parametervalue - the new value of the ParameterSimpleParameter.IllegalValueException - if the specified value is not valid for this
Parameterpublic 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)
AbstractSelectionParametertrue if the option at position idx is
selected.isSelected in class AbstractSelectionParameteridx - 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()
AnnotatedEntityAnnotatedEntity.getValue in class AnnotatedEntityAnnotatedEntitypublic boolean hasDefaultOrIsSet()
Parametertrue if the parameter either has a default value or
the value was set by the user, false otherwise.hasDefaultOrIsSet in class Parametertrue if value has a default value or was set,
false otherwisepublic void reset()
Parameternull if no defaults are given.public void setDefault(Object defaultValue) throws SimpleParameter.IllegalValueException
AbstractSelectionParameterAbstractSelectionParameter 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 AbstractSelectionParameterdefaultValue - the default valueSimpleParameter.IllegalValueExceptionpublic 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()
AnnotatedEntitygetXMLTag in class AnnotatedEntityprotected void appendFurtherInfos(StringBuffer sup)
AnnotatedEntityStorable.toXML() to extract
further information (name, comment, datatype).appendFurtherInfos in class AbstractSelectionParametersup - a XML representation of the main information as
StringBufferStorable.toXML()protected void extractFurtherInfos(StringBuffer representation) throws NonParsableException
AnnotatedEntityStringBuffer to
extract the further information.extractFurtherInfos in class AbstractSelectionParameterrepresentation - a XML represenation of the main information as
StringBufferNonParsableException - if the XML representation is not parsableAnnotatedEntity.AnnotatedEntity(StringBuffer)public boolean next()
throws ParameterException
RangeIteratornext in interface RangeIteratortrue if the next element exists, false
otherwiseParameterException - if the next value could not be fetchedpublic void resetToFirst()
RangeIteratorresetToFirst in interface RangeIteratorpublic int getNumberOfValues()
RangeIteratorgetNumberOfValues in interface RangeIteratorpublic int getNumberOfNexts(int afterIdx)
next() that can be called
before false is returned.afterIdx - the index after which shall be countednext()public String valuesToString()
RangeIteratorString representation of the set of values.valuesToString in interface RangeIteratorString representationpublic 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 boolean hasDefault()
AbstractSelectionParametertrue, if this AbstractSelectionParameter has a
default value.hasDefault in class AbstractSelectionParameterAbstractSelectionParameter has a default valueAbstractSelectionParameter.setDefault(Object)public void fromGalaxy(String namePrefix, StringBuffer command) throws Exception
GalaxyConvertiblecommand 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 GalaxyConvertiblenamePrefix - the prefix of the variable namecommand - the command stringException - if the command string could not be parsed