|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.AnnotatedEntity
de.jstacs.parameters.Parameter
de.jstacs.parameters.AbstractSelectionParameter
de.jstacs.parameters.SelectionParameter
public class SelectionParameter
Class for a collection parameter, i.e. a parameter that provides some
collection of possible values the user can choose from. Instances of this
class can be used as parameters in a ParameterSet
.
ParameterSet
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 | |
---|---|
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)
Constructor for a SelectionParameter from an array of
Class es of ParameterSet s. |
|
SelectionParameter(String name,
String comment,
boolean required,
ParameterSet... values)
Constructor for a SelectionParameter from an array of
ParameterSet s. |
Method Summary | |
---|---|
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)
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()
|
Methods inherited from class de.jstacs.parameters.AbstractSelectionParameter |
---|
check, checkValue, clone, createParameterSet, equals, 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, wait, wait, wait |
Methods inherited from interface de.jstacs.parameters.Rangeable |
---|
getRangedInstance, isRangeable |
Methods inherited from interface de.jstacs.parameters.GalaxyConvertible |
---|
toGalaxy |
Constructor Detail |
---|
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
otherwise
InconsistentCollectionException
- if the length of keys
and the
values
is 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
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
otherwise
InconsistentCollectionException
- if the length of keys
and values
is
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
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 parsedMethod Detail |
---|
public 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 position
true
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 value
SimpleParameter.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 value
SimpleParameter.IllegalValueException
public void reset()
Parameter
null
if no defaults are given.
reset
in class Parameter
public Object getValue()
AnnotatedEntity
AnnotatedEntity
.
getValue
in class AnnotatedEntity
AnnotatedEntity
public String toString()
toString
in class 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 All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |