|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.parameters.Parameter
de.jstacs.parameters.RangeParameter
public class RangeParameter
Class for a parameter wrapper that allows SimpleParameter
s to be set to a set
of values.
These values may be given either as a list of values separated by spaces, as a range between a first and
a last value with a given number of steps between these values, or a single value. In the latter case
a RangeParameter
works just like a plain SimpleParameter
.
SimpleParameter
s that are used to construct a RangeParameter
must be
rangeable, i.e. their isRangeable()
-method must return true
, or they will
be rejected.
Nested Class Summary | |
---|---|
static class |
RangeParameter.RangeType
The possible types of defining ranges for a RangeParameter |
static class |
RangeParameter.Scale
The possible scales, if RangeParameter.RangeType is RangeParameter.RangeType.RANGE . |
Field Summary |
---|
Fields inherited from class de.jstacs.parameters.Parameter |
---|
neededReference, neededReferenceId, parent |
Constructor Summary | |
---|---|
RangeParameter(SimpleParameter par)
Constructs a RangeParameter from a SimpleParameter that is rangeable. |
|
RangeParameter(StringBuffer representation)
Restores a RangeParameter from its XML-representation. |
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 |
RangeParameter |
clone()
|
protected void |
fromXML(StringBuffer representation)
Parses a Parameter from an XML-representation as returned by Parameter.toXML() . |
static CollectionParameter |
getCollectionOfScales()
Returns a CollectionsParameter that allows the user to choose between different scales. |
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 |
Object |
getEndValue()
Returns the last value of a range of parameter values or null
if no range was specified. |
String |
getErrorMessage()
If a value could not be set successfully this method returns the corresponding error message. |
String |
getList()
Returns a list of all parameter values as a String or null
if no parameter values have been set. |
String |
getName()
Returns the name of the parameter |
ParameterSet |
getNeededReference()
Returns a reference to a ParameterSet whose ParameterSet.hasDefaultOrIsSet() method depends on the value of this Parameter . |
int |
getNumberOfNexts(int afterIndex)
Returns the number of calls to next() that can be done, before
obtaining false . |
int |
getNumberOfValues()
Returns the number of values in a list or range of parameter values |
String |
getScale()
Returns a description of the the scale of a range of parameter values. |
Object |
getStartValue()
Returns the start value of a range of parameter values or null
if no range was specified. |
int |
getSteps()
Returns the number of steps of a range of parameter values or 0
if no range was specified. |
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. |
boolean |
isAtomic()
Returns true if the parameter is of an atomic data type |
boolean |
isRanged()
Returns true if this range iterator is ranging over a set 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. |
boolean |
next()
Returns true if the next element still exists and get be fetched using getValue() , false otherwise |
void |
reset()
Resets the parameter and its contents to the default values or null if not
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 the parameter to defaultValue |
void |
setNeededReference(ParameterSet reference)
Sets an internal reference to a ParameterSet whose validity depends on
the value of this Parameter . |
void |
setShallBeRanged(RangeParameter.RangeType shallBeRanged)
Sets the type of this RangeParameter to one of
LIST, RANGE , or NO . |
void |
setValue(Object value)
Sets the value of this parameter to value . |
void |
setValues(Object startValue,
int steps,
Object endValue,
RangeParameter.Scale scale)
Sets the values of this RangeParameter as a range of values, specified by a start values,
a last value, a number of steps between these values (without the last value), and a scale in that
the values between the first and the last value are chosen. |
void |
setValues(String values)
Sets a list of values from a String containing a space separated list of values. |
void |
setValuesInLogScale(boolean log,
double radix,
Object startValue,
int steps,
Object endValue)
This method enables you to set a list of values in an easy manner. |
RangeParameter.RangeType |
shallBeRanged()
Returns one of LIST, RANGE , or NO
depending on the input used to specify this RangeParameter |
void |
simplify()
Simplifies the Parameter and its contents to the relevant information. |
StringBuffer |
toXML()
This method returns an XML-representation of an instance of the implementing class. |
String |
valuesToString()
Returns a String -representation of the set of values. |
Methods inherited from class de.jstacs.parameters.Parameter |
---|
getId, getNeededReferenceId, getParent, setParent |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RangeParameter(SimpleParameter par) throws Exception
RangeParameter
from a SimpleParameter
that is rangeable.
par
- the parameter
Exception
- an Exception
is thrown if the parameter is not rangeable, i.e. its isRangeable()
-method returns false
.public RangeParameter(StringBuffer representation) throws NonParsableException
RangeParameter
from its XML-representation.
representation
- the XML-representation
NonParsableException
- a NonParsableException
is thrown if representation
could not be parsedMethod Detail |
---|
public RangeParameter clone() throws CloneNotSupportedException
clone
in class Parameter
CloneNotSupportedException
public static CollectionParameter getCollectionOfScales() throws ParameterException
CollectionsParameter
that allows the user to choose between different scales.
CollectionParameter
ParameterException
- is thrown if the CollectionParameter
could, or if one of the possible values of the CollectionParameter
was not legalpublic String getName()
Parameter
getName
in class Parameter
public String getList()
String
or null
if no parameter values have been set.
public Object getStartValue()
null
if no range was specified.
public Object getEndValue()
null
if no range was specified.
public int getSteps()
0
if no range was specified.
public String getScale()
public DataType getDatatype()
Parameter
getDatatype
in class Parameter
public String getComment()
Parameter
getComment
in class Parameter
public boolean isRequired()
Parameter
true
if the parameter is required, false
otherwise
isRequired
in class Parameter
public boolean checkValue(Object value)
Parameter
checkValue
in class Parameter
value
- the value to be checked
public void setValue(Object value) throws SimpleParameter.IllegalValueException
Parameter
value
.
setValue
in class Parameter
value
- the new value
SimpleParameter.IllegalValueException
- if the specified value is not valid for this Parameter
an IllegalValueException
is thrownpublic void setValues(String values) throws SimpleParameter.IllegalValueException
String
containing a space separated list of values.
After this method has been called, shallBeRanged()
returns LIST
.
values
- the space separated list
SimpleParameter.IllegalValueException
- an IllegalValueException
is thrown if at least one of the values
in the list is no suitable value for this RangeParameter
public void setValues(Object startValue, int steps, Object endValue, RangeParameter.Scale scale) throws SimpleParameter.IllegalValueException
RangeParameter
as a range of values, specified by a start values,
a last value, a number of steps between these values (without the last value), and a scale in that
the values between the first and the last value are chosen. This range must be one of LINSCALE,
LOGSCALE
, and EXPSCALE
startValue
- the first valuesteps
- the number of stepsendValue
- the last valuesscale
- the scale
SimpleParameter.IllegalValueException
- an IllegalValueException
is thrown if one of the values is
not suitable for this RangeParameter
, e.g. is out of a specified range of allowed valuespublic void setValuesInLogScale(boolean log, double radix, Object startValue, int steps, Object endValue) throws SimpleParameter.IllegalValueException
[startValue,endValue]
in (inverse) log scale.
log
- if true
log scale is used, otherwise inverse log scaleradix
- the radix for the scalestartValue
- the start valuesteps
- the number of stepsendValue
- the end value
SimpleParameter.IllegalValueException
- if some constraints are not fulfilledpublic Object getValue()
Parameter
Parameter
getValue
in class Parameter
public boolean next() throws SimpleParameter.IllegalValueException
getValue()
, false otherwise
next
in interface RangeIterator
SimpleParameter.IllegalValueException
public int getNumberOfValues()
getNumberOfValues
in interface RangeIterator
public int getNumberOfNexts(int afterIndex)
next()
that can be done, before
obtaining false
.
afterIndex
- the index after which next() shall be called
public RangeParameter.RangeType shallBeRanged()
LIST, RANGE
, or NO
depending on the input used to specify this RangeParameter
public void setShallBeRanged(RangeParameter.RangeType shallBeRanged) throws Exception
RangeParameter
to one of
LIST, RANGE
, or NO
.
shallBeRanged
- the type of this parameter
Exception
- an Exception
is thrown if shallBeRanged
is none of the allowed valuespublic boolean hasDefaultOrIsSet()
Parameter
hasDefaultOrIsSet
in class Parameter
public boolean isSet()
Parameter
isSet
in class Parameter
public boolean isAtomic()
Parameter
isAtomic
in class Parameter
public String getErrorMessage()
Parameter
getErrorMessage
in class Parameter
public StringBuffer toXML()
Storable
toXML
in interface Storable
toXML
in class Parameter
protected void fromXML(StringBuffer representation) throws NonParsableException
Parameter
Parameter
from an XML-representation as returned by Parameter.toXML()
.
fromXML
in class Parameter
representation
- the XML-representation
NonParsableException
- is thrown if the XML-code could not be parsedpublic void simplify()
Parameter
CollectionParameter
that are not
selected.
simplify
in class Parameter
public void reset()
Parameter
null
if not
defaults are given.
reset
in class Parameter
public void resetToFirst()
RangeIterator
resetToFirst
in interface RangeIterator
public void setDefault(Object defaultValue) throws Exception
Parameter
defaultValue
setDefault
in class Parameter
defaultValue
- the default value
Exception
- throws an Exceptio
if the default value is not an appropriate value
for this parameter.public String valuesToString()
RangeIterator
String
-representation of the set of values.
valuesToString
in interface RangeIterator
public boolean isRanged()
RangeIterator
isRanged
in interface RangeIterator
public ParameterSet getNeededReference()
Parameter
ParameterSet
whose ParameterSet.hasDefaultOrIsSet()
method depends on the value of this Parameter
.
If no such ParameterSet
exists, null
is returned.
getNeededReference
in class Parameter
public void setNeededReference(ParameterSet reference)
Parameter
ParameterSet
whose validity depends on
the value of this Parameter
.
setNeededReference
in class Parameter
reference
- the ParameterSet
depending on the value of this Parameter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |