|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.jstacs.AnnotatedEntity de.jstacs.parameters.Parameter de.jstacs.parameters.AbstractSelectionParameter de.jstacs.parameters.MultiSelectionParameter
public class MultiSelectionParameter
Class for a 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
Nested Class Summary |
---|
Nested classes/interfaces inherited from class de.jstacs.parameters.AbstractSelectionParameter |
---|
AbstractSelectionParameter.InconsistentCollectionException |
Field Summary |
---|
Fields inherited from class de.jstacs.parameters.AbstractSelectionParameter |
---|
errorMessage, parameters, userSelected |
Fields inherited from class de.jstacs.parameters.Parameter |
---|
parent |
Fields inherited from class de.jstacs.AnnotatedEntity |
---|
comment, datatype, name |
Constructor Summary | |
---|---|
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)
Creates a new MultiSelectionParameter from an array of
Class es of ParameterSet s. |
|
MultiSelectionParameter(String name,
String comment,
boolean required,
ParameterSet... values)
Creates a new MultiSelectionParameter from an array of
ParameterSet s. |
Method Summary | |
---|---|
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)
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. |
Methods inherited from class de.jstacs.parameters.AbstractSelectionParameter |
---|
check, createParameterSet, equals, getErrorMessage, getParametersInCollection, getRangedInstance, isAtomic, isRangeable, isRequired, isSet, isUserSelected, setRangeable, toGalaxy |
Methods inherited from class de.jstacs.parameters.Parameter |
---|
getParent, isComparable, setParent |
Methods inherited from class de.jstacs.AnnotatedEntity |
---|
getComment, getDatatype, getName, toXML |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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
otherwise
InconsistentCollectionException
- if the lengths of keys
and values
are different or the collection is inconsistent for some
other reason
SimpleParameter.IllegalValueException
- if one of the values in values
is not of type
datatype
SimpleParameter.DatatypeNotValidException
- if the datatype
is not one of the allowed values
AbstractSelectionParameter.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
otherwise
InconsistentCollectionException
- if the lengths of keys
and values
are different or the collection is inconsistent for some
other reason
SimpleParameter.IllegalValueException
- if one of the values in values
is not of type
datatype
SimpleParameter.DatatypeNotValidException
- if the datatype
is not one of the allowed values
AbstractSelectionParameter.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
representation
representation
- the XML representation as StringBuffer
NonParsableException
- if the StringBuffer
representation
could
not be parsedMethod Detail |
---|
public 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 value
true
if the key could be found and set,
false
otherwisepublic boolean isSelected(String key)
key
.
key
- the key of the option
false
if no such option
existspublic Object getValueFor(String key)
key
.
key
- the key of the option
null
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 checked
true
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 value
true
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 position
true
if the option at position idx
is
selected, false
otherwisepublic Object getValueFor(int idx)
idx
.
idx
- the index of the option
null
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.
reset
in class 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 value
SimpleParameter.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
otherwise
ParameterException
- 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 counted
next()
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)
and sets the values of the Parameter
or ParameterSet
accordingly.
fromGalaxy
in interface GalaxyConvertible
namePrefix
- the prefix of the variable namecommand
- the command string
Exception
- if the command string could not be parsed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |