|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.parameters.Parameter
de.jstacs.parameters.SimpleParameter
public class SimpleParameter
Class for a "simple" parameter. Simple parameters are those of the
primitive types and single String
s.
Nested Class Summary | |
---|---|
static class |
SimpleParameter.DatatypeNotValidException
Class for an Exception that can be thrown if the provided
int -value that represents a data type is not one of the
values defined in DataType . |
static class |
SimpleParameter.IllegalValueException
This exception is thrown if a parameter is not valid. |
Field Summary | |
---|---|
protected String |
comment
A comment on the parameter |
protected DataType |
datatype
The data type of the parameter value |
protected Object |
defaultValue
The default value of the parameter |
protected String |
name
The name of the parameter |
protected boolean |
required
Determines if the parameter is required |
protected ParameterValidator |
validator
The validator for the parameter values |
protected Object |
value
The current value of the parameter |
Fields inherited from class de.jstacs.parameters.Parameter |
---|
neededReference, neededReferenceId, parent |
Constructor Summary | |
---|---|
SimpleParameter(DataType datatype,
String name,
String comment,
boolean required)
Constructor for a SimpleParameter without
ParameterValidator . |
|
SimpleParameter(DataType datatype,
String name,
String comment,
boolean required,
Object defaultVal)
Constructor for a SimpleParameter without
ParameterValidator but with a default value. |
|
SimpleParameter(DataType datatype,
String name,
String comment,
boolean required,
ParameterValidator validator)
Constructor for a SimpleParameter with a
ParameterValidator . |
|
SimpleParameter(DataType datatype,
String name,
String comment,
boolean required,
ParameterValidator validator,
Object defaultVal)
Constructor for a SimpleParameter with validator and default
value. |
|
SimpleParameter(StringBuffer representation)
The standard constructor for the interface Storable . |
Method Summary | |
---|---|
boolean |
checkValue(Object value)
Checks the value for correctness, e.g. for numerical parameters this might be checking if the value is within specified bounds. |
SimpleParameter |
clone()
|
boolean |
equals(Object o2)
|
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 void |
fromXML(StringBuffer representation)
Parses a Parameter from a XML representation as returned by
Parameter.toXML() . |
String |
getComment()
Returns a comment on this Parameter that tells something about
useful values, domains, usage of this parameter, etc. |
DataType |
getDatatype()
Returns the data type of the Parameter . |
String |
getErrorMessage()
If a value could not be set successfully this method returns the corresponding error message. |
String |
getName()
Returns the name of the Parameter . |
Parameter |
getRangedInstance()
Returns an instance of RangeIterator that has the same properties
as the current instance, but accepts a range or list of values. |
ParameterValidator |
getValidator()
Returns the ParameterValidator used in this
SimpleParameter . |
Object |
getValue()
Returns the current value of this Parameter . |
boolean |
hasDefaultOrIsSet()
Returns true if the parameter either has a default value or
the value was set by the user, false otherwise. |
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. |
boolean |
isSet()
Returns true if the parameter was set by the user,
false otherwise. |
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 the Parameter to
defaultValue . |
void |
setRangeable(boolean rangeable)
Sets the value returned by isRangeable() to
rangeable . |
void |
setValidator(ParameterValidator validator)
Sets a new ParameterValidator for this SimpleParameter . |
void |
setValue(Object value2)
Sets the value of this Parameter to value . |
void |
simplify()
Simplifies the Parameter and its contents to the relevant
information. |
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 . |
String |
toString()
|
StringBuffer |
toXML()
This method returns an XML representation as StringBuffer of an
instance of the implementing class. |
Methods inherited from class de.jstacs.parameters.Parameter |
---|
getId, getNeededReference, getNeededReferenceId, getParent, setNeededReference, setParent |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected DataType datatype
protected String name
protected String comment
protected boolean required
protected Object value
protected Object defaultValue
protected ParameterValidator validator
Constructor Detail |
---|
public SimpleParameter(StringBuffer representation) throws NonParsableException
Storable
.
Constructs a SimpleParameter
out of an XML representation.
representation
- the XML representation as StringBuffer
NonParsableException
- if the SimpleParameter
could not be restored from the
StringBuffer
representation
public SimpleParameter(DataType datatype, String name, String comment, boolean required) throws SimpleParameter.DatatypeNotValidException
SimpleParameter
without
ParameterValidator
.
datatype
- the data type of the parameter valuename
- the name of the parametercomment
- a comment on the parameter that tells the user some details
about itrequired
- determines if the parameter is required
SimpleParameter.DatatypeNotValidException
- if datatype
is not one of the allowed
DataType
spublic SimpleParameter(DataType datatype, String name, String comment, boolean required, Object defaultVal) throws ParameterException
SimpleParameter
without
ParameterValidator
but with a default value.
datatype
- the data type of the parameter valuename
- the name of the parametercomment
- a comment on the parameter that tells the user some details
about itrequired
- determines if the parameter is requireddefaultVal
- the default value
ParameterException
- if either the default value is not a valid value with respect
to datatype
or datatype
is not in
the values allowed for a SimpleParameter
public SimpleParameter(DataType datatype, String name, String comment, boolean required, ParameterValidator validator) throws SimpleParameter.DatatypeNotValidException
SimpleParameter
with a
ParameterValidator
.
datatype
- the data type of the parameter valuename
- the name of the parametercomment
- a comment on the parameter that tells the user some details
about itrequired
- determines if the parameter is requiredvalidator
- the validator for the parameter values
SimpleParameter.DatatypeNotValidException
- if datatype
is not in the values allowed for a
SimpleParameter
public SimpleParameter(DataType datatype, String name, String comment, boolean required, ParameterValidator validator, Object defaultVal) throws ParameterException
SimpleParameter
with validator and default
value.
datatype
- the data type of the parameter valuename
- the name of the parametercomment
- a comment on the parameter that tells the user some details
about itrequired
- determines if the parameter is requiredvalidator
- the validator for the parameter valuesdefaultVal
- the default value
ParameterException
- if either the default value is not a valid value with respect
to datatype
or datatype
is not in
the values allowed for a SimpleParameter
Method Detail |
---|
public SimpleParameter clone() throws CloneNotSupportedException
clone
in class Parameter
CloneNotSupportedException
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 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 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
otherwisepublic void setRangeable(boolean rangeable)
isRangeable()
to
rangeable
.
rangeable
- the new value that determines if this SimpleParameter
is rangeablepublic Parameter 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 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 String getName()
Parameter
Parameter
.
getName
in class Parameter
Parameter
public DataType getDatatype()
Parameter
Parameter
.
getDatatype
in class Parameter
Parameter
public String getComment()
Parameter
Parameter
that tells something about
useful values, domains, usage of this parameter, etc.
getComment
in class Parameter
public boolean isRequired()
Parameter
true
if the Parameter
is required,
false
otherwise.
isRequired
in class Parameter
true
if the Parameter
is required,
false
otherwisepublic boolean checkValue(Object value)
Parameter
checkValue
in class Parameter
value
- the value to be checked
true
if the value is valid, false
otherwisepublic String getErrorMessage()
Parameter
getErrorMessage
in class Parameter
public void setDefault(Object defaultValue) throws SimpleParameter.IllegalValueException
Parameter
Parameter
to
defaultValue
.
setDefault
in class Parameter
defaultValue
- the default value
SimpleParameter.IllegalValueException
public void simplify()
Parameter
Parameter
and its contents to the relevant
information. This could be e.g. to reset the contents of those values of
a CollectionParameter
that are not selected.
simplify
in class Parameter
public void reset()
Parameter
null
if no defaults are given.
reset
in class Parameter
public void setValue(Object value2) throws SimpleParameter.IllegalValueException
Parameter
Parameter
to value
.
setValue
in class Parameter
value2
- the new value of the Parameter
SimpleParameter.IllegalValueException
- if the specified value is not valid for this
Parameter
public Object getValue()
Parameter
Parameter
.
getValue
in class Parameter
Parameter
public StringBuffer toXML()
Storable
StringBuffer
of an
instance of the implementing class.
toXML
in interface Storable
toXML
in class Parameter
protected void fromXML(StringBuffer representation) throws NonParsableException
Parameter
Parameter
from a XML representation as returned by
Parameter.toXML()
.
fromXML
in class Parameter
representation
- the XML representation as StringBuffer
NonParsableException
- if the XML code could not be parsedParameter.toXML()
public boolean equals(Object o2)
equals
in class Object
public ParameterValidator getValidator()
ParameterValidator
used in this
SimpleParameter
. This may be null
.
SimpleParameter
public void setValidator(ParameterValidator validator)
ParameterValidator
for this SimpleParameter
.
validator
- the new parameter validatorpublic String toString()
toString
in class Object
public 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 failspublic 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 |