Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.jstacs.parameters
Class SelectionParameter

    java.lang.Object
      de.jstacs.AnnotatedEntity
          de.jstacs.parameters.Parameter
              de.jstacs.parameters.AbstractSelectionParameter
                  de.jstacs.parameters.SelectionParameter

All Implemented Interfaces:
  GalaxyConvertible, Rangeable, Storable, Cloneable

Direct Known Subclasses:
  EnumParameter

    public class SelectionParameter

extends AbstractSelectionParameter
implements Rangeable, GalaxyConvertible

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`.

Author:
  Jan Grau
See Also:
  `ParameterSet`

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
`SelectionParameter(DataType datatype, String[] keys, Object[] values, String[] comments, String name, String comment, boolean required)` Constructor for a `SelectionParameter`.
`SelectionParameter(DataType datatype, String[] keys, Object[] values, String name, String comment, boolean required)` Constructor for a `SelectionParameter`.
`SelectionParameter(StringBuffer representation)` The standard constructor for the interface `Storable`.
`SelectionParameter(String name, String comment, boolean required, Class<? extends ParameterSet>... values)` Constructor for a `SelectionParameter` from an array of `Class`es of `ParameterSet`s.
`SelectionParameter(String name, String comment, boolean required, ParameterSet... values)` Constructor for a `SelectionParameter` 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 void` | `extractFurtherInfos(StringBuffer representation)` This method can be used in the constructor with parameter `StringBuffer` to extract the further information.
`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 int` | `getDefault()` Returns the index of the default selected value.
`String` | `getErrorMessage()` If a value could not be set successfully this method returns the corresponding error message.
`int` | `getSelected()` Returns the index of the selected value.
`Object` | `getValue()` Returns the value of the `AnnotatedEntity`.
`String` | `getXMLTag()` This method returns a tag used as outer tag of the XML description.
`boolean` | `hasDefault()` Returns `true`, if this `SelectionParameter` has a default value.
`boolean` | `hasDefaultOrIsSet()` Returns `true` if the parameter either has a default value or the value was set by the user, `false` otherwise.
`boolean` | `isSelected(int idx)` Returns `true` if the option at position `idx` is selected.
`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 this `AbstractSelectionParameter` to `defaultValue`.
`void` | `setValue(Object value)` Sets the selected value to the one that is specified by the key `value`.
`String` | `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

### SelectionParameter

    public SelectionParameter(DataType datatype,
                              String[] keys,
                              Object[] values,
                              String name,
                              String comment,
                              boolean required)
                       throws AbstractSelectionParameter.InconsistentCollectionException,
                              SimpleParameter.IllegalValueException,
                              SimpleParameter.DatatypeNotValidException

  Constructor for a `SelectionParameter`.

  Parameters:
    `datatype` - the data type of the parameters in the collection
    `keys` - the keys/names of the values in the collection, this is the name the user will see in the user interface
    `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 array
    `name` - the name of the parameter
    `comment` - a comment on the parameter
    `required` - `true` if this `SelectionParameter` is required, `false` otherwise
  Throws:
    `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 values
    `AbstractSelectionParameter.InconsistentCollectionException`
  See Also:
    `AbstractSelectionParameter.AbstractSelectionParameter(DataType, String[], Object[], String[], String, String, boolean)`

### SelectionParameter

    public SelectionParameter(DataType datatype,
                              String[] keys,
                              Object[] values,
                              String[] comments,
                              String name,
                              String comment,
                              boolean required)
                       throws AbstractSelectionParameter.InconsistentCollectionException,
                              SimpleParameter.IllegalValueException,
                              SimpleParameter.DatatypeNotValidException

  Constructor for a `SelectionParameter`.

  Parameters:
    `datatype` - the data type of the parameters in the collection
    `keys` - the keys/names of the values in the collection, this is the name the user will see in the user interface
    `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 array
    `comments` - the comments on the possible values
    `name` - the name of the parameter
    `comment` - a comment on the parameter
    `required` - `true` if the `SelectionParameter` is required, `false` otherwise
  Throws:
    `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 values
    `AbstractSelectionParameter.InconsistentCollectionException`
  See Also:
    `AbstractSelectionParameter.createParameterSet(Object[], String[], String[])`

### SelectionParameter

    public SelectionParameter(String name,
                              String comment,
                              boolean required,
                              ParameterSet... values)

  Constructor for a `SelectionParameter` from an array of `ParameterSet`s. This constructor can be used to easily construct a `SelectionParameter` that lets the user select from a list of possible options that all require an own set of `Parameter`s to be instantiated.

  Parameters:
    `values` - the array of `ParameterSet`s
    `name` - the name of the parameter
    `comment` - a comment on the parameter
    `required` - `true` if the parameter is required, `false` otherwise
  See Also:
    `AbstractSelectionParameter.createParameterSet(Object[], String[], String[])`

### SelectionParameter

    public SelectionParameter(String name,
                              String comment,
                              boolean required,
                              Class<? extends ParameterSet>... values)

  Constructor for a `SelectionParameter` from an array of `Class`es of `ParameterSet`s. This constructor can be used to easily construct a `SelectionParameter` 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 `SelectionParameter(String, String, boolean, ParameterSet...)`, i.e., the `ParameterSet`s are only created if necessary.

  Parameters:
    `values` - the array of `Class`es of `ParameterSet`s
    `name` - the name of the parameter
    `comment` - a comment on the parameter
    `required` - `true` if the parameter is required, `false` otherwise
  See Also:
    `AbstractSelectionParameter.createParameterSet(Object[], String[], String[])`

### SelectionParameter

    public SelectionParameter(StringBuffer representation)
                       throws NonParsableException

  The standard constructor for the interface `Storable`. Restores an instance of `SelectionParameter` from a XML representation.

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

Method Detail

### hasDefault

    public boolean hasDefault()

  Returns `true`, if this `SelectionParameter` has a default value.

  Specified by:
    `hasDefault` in class `AbstractSelectionParameter`
  Returns:
    if this `SelectionParameter` has a default value
  See Also:
    `AbstractSelectionParameter.setDefault(Object)`

### 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, `false` otherwise.

  Specified by:
    `hasDefaultOrIsSet` in class `Parameter`
  Returns:
    `true` if value has a default value or was set, `false` otherwise

### getErrorMessage

    public String getErrorMessage()

  Description copied from class: `Parameter`
  If a value could not be set successfully this method returns the corresponding error message.

  Overrides:
    `getErrorMessage` in class `AbstractSelectionParameter`
  Returns:
    an error message if a value could not be set successfully

### getXMLTag

    public String getXMLTag()

  Description copied from class: `AnnotatedEntity`
  This method returns a tag used as outer tag of the XML description.

  Specified by:
    `getXMLTag` in class `AnnotatedEntity`
  Returns:
    a tag used as outer tag of the XML description

### 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 `AbstractSelectionParameter`
  Parameters:
    `buf` - a XML representation of the main information as `StringBuffer`
  See Also:
    `Storable.toXML()`

### extractFurtherInfos

    protected void extractFurtherInfos(StringBuffer representation)
                                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 `AbstractSelectionParameter`
  Parameters:
    `representation` - a XML represenation of the main information as `StringBuffer`
  Throws:
    `NonParsableException` - if the XML representation is not parsable
  See Also:
    `AnnotatedEntity.AnnotatedEntity(StringBuffer)`

### isSelected

    public boolean isSelected(int idx)

  Returns `true` if the option at position `idx` is selected.

  Specified by:
    `isSelected` in class `AbstractSelectionParameter`
  Parameters:
    `idx` - the position
  Returns:
    `true` if the option at position `idx` is selected, `false` otherwise

### getSelected

    public int getSelected()

  Returns the index of the selected value.

  Returns:
    the index of the selected value

### getDefault

    protected int getDefault()

  Returns the index of the default selected value.

  Returns:
    the index of the default selected value

### setValue

    public void setValue(Object value)
                  throws SimpleParameter.IllegalValueException

  Sets the selected value to the one that is specified by the key `value`.

  Specified by:
    `setValue` in class `Parameter`
  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`.

  Specified by:
    `setDefault` in class `AbstractSelectionParameter`
  Parameters:
    `defaultValue` - the default value
  Throws:
    `SimpleParameter.IllegalValueException`

### reset

    public void reset()

  Description copied from class: `Parameter`
  Resets the parameter and its contents to the default values or `null` if no defaults are given.

  Specified by:
    `reset` in class `Parameter`

### getValue

    public Object getValue()

  Description copied from class: `AnnotatedEntity`
  Returns the value of the `AnnotatedEntity`.

  Specified by:
    `getValue` in class `AnnotatedEntity`
  Returns:
    the value of the `AnnotatedEntity`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### fromGalaxy

    public void fromGalaxy(String namePrefix,
                           StringBuffer command)
                    throws Exception

  Description copied from interface: `GalaxyConvertible`
  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.

  Specified by:
    `fromGalaxy` in interface `GalaxyConvertible`
  Parameters:
    `namePrefix` - the prefix of the variable name
    `command` - the command string
  Throws:
    `Exception` - if the command string could not be parsed

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD