de.jstacs.parameters
Class ParameterSetContainer

java.lang.Object
  extended by de.jstacs.parameters.Parameter
      extended by de.jstacs.parameters.ParameterSetContainer
All Implemented Interfaces:
Rangeable, RangeIterator, Storable, Cloneable

public class ParameterSetContainer
extends Parameter
implements Rangeable, RangeIterator

Class for a Parameter that contains a ParameterSet as value. This ParameterSet can be set either using the constructor or using the setValue()-method and can be obtained by the getValue()-method. ParameterSetContainers can be used to build tree-structures of Parameter.

Author:
Jan Grau, Jens Keilwagen

Field Summary
protected  String errorMessage
          The message of the last error or null if no error occurred
 
Fields inherited from class de.jstacs.parameters.Parameter
neededReference, neededReferenceId, parent
 
Constructor Summary
ParameterSetContainer(StringBuffer representation)
          Creates a new ParameterSetContainer from its XML-representation.
ParameterSetContainer(String name, String comment, ParameterSet content)
          Creates an new ParameterSetContainer out of a ParameterSet.
 
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
 ParameterSetContainer clone()
           
protected  void fromXML(StringBuffer representation)
          Parses a Parameter from an 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
 int getNumberOfValues()
          Returns the number of values in the collection.
 Parameter getRangedInstance()
          Returns an instance of RangeIterator that has the same properties as the current instance, but accepts a range or list of values.
 ParameterSet 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 isRangeable()
          Returns true if the parameters can be varied over a range of values.
 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()
          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 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 setValue(Object value)
          Sets the value of this parameter to value.
 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, getNeededReference, getNeededReferenceId, getParent, setNeededReference, setParent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errorMessage

protected String errorMessage
The message of the last error or null if no error occurred

Constructor Detail

ParameterSetContainer

public ParameterSetContainer(String name,
                             String comment,
                             ParameterSet content)
Creates an new ParameterSetContainer out of a ParameterSet.

Parameters:
name - the name of the ParameterSetContainer
comment - the comment of the ParameterSetContainer
content - the ParameterSet

ParameterSetContainer

public ParameterSetContainer(StringBuffer representation)
                      throws NonParsableException
Creates a new ParameterSetContainer from its XML-representation.

Parameters:
representation - the XML-representation
Throws:
NonParsableException - is thrown if representation could not be parsed
Method Detail

clone

public ParameterSetContainer clone()
                            throws CloneNotSupportedException
Overrides:
clone in class Parameter
Throws:
CloneNotSupportedException

getName

public String getName()
Description copied from class: Parameter
Returns the name of the parameter

Specified by:
getName in class Parameter
Returns:
the name

getDatatype

public DataType getDatatype()
Description copied from class: Parameter
Returns the data type of the parameter

Specified by:
getDatatype in class Parameter
Returns:
the data type

getComment

public String getComment()
Description copied from class: Parameter
Returns a comment on this parameter that tells something about useful values, domains, usage of this parameter, etc.

Specified by:
getComment in class Parameter
Returns:
the comment

isRequired

public boolean isRequired()
Description copied from class: Parameter
Returns true if the parameter is required, false otherwise

Specified by:
isRequired in class Parameter
Returns:
if the parameter is required

checkValue

public boolean checkValue(Object value)
Description copied from class: Parameter
Checks the value for correctness, e.g. for numerical parameters this might be checking if the value is within specified bounds

Specified by:
checkValue in class Parameter
Parameters:
value - the value to be checked
Returns:
if the value is valid

setValue

public void setValue(Object value)
              throws SimpleParameter.IllegalValueException
Description copied from class: Parameter
Sets the value of this parameter to value.

Specified by:
setValue in class Parameter
Parameters:
value - the new value
Throws:
SimpleParameter.IllegalValueException - if the specified value is not valid for this Parameter an IllegalValueException is thrown

getValue

public ParameterSet getValue()
Description copied from class: Parameter
Returns the current value of this Parameter

Specified by:
getValue in class Parameter
Returns:
the current value

hasDefaultOrIsSet

public boolean hasDefaultOrIsSet()
Description copied from class: Parameter
Returns true if the parameter either has a default value or the value was set by the user.

Specified by:
hasDefaultOrIsSet in class Parameter
Returns:
if value has default or is set

isSet

public boolean isSet()
Description copied from class: Parameter
Returns true if the parameter was set by the user.

Specified by:
isSet in class Parameter
Returns:
if the parameter was set

isAtomic

public boolean isAtomic()
Description copied from class: Parameter
Returns true if the parameter is of an atomic data type

Specified by:
isAtomic in class Parameter
Returns:
if the parameter is atomic

getErrorMessage

public String getErrorMessage()
Description copied from class: Parameter
If a value could not be set successfully this method returns the corresponding error message.

Specified by:
getErrorMessage in class Parameter
Returns:
the error message

simplify

public void simplify()
Description copied from class: Parameter
Simplifies the 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.

Specified by:
simplify in class Parameter

reset

public void reset()
Description copied from class: Parameter
Resets the parameter and its contents to the default values or null if not defaults are given.

Specified by:
reset in class Parameter

setDefault

public void setDefault(Object defaultValue)
                throws Exception
Description copied from class: Parameter
Sets the default value of the parameter to defaultValue

Specified by:
setDefault in class Parameter
Parameters:
defaultValue - the default value
Throws:
Exception - throws an Exceptio if the default value is not an appropriate value for this parameter.

toXML

public StringBuffer toXML()
Description copied from interface: Storable
This method returns an XML-representation of an instance of the implementing class.

Specified by:
toXML in interface Storable
Overrides:
toXML in class Parameter
Returns:
the XML-representation

fromXML

protected void fromXML(StringBuffer representation)
                throws NonParsableException
Description copied from class: Parameter
Parses a Parameter from an XML-representation as returned by Parameter.toXML().

Overrides:
fromXML in class Parameter
Parameters:
representation - the XML-representation
Throws:
NonParsableException - is thrown if the XML-code could not be parsed

isRangeable

public boolean isRangeable()
Description copied from interface: Rangeable
Returns true if the parameters can be varied over a range of values.

Specified by:
isRangeable in interface Rangeable
Returns:
if the parameter can be varied

getRangedInstance

public Parameter getRangedInstance()
                            throws Exception
Description copied from interface: Rangeable
Returns an instance of 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.

Specified by:
getRangedInstance in interface Rangeable
Returns:
the instance
Throws:
Exception - is thrown if isRangeable() returns false or the ranged instance could not be created for some other reason

next

public boolean next()
             throws ParameterException
Description copied from interface: RangeIterator
Switches to the next value in the collection of values in the specified range.

Specified by:
next in interface RangeIterator
Returns:
if the next element exists
Throws:
ParameterException - if the next value could not be set

resetToFirst

public void resetToFirst()
Description copied from interface: RangeIterator
Resets the current value in the collection to the first value.

Specified by:
resetToFirst in interface RangeIterator

isRanged

public boolean isRanged()
Description copied from interface: RangeIterator
Returns true if this range iterator is ranging over a set of values.

Specified by:
isRanged in interface RangeIterator
Returns:
if ranging

getNumberOfValues

public int getNumberOfValues()
Description copied from interface: RangeIterator
Returns the number of values in the collection.

Specified by:
getNumberOfValues in interface RangeIterator
Returns:
the number of values

valuesToString

public String valuesToString()
Description copied from interface: RangeIterator
Returns a String-representation of the set of values.

Specified by:
valuesToString in interface RangeIterator
Returns:
the representation