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 MultiSelectionCollectionParameter

    java.lang.Object
      de.jstacs.parameters.Parameter
          de.jstacs.parameters.CollectionParameter
              de.jstacs.parameters.MultiSelectionCollectionParameter

All Implemented Interfaces:
  Rangeable, RangeIterator, Storable, Cloneable

Direct Known Subclasses:
  MeasureParameters

    public class MultiSelectionCollectionParameter

extends CollectionParameter
implements RangeIterator

Class for a `Parameter` that provides a collection of possible values. The user can select one or more values out of the collection as values of this `Parameter`.

Author:
  Jan Grau
See Also:
  `CollectionParameter`

Nested Class Summary

Nested classes/interfaces inherited from class de.jstacs.parameters.CollectionParameter
`CollectionParameter.InconsistentCollectionException`

Field Summary

Fields inherited from class de.jstacs.parameters.CollectionParameter
`errorMessage, parameters, userSelected`

Fields inherited from class de.jstacs.parameters.Parameter
`neededReference, neededReferenceId, parent`

Constructor Summary
`` | `MultiSelectionCollectionParameter(DataType datatype, String[] keys, Object[] values, String[] comments, String name, String comment, boolean required)` Constructor for a `MultiSelectionCollectionParameter`.
`` | `MultiSelectionCollectionParameter(DataType datatype, String[] keys, Object[] values, String name, String comment, boolean required)` Constructor for a `MultiSelectionCollectionParameter`.
`` | `MultiSelectionCollectionParameter(InstanceParameterSet[] values, String name, String comment, boolean required)` Creates a new `MultiSelectionCollectionParameter` from an array of `ParameterSet`s.
`` | `MultiSelectionCollectionParameter(ParameterSet[] values, String[] keys, String[] comments, String name, String comment, boolean required)` Creates a new `MultiSelectionCollectionParameter` from an array of `ParameterSet`s.
`protected` | `MultiSelectionCollectionParameter(ParameterSet options, boolean[] selected, boolean[] defaultSelected, boolean userSelected, String name, String comment, boolean required, DataType datatype, String errorMessage, int current, boolean makeRanged)` Creates a new `MultiSelectionCollectionParameter` from the necessary field.
`` | `MultiSelectionCollectionParameter(StringBuffer representation)` The standard constructor for the interface `Storable`.

Method Summary
`boolean` | `checkValue(Object value)` Returns `true` if the key specified by `value` is in the set of keys of this `CollectionParameter`.
`MultiSelectionCollectionParameter` | `clone()`
`protected void` | `fromXML(StringBuffer representation)` Parses a `Parameter` from a XML representation as returned by `Parameter.toXML()`.
`int` | `getNumberOfNexts(int afterIdx)` Returns the number of calls of `next()` that can be called before `false` is returned.
`int` | `getNumberOfValues()` Returns the number of values in the collection.
`int` | `getSelected()` Returns the index of the selected value.
`Object` | `getValue()` Returns the current value of this `Parameter`.
`Object` | `getValueFor(int idx)` Returns the value of the option with no.
`Object` | `getValueFor(String key)` Returns the value for the option with key `key`.
`Object[]` | `getValues()` Returns the values of all selected options as an array.
`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` | `isRanged()` Returns `true` if this `RangeIterator` is ranging over a set of values.
`boolean` | `isSelected(int idx)` Returns `true` if the option at position `idx` is selected.
`boolean` | `isSelected(String key)` Returns the selection value of the option with key `key`.
`boolean` | `isSet()` Returns `true` if the parameter was set by the user, `false` otherwise.
`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 no 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`.
`boolean` | `setSelected(int idx, boolean selected)` Sets the selection of option with no.
`boolean` | `setSelected(String key, boolean selected)` Sets the selection of the option with key `key` to the value of `selected`.
`void` | `setValue(Object value)` Sets the selected value to the one that is specified by the key `value`.
`void` | `simplify()` Simplifies the `Parameter` and its contents to the relevant information.
`StringBuffer` | `toXML()` This method returns an XML representation as `StringBuffer` 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.CollectionParameter
`appendCollection, createParameterSet, equals, extractCollection, getComment, getDatatype, getDefault, getErrorMessage, getName, getParametersInCollection, getRangedInstance, hasDefault, isRangeable, isRequired, isUserSelected, setRangeable`

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, toString, wait, wait, wait`

Constructor Detail

### MultiSelectionCollectionParameter

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

  Constructor for a `MultiSelectionCollectionParameter`. The first option in the selection is selected by default.

  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 the parameter is required, `false` otherwise
  Throws:
    `InconsistentCollectionException` - if the lengths of `keys` and `values` are 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
    `CollectionParameter.InconsistentCollectionException`

### MultiSelectionCollectionParameter

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

  Constructor for a `MultiSelectionCollectionParameter`. The first option in the selection is selected by default.

  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 values in the collection
    `name` - the name of the parameter
    `comment` - a comment on the parameter
    `required` - `true` if the parameter is required, `false` otherwise
  Throws:
    `InconsistentCollectionException` - if the lengths of `keys` and `values` are 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
    `CollectionParameter.InconsistentCollectionException`

### MultiSelectionCollectionParameter

    public MultiSelectionCollectionParameter(ParameterSet[] values,
                                             String[] keys,
                                             String[] comments,
                                             String name,
                                             String comment,
                                             boolean required)

  Creates a new `MultiSelectionCollectionParameter` from an array of `ParameterSet`s. The first option in the selection is selected by default.

  Parameters:
    `values` - the options/values 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
    `comments` - the comments on the possible values
    `name` - the name of this `MultiSelectionCollectionParameter`
    `comment` - the comment on this `MultiSelectionCollectionParameter`
    `required` - `true` if this `MultiSelectionCollectionParameter` is required, `false` otherwise

### MultiSelectionCollectionParameter

    public MultiSelectionCollectionParameter(InstanceParameterSet[] values,
                                             String name,
                                             String comment,
                                             boolean required)

  Creates a new `MultiSelectionCollectionParameter` from an array of `ParameterSet`s. The first option in the selection is selected by default.

  Parameters:
    `values` - the options/values in the collection
    `name` - the name of this `MultiSelectionCollectionParameter`
    `comment` - the comment on this `MultiSelectionCollectionParameter`
    `required` - `true` if this `MultiSelectionCollectionParameter` is required, `false` otherwise

### MultiSelectionCollectionParameter

    public MultiSelectionCollectionParameter(StringBuffer representation)
                                      throws NonParsableException

  The standard constructor for the interface `Storable`. Creates a new `MultiSelectionCollectionParameter` from its XML representation

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

### MultiSelectionCollectionParameter

    protected MultiSelectionCollectionParameter(ParameterSet options,
                                                boolean[] selected,
                                                boolean[] defaultSelected,
                                                boolean userSelected,
                                                String name,
                                                String comment,
                                                boolean required,
                                                DataType datatype,
                                                String errorMessage,
                                                int current,
                                                boolean makeRanged)
                                         throws Exception

  Creates a new `MultiSelectionCollectionParameter` from the necessary field. This constructor should be used to clone a current instance.

  Parameters:
    `options` - the options of the `CollectionParameter`
    `selected` - the currently selected values
    `defaultSelected` - the values selected by default
    `userSelected` - `true` if the current value was selected by the user, `false`
    `name` - the name of the parameter
    `comment` - a comment on the parameter
    `required` - `true` if this `CollectionParameter` is required, `false` otherwise
    `datatype` - the data type of this `CollectionParameter`
    `errorMessage` - the error message of the last error or `null`
    `current` - the currently used value in the set of selected values
    `makeRanged` - replace the `Parameter` in `options` with their ranged equivalent (if allowed)
  Throws:
    `Exception` - if something went wrong

Method Detail

### clone

    public MultiSelectionCollectionParameter clone()
                                            throws CloneNotSupportedException

  Overrides:
    `clone` in class `CollectionParameter`
  Throws:
    `CloneNotSupportedException`

### setSelected

    public boolean setSelected(String key,
                               boolean selected)

  Sets the selection of the option with key `key` to the value of `selected`.

  Parameters:
    `key` - the key of the option
    `selected` - the selection value
  Returns:
    `true` if the key could be found and set, `false` otherwise

### isSelected

    public boolean isSelected(String key)

  Returns the selection value of the option with key `key`.

  Parameters:
    `key` - the key of the option
  Returns:
    the selection value or `false` if no such option exists

### getValueFor

    public Object getValueFor(String key)

  Returns the value for the option with key `key`.

  Parameters:
    `key` - the key of the option
  Returns:
    the value or `null` if the corresponding option either does not exist or is not selected

### checkValue

    public boolean checkValue(Object value)

  Description copied from class: `CollectionParameter`
  Returns `true` if the key specified by `value` is in the set of keys of this `CollectionParameter`.

  Overrides:
    `checkValue` in class `CollectionParameter`
  Parameters:
    `value` - the value to be checked
  Returns:
    `true` if the key specified by `value` is in the set of keys of this `CollectionParameter`, `false` otherwise

### setValue

    public void setValue(Object value)
                  throws SimpleParameter.IllegalValueException

  Description copied from class: `CollectionParameter`
  Sets the selected value to the one that is specified by the key `value`.

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

### getSelected

    public int getSelected()

  Description copied from class: `CollectionParameter`
  Returns the index of the selected value.

  Overrides:
    `getSelected` in class `CollectionParameter`
  Returns:
    the index of the selected value

### setSelected

    public boolean setSelected(int idx,
                               boolean selected)

  Sets the selection of option with no. `idx` to `selected`.

  Parameters:
    `idx` - the index of the option
    `selected` - the selection value
  Returns:
    `true` if the option exists and could be set, `false` otherwise

### isSelected

    public boolean isSelected(int idx)

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

  Parameters:
    `idx` - the position
  Returns:
    `true` if the option at position `idx` is selected, `false` otherwise

### getValueFor

    public Object getValueFor(int idx)

  Returns the value of the option with no. `idx`.

  Parameters:
    `idx` - the index of the option
  Returns:
    the value or `null` if the corresponding option either does not exists or is not selected

### getValues

    public Object[] getValues()

  Returns the values of all selected options as an array.

  Returns:
    the values of all selected options

### getValue

    public Object getValue()

  Description copied from class: `Parameter`
  Returns the current value of this `Parameter`.

  Overrides:
    `getValue` in class `CollectionParameter`
  Returns:
    the current value of the `Parameter`

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

  Overrides:
    `hasDefaultOrIsSet` in class `CollectionParameter`
  Returns:
    `true` if value has a default value or was set, `false` otherwise

### isSet

    public boolean isSet()

  Description copied from class: `Parameter`
  Returns `true` if the parameter was set by the user, `false` otherwise.

  Overrides:
    `isSet` in class `CollectionParameter`
  Returns:
    `true` if the parameter was set, `false` otherwise

### isAtomic

    public boolean isAtomic()

  Description copied from class: `Parameter`
  Returns `true` if the parameter is of an atomic data type, `false` otherwise.

  Overrides:
    `isAtomic` in class `CollectionParameter`
  Returns:
    `true` if the parameter is atomic, `false` otherwise

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

  Overrides:
    `simplify` in class `CollectionParameter`

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

  Overrides:
    `reset` in class `CollectionParameter`

### setDefault

    public void setDefault(Object defaultValue)
                    throws SimpleParameter.IllegalValueException

  Description copied from class: `Parameter`
  Sets the default value of the `Parameter` to `defaultValue`.

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

### toXML

    public StringBuffer toXML()

  Description copied from interface: `Storable`
  This method returns an XML representation as `StringBuffer` of an instance of the implementing class.

  Specified by:
    `toXML` in interface `Storable`
  Overrides:
    `toXML` in class `CollectionParameter`
  Returns:
    the XML representation

### fromXML

    protected void fromXML(StringBuffer representation)
                    throws NonParsableException

  Description copied from class: `Parameter`
  Parses a `Parameter` from a XML representation as returned by `Parameter.toXML()`.

  Overrides:
    `fromXML` in class `CollectionParameter`
  Parameters:
    `representation` - the XML representation as `StringBuffer`
  Throws:
    `NonParsableException` - if the XML code could not be parsed
  See Also:
    `Parameter.toXML()`

### 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:
    `true` if the next element exists, `false` otherwise
  Throws:
    `ParameterException` - if the next value could not be fetched

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

### 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

### getNumberOfNexts

    public int getNumberOfNexts(int afterIdx)

  Returns the number of calls of `next()` that can be called before `false` is returned.

  Parameters:
    `afterIdx` - the index after which shall be counted
  Returns:
    the number of calls of `next()`

### 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 `String` representation

### isRanged

    public boolean isRanged()

  Description copied from interface: `RangeIterator`
  Returns `true` if this `RangeIterator` is ranging over a set of values.

  Specified by:
    `isRanged` in interface `RangeIterator`
  Returns:
    `true` if this `RangeIterator` is ranging over a set of values, `false` otherwise

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