|
||||||||||
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
public abstract class AbstractSelectionParameter
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 | |
---|---|
class |
AbstractSelectionParameter.InconsistentCollectionException
This exception is thrown if the AbstractSelectionParameter is
inconsistent for some reason. |
Field Summary | |
---|---|
protected String |
errorMessage
If a value was illegal for the collection parameter, this field holds the error message. |
protected ParameterSet |
parameters
The internal ParameterSet that holds the possible values |
protected boolean |
userSelected
true if the user has selected an item |
Fields inherited from class de.jstacs.parameters.Parameter |
---|
parent |
Fields inherited from class de.jstacs.AnnotatedEntity |
---|
comment, datatype, name |
Constructor Summary | |
---|---|
AbstractSelectionParameter(DataType datatype,
String[] keys,
Object[] values,
String[] comments,
String name,
String comment,
boolean required)
Constructor for a AbstractSelectionParameter . |
|
AbstractSelectionParameter(DataType datatype,
String[] keys,
Object[] values,
String name,
String comment,
boolean required)
Constructor for a AbstractSelectionParameter of SimpleParameter s. |
|
AbstractSelectionParameter(StringBuffer representation)
The standard constructor for the interface Storable . |
|
AbstractSelectionParameter(String name,
String comment,
boolean required,
Class<? extends ParameterSet>... values)
Constructor for a AbstractSelectionParameter from an array of
Class es of ParameterSet s. |
|
AbstractSelectionParameter(String name,
String comment,
boolean required,
ParameterSet... values)
Constructor for a AbstractSelectionParameter 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 int |
check(Object value)
Test whether a given value can be used in Parameter.setValue(Object) . |
boolean |
checkValue(Object value)
Returns true if the key specified by value is
in the set of keys of this AbstractSelectionParameter . |
AbstractSelectionParameter |
clone()
|
protected void |
createParameterSet(Object[] values,
String[] keys,
String[] comments)
Creates a new ParameterSet from an array of values, an array of
names and an array of comments. |
boolean |
equals(Object o2)
|
protected void |
extractFurtherInfos(StringBuffer representation)
This method can be used in the constructor with parameter StringBuffer to
extract the further information. |
String |
getErrorMessage()
If a value could not be set successfully this method returns the corresponding error message. |
ParameterSet |
getParametersInCollection()
Returns the possible values in this collection. |
MultiSelectionParameter |
getRangedInstance()
Returns an instance of RangeIterator that has the same properties
as the current instance, but accepts a range or list of values. |
abstract boolean |
hasDefault()
Returns true , if this AbstractSelectionParameter has a
default value. |
boolean |
isAtomic()
Returns true if the parameter is of an atomic data type,
false otherwise. |
boolean |
isRangeable()
Returns true if the parameters can be varied over a range of
values. |
boolean |
isRequired()
Returns true if the Parameter is required,
false otherwise. |
abstract boolean |
isSelected(int idx)
Returns true if the option at position idx is
selected. |
boolean |
isSet()
Returns true if the parameter was set by the user,
false otherwise. |
boolean |
isUserSelected()
Returns true if the value was selected by the user. |
abstract void |
setDefault(Object defaultValue)
Sets the default value of this AbstractSelectionParameter to
defaultValue . |
void |
setRangeable(boolean rangeable)
Sets the value returned by isRangeable() to
rangeable . |
void |
toGalaxy(String namePrefix,
String configPrefix,
int depth,
StringBuffer descBuffer,
StringBuffer configBuffer)
Creates an Galaxy XML-representation of the parameters and appends it to descBuffer
and variable configuration and appends it to configBuffer . |
Methods inherited from class de.jstacs.parameters.Parameter |
---|
getParent, hasDefaultOrIsSet, isComparable, reset, setParent, setValue |
Methods inherited from class de.jstacs.AnnotatedEntity |
---|
getComment, getDatatype, getName, getValue, getXMLTag, toXML |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface de.jstacs.parameters.GalaxyConvertible |
---|
fromGalaxy |
Field Detail |
---|
protected ParameterSet parameters
ParameterSet
that holds the possible values
protected boolean userSelected
true
if the user has selected an item
protected String errorMessage
Constructor Detail |
---|
public AbstractSelectionParameter(DataType datatype, String[] keys, Object[] values, String name, String comment, boolean required) throws AbstractSelectionParameter.InconsistentCollectionException, SimpleParameter.IllegalValueException, SimpleParameter.DatatypeNotValidException
AbstractSelectionParameter
of SimpleParameter
s.
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 AbstractSelectionParameter
is
required, false
otherwise
AbstractSelectionParameter.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 valuesAbstractSelectionParameter(DataType, String[], Object[], String[], String, String, boolean)
,
SimpleParameter
public AbstractSelectionParameter(DataType datatype, String[] keys, Object[] values, String[] comments, String name, String comment, boolean required) throws AbstractSelectionParameter.InconsistentCollectionException, SimpleParameter.IllegalValueException, SimpleParameter.DatatypeNotValidException
AbstractSelectionParameter
.
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 AbstractSelectionParameter
is
required, false
otherwise
AbstractSelectionParameter.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 valuescreateParameterSet(Object[], String[], String[])
public AbstractSelectionParameter(String name, String comment, boolean required, ParameterSet... values)
AbstractSelectionParameter
from an array of
ParameterSet
s. This constructor can be used to easily construct a
AbstractSelectionParameter
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
otherwisecreateParameterSet(Object[], String[], String[])
,
ParameterSet.getName(ParameterSet)
,
ParameterSet.getComment(ParameterSet)
public AbstractSelectionParameter(String name, String comment, boolean required, Class<? extends ParameterSet>... values)
AbstractSelectionParameter
from an array of
Class
es of ParameterSet
s. This constructor can be used to easily construct a
AbstractSelectionParameter
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 AbstractSelectionParameter(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
otherwisecreateParameterSet(Object[], String[], String[])
,
ParameterSet.getName(ParameterSet)
,
ParameterSet.getComment(ParameterSet)
public AbstractSelectionParameter(StringBuffer representation) throws NonParsableException
Storable
.
Restores an instance of AbstractSelectionParameter
from a XML
representation.
representation
- the XML representation as StringBuffer
NonParsableException
- if the StringBuffer
representation
could
not be parsedMethod Detail |
---|
protected void createParameterSet(Object[] values, String[] keys, String[] comments) throws SimpleParameter.DatatypeNotValidException, SimpleParameter.IllegalValueException, AbstractSelectionParameter.InconsistentCollectionException
ParameterSet
from an array of values, an array of
names and an array of comments.
values
- 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 arraykeys
- the keys/names of the values in the collection, this is the
name the user will see in the user interfacecomments
- the comments on the possible values
SimpleParameter.IllegalValueException
- if one of the values in values
is not of type
datatype
SimpleParameter.DatatypeNotValidException
- if the data type is not allowed, i.e. is not one of the
primitive data types, String
or
DataType.PARAMETERSET
AbstractSelectionParameter.InconsistentCollectionException
- if the internally used keys are not uniquepublic AbstractSelectionParameter clone() throws CloneNotSupportedException
clone
in class Parameter
CloneNotSupportedException
public boolean isAtomic()
Parameter
true
if the parameter is of an atomic data type,
false
otherwise.
isAtomic
in class Parameter
true
if the parameter is atomic, false
otherwisepublic abstract boolean hasDefault()
true
, if this AbstractSelectionParameter
has a
default value.
AbstractSelectionParameter
has a default valuesetDefault(Object)
public boolean isSet()
Parameter
true
if the parameter was set by the user,
false
otherwise.
isSet
in class Parameter
true
if the parameter was set, false
otherwisepublic ParameterSet getParametersInCollection()
public void setRangeable(boolean rangeable)
isRangeable()
to
rangeable
.
rangeable
- the new valuepublic boolean isRangeable()
Rangeable
true
if the parameters can be varied over a range of
values.
isRangeable
in interface Rangeable
true
if the parameter can be varied,
false
otherwiseprotected int check(Object value)
value
can be used in Parameter.setValue(Object)
.
If so, the index of corresponding option is returned, otherwise -1.
value
- the value to be checked
errorMessage
,
checkValue(Object)
public boolean checkValue(Object value)
true
if the key specified by value
is
in the set of keys of this AbstractSelectionParameter
.
checkValue
in class Parameter
value
- the value to be checked
true
if the key specified by value
is
in the set of keys of this AbstractSelectionParameter
,
false
otherwisepublic String getErrorMessage()
Parameter
getErrorMessage
in class Parameter
protected void appendFurtherInfos(StringBuffer buf)
AnnotatedEntity
Storable.toXML()
to extract
further information (name, comment, datatype).
appendFurtherInfos
in class Parameter
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 Parameter
representation
- a XML represenation of the main information as
StringBuffer
NonParsableException
- if the XML representation is not parsableAnnotatedEntity.AnnotatedEntity(StringBuffer)
public boolean isRequired()
Parameter
true
if the Parameter
is required,
false
otherwise.
isRequired
in class Parameter
true
if the Parameter
is required,
false
otherwisepublic abstract boolean isSelected(int idx)
true
if the option at position idx
is
selected.
idx
- the position
true
if the option at position idx
is
selected, false
otherwisepublic boolean isUserSelected()
true
if the value was selected by the user.
true
if the value was selected by the user.public abstract void setDefault(Object defaultValue) throws Exception
AbstractSelectionParameter
to
defaultValue
. This method also sets the current
value of this AbstractSelectionParameter
to the default
and resets it such that isUserSelected()
returns false
.
setDefault
in class Parameter
defaultValue
- the default value
AbstractSelectionParameter.InconsistentCollectionException
- if the default value is not an appropriate value for this
Parameter
Exception
public boolean equals(Object o2)
equals
in class Object
public MultiSelectionParameter getRangedInstance() throws Exception
Rangeable
RangeIterator
that has the same properties
as the current instance, but accepts a range or list of values. These
values can be obtained by the methods of RangeIterator
.
getRangedInstance
in interface Rangeable
Exception
- is thrown if Rangeable.isRangeable()
returns
false
or the ranged instance could not be
created for some other reasonpublic void toGalaxy(String namePrefix, String configPrefix, int depth, StringBuffer descBuffer, StringBuffer configBuffer) throws Exception
GalaxyConvertible
descBuffer
and variable configuration and appends it to configBuffer
. The variable configuation
is also used to parse user-supplied values returned by Galaxy.
toGalaxy
in interface GalaxyConvertible
namePrefix
- the prefix of the variable name used in GalaxyconfigPrefix
- the prefix for conditionalsdepth
- the depth in the parameter hierarchy, used for graphical representation of nestingdescBuffer
- the buffer for the parameter descriptionconfigBuffer
- the buffer for the configuration line
Exception
- if the conversion fails
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |