de.jstacs.parameters
Class EnumParameter

java.lang.Object
  extended by de.jstacs.AnnotatedEntity
      extended by de.jstacs.parameters.Parameter
          extended by de.jstacs.parameters.AbstractSelectionParameter
              extended by de.jstacs.parameters.SelectionParameter
                  extended by de.jstacs.parameters.EnumParameter
All Implemented Interfaces:
GalaxyConvertible, Rangeable, Storable, Cloneable

public class EnumParameter
extends SelectionParameter

This class implements a SelectionParameter based on an Enum. Internally it is based on Strings, i.e. the names of the Enum constants. The methods setDefault(Object) and setValue(Object) can be used with Strings or with the Enum constants.

Author:
Jens Keilwagen

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
EnumParameter(Class<? extends Enum> enumInstance, String comment, boolean required)
          The main constructor.
EnumParameter(Class<? extends Enum> enumInstance, String comment, boolean required, String defaultValue)
          This constructor creates an instance and set the default value.
EnumParameter(StringBuffer representation)
          The standard constructor for the interface Storable.
 
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 buf)
          This method can be used in the constructor with parameter StringBuffer to extract the further information.
 Enum getValue()
          Returns the value of the AnnotatedEntity.
 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.
 
Methods inherited from class de.jstacs.parameters.SelectionParameter
fromGalaxy, getDefault, getErrorMessage, getSelected, getXMLTag, hasDefault, hasDefaultOrIsSet, isSelected, reset, 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

EnumParameter

public EnumParameter(Class<? extends Enum> enumInstance,
                     String comment,
                     boolean required)
              throws ParameterException
The main constructor.

Parameters:
enumInstance - the Enum class, e.g. DataSet.PartitionMethod.class
comment - a comment on this parameter
required - true if this EnumParameter is required, false otherwise
Throws:
ParameterException - is never thrown but exists due to the class hierarchy

EnumParameter

public EnumParameter(Class<? extends Enum> enumInstance,
                     String comment,
                     boolean required,
                     String defaultValue)
              throws ParameterException
This constructor creates an instance and set the default value.

Parameters:
enumInstance - the Enum class, e.g. DataSet.PartitionMethod.class
comment - a comment on this parameter
required - true if this EnumParameter is required, false otherwise
defaultValue - the default value of this parameter
Throws:
ParameterException - is never thrown but exists due to the class hierarchy
See Also:
EnumParameter(Class, String, boolean), setDefault(Object)

EnumParameter

public EnumParameter(StringBuffer representation)
              throws NonParsableException
The standard constructor for the interface Storable. Restores an instance of EnumParameter from a XML representation.

Parameters:
representation - the XML representation as StringBuffer
Throws:
NonParsableException - if the StringBuffer representation could not be parsed
Method Detail

appendFurtherInfos

protected void appendFurtherInfos(StringBuffer buf)
Description copied from class: AnnotatedEntity
This method can be used in the method Storable.toXML() to extract further information (name, comment, datatype).

Overrides:
appendFurtherInfos in class SelectionParameter
Parameters:
buf - a XML representation of the main information as StringBuffer
See Also:
Storable.toXML()

extractFurtherInfos

protected void extractFurtherInfos(StringBuffer buf)
                            throws NonParsableException
Description copied from class: AnnotatedEntity
This method can be used in the constructor with parameter StringBuffer to extract the further information.

Overrides:
extractFurtherInfos in class SelectionParameter
Parameters:
buf - a XML represenation of the main information as StringBuffer
Throws:
NonParsableException - if the XML representation is not parsable
See Also:
AnnotatedEntity.AnnotatedEntity(StringBuffer)

getValue

public Enum getValue()
Description copied from class: AnnotatedEntity
Returns the value of the AnnotatedEntity.

Overrides:
getValue in class SelectionParameter
Returns:
the value of the AnnotatedEntity

setValue

public void setValue(Object value)
              throws SimpleParameter.IllegalValueException
Description copied from class: SelectionParameter
Sets the selected value to the one that is specified by the key value.

Overrides:
setValue in class SelectionParameter
Parameters:
value - the key of the desired value
Throws:
SimpleParameter.IllegalValueException - if the specified value is not valid for this Parameter

setDefault

public void setDefault(Object defaultValue)
                throws SimpleParameter.IllegalValueException
Description copied from class: AbstractSelectionParameter
Sets the default value of this 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.

Overrides:
setDefault in class SelectionParameter
Parameters:
defaultValue - the default value
Throws:
SimpleParameter.IllegalValueException