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 ParameterSet

    java.lang.Object
      de.jstacs.parameters.ParameterSet

All Implemented Interfaces:
  RangeIterator, Storable, Cloneable

Direct Known Subclasses:
  ClassifierAssessmentAssessParameterSet, ExpandableParameterSet, InstanceParameterSet, SimpleParameterSet

    public abstract class ParameterSet

extends Object
implements Storable, Cloneable, RangeIterator

(Container) class for a set of `Parameter`s. This is the base class for other `ParameterSet`s that provide more specialized methods, e.g. for expanding the set of `Parameter`s at runtime ( `ExpandableParameterSet` ) or defining an array of `ParameterSet` s from a common template ( `ArrayParameterSet` ).

Author:
  Jan Grau

Nested Class Summary
`class` | `ParameterSet.ParameterList` Class for a `List` of `Parameter`s that basically has the same functionality as `ArrayList`, but additionally takes care of the references `Parameter.parent`.

Field Summary
`protected String` | `errorMessage` The error message of the last error or `null`
`protected ParameterSet.ParameterList` | `parameters` The set of parameters
`protected ParameterSetContainer` | `parent` If this `ParameterSet` is contained in a `ParameterSetContainer`, this variable holds a reference to that `ParameterSetContainer`.
`protected boolean` | `ranged` Indicates if the `Parameter`s of this `ParameterSet` that implement `Rangeable` and return `true` shall be replaced by their ranged instances

Constructor Summary
`` | `ParameterSet()` Constructs a new `ParameterSet` with empty parameter values.
`protected` | `ParameterSet(ArrayList<Parameter> parameters)` Constructs a `ParameterSet` out of an `ArrayList` of `Parameter`s.
`protected` | `ParameterSet(Parameter[] parameters)` Constructs a `ParameterSet` out of an array of `Parameter`s.
`` | `ParameterSet(StringBuffer representation)` The standard constructor for the interface `Storable`.

Method Summary
`ParameterSet` | `clone()` Creates a full clone (deep copy) of this `ParameterSet`.
`protected void` | `fromXML(StringBuffer representation)` Parses the instance fields of a `ParameterSet` from the XML representation as returned by `toXML()`.
`String` | `getErrorMessage()` Returns the message of the last error that occurred.
`long` | `getId()` Returns the id of this `ParameterSet`.
`int` | `getNumberOfParameters()` Returns the number of parameters in the `ParameterSet`.
`int` | `getNumberOfValues()` Returns the number of values in the collection.
`Parameter` | `getParameterAt(int i)` Returns the `Parameter` at position `i`.
`ParameterSetContainer` | `getParent()` Returns the enclosing `ParameterSetContainer` of this `ParameterSet` or `null` if none exists.
`boolean` | `hasDefaultOrIsSet()` Returns `true` if all parameters in this `ParameterSet` are either set by the user or have default values.
`protected void` | `initParameterList()` Initializes the internal set of `Parameter`s, which is a `ParameterSet.ParameterList`.
`protected void` | `initParameterList(int initCapacity)` Initializes the internal set of `Parameter`s, which is a `ParameterSet.ParameterList`, with an initial number of `Parameter`s of `initCapacity`.
`boolean` | `isAtomic()` Returns `true` if this `ParameterSet` contains only atomic parameters, i.e. the parameters do not contain `ParameterSet`s themselves.
`boolean` | `isRanged()` Returns `true` if this `RangeIterator` is ranging over a set of values.
`protected abstract void` | `loadParameters()` Loads the parameters for this `ParameterSet`.
`void` | `makeRanged()` Replaces all `Parameter`s in this `ParameterSet` by their equivalents implementing the `Rangeable` interface.
`boolean` | `next()` Switches to the next value in the collection of values in the specified range.
`boolean` | `parametersLoaded()` Returns `true` if the parameters of this `ParameterSet` have already been loaded using `loadParameters()`.
`protected void` | `propagateId()` Propagates the id of this `ParameterSet` to all `Parameter`s above and below in the hierarchy.
`protected void` | `recieveId()` Searches for all `Parameter.neededReferenceId`s in the hierarchy below this `ParameterSet` and sets the corresponding `Parameter.neededReference`s.
`protected void` | `replaceParametersWithRangedInstance()` Replaces all `Parameter`s in this `ParameterSet` by their equivalents implementing the `Rangeable` interface.
`void` | `reset()` Resets all `Parameter`s in this `ParameterSet` to their default values or `null` if not default value was provided.
`void` | `resetToFirst()` Resets the current value in the collection to the first value.
`void` | `setParent(ParameterSetContainer parent)` Sets the enclosing `ParameterSetContainer` of this `ParameterSet` to `parent`.
`void` | `simplify()` Simplifies all `Parameter`s in this `ParameterSet`.
`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 java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### parameters

    protected ParameterSet.ParameterList parameters

  The set of parameters

### errorMessage

    protected String errorMessage

  The error message of the last error or `null`

### ranged

    protected boolean ranged

  Indicates if the `Parameter`s of this `ParameterSet` that implement `Rangeable` and return `true` shall be replaced by their ranged instances

### parent

    protected ParameterSetContainer parent

  If this `ParameterSet` is contained in a `ParameterSetContainer`, this variable holds a reference to that `ParameterSetContainer`.

Constructor Detail

### ParameterSet

    public ParameterSet()
                 throws UnsupportedOperationException

  Constructs a new `ParameterSet` with empty parameter values. The set of parameters is loaded by the method `loadParameters()` as soon as one of the accession methods, e.g. `getNumberOfParameters()`, is called.

  Throws:
    `UnsupportedOperationException` - if the `ParameterSet` could not be constructed

### ParameterSet

    protected ParameterSet(Parameter[] parameters)

  Constructs a `ParameterSet` out of an array of `Parameter`s. The `Parameter`s are not cloned, but passed by reference.

  Parameters:
    `parameters` - the `Parameter`s

### ParameterSet

    protected ParameterSet(ArrayList<Parameter> parameters)

  Constructs a `ParameterSet` out of an `ArrayList` of `Parameter`s. The `Parameter`s are not cloned, but passed by reference.

  Parameters:
    `parameters` - the `Parameter`s

### ParameterSet

    public ParameterSet(StringBuffer representation)
                 throws NonParsableException

  The standard constructor for the interface `Storable`. Constructs a `ParameterSet` out of an XML representation.

  Parameters:
    `representation` - the XML representation as `StringBuffer`
  Throws:
    `NonParsableException` - if the `ParameterSet` could not be reconstructed out of the `StringBuffer` `representation`

Method Detail

### clone

    public ParameterSet clone()
                       throws CloneNotSupportedException

  Creates a full clone (deep copy) of this `ParameterSet`. As a convenience-method the user can use `fillWithStandardFieldsForClone(ParameterSet)` on a newly created instance of a subclass of `ParameterSet` to obtain a clone/copy of all standard member variables (those already defined in `ParameterSet`) in the passed `ParameterSet`. Using this method, the cloning process becomes merely three-step:
  - Create a new instance of your subclass of `ParameterSet`, most likely with an empty constructor or the one taking just the instance class.
  - Call `this.fillWithStandardFieldsForClone` on this instance.
  - Return the instance.
  This method fulfills the conventions of `Object`'s method `Object.clone()`.

  Overrides:
    `clone` in class `Object`
  Returns:
    a deep clone/copy of this `ParameterSet`
  Throws:
    `CloneNotSupportedException`

### initParameterList

    protected final void initParameterList()

  Initializes the internal set of `Parameter`s, which is a `ParameterSet.ParameterList`.

### initParameterList

    protected final void initParameterList(int initCapacity)

  Initializes the internal set of `Parameter`s, which is a `ParameterSet.ParameterList`, with an initial number of `Parameter`s of `initCapacity`.

  Parameters:
    `initCapacity` - the initial number of `Parameter`s

### loadParameters

    protected abstract void loadParameters()
                                    throws Exception

  Loads the parameters for this `ParameterSet`. This is in most cases done by calling `initParameterList()` or `initParameterList(int)` to initialize `parameters` and afterwards filling `parameters` with instances of subclasses of `Parameter`.

  Throws:
    `Exception` - if the parameters could not be loaded
  See Also:
    `Parameter`, `parameters`, `initParameterList()`, `initParameterList(int)`

### parametersLoaded

    public boolean parametersLoaded()

  Returns `true` if the parameters of this `ParameterSet` have already been loaded using `loadParameters()`.

  Returns:
    the state of the parameters (loaded or not)

### isAtomic

    public boolean isAtomic()

  Returns `true` if this `ParameterSet` contains only atomic parameters, i.e. the parameters do not contain `ParameterSet`s themselves.

  Returns:
    `true` if the `ParameterSet` contains only atomic parameters, `false` otherwise

### hasDefaultOrIsSet

    public boolean hasDefaultOrIsSet()

  Returns `true` if all parameters in this `ParameterSet` are either set by the user or have default values. If any additional constraints are required on your parameters you should either specify some `ParameterValidator` on these parameters or implement these constraints by overriding this method in your implementation of `ParameterSet`. It is recommended to specify a useful remark which constraint failed in the member-variable `errorMessage`, which will be displayed to the user. In the overriding method `super.``hasDefaultOrIsSet()` should be called prior to checking specific constraints.

  Returns:
    `true` if all parameters have some allowed value set, `false` otherwise

### getErrorMessage

    public String getErrorMessage()

  Returns the message of the last error that occurred. If no error occurred this method returns `null`.

  Returns:
    the error message of the last error or `null`

### getNumberOfParameters

    public int getNumberOfParameters()

  Returns the number of parameters in the `ParameterSet`.

  Returns:
    the number of parameters in the `ParameterSet`

### getParameterAt

    public Parameter getParameterAt(int i)

  Returns the `Parameter` at position `i`.

  Parameters:
    `i` - the position in the `ParameterSet.ParameterList`
  Returns:
    the `Parameter` at position `i`

### makeRanged

    public void makeRanged()
                    throws Exception

  Replaces all `Parameter`s in this `ParameterSet` by their equivalents implementing the `Rangeable` interface.

  Throws:
    `Exception` - if these instances could not be created
  See Also:
    `replaceParametersWithRangedInstance()`

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

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

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

### replaceParametersWithRangedInstance

    protected void replaceParametersWithRangedInstance()
                                                throws Exception

  Replaces all `Parameter`s in this `ParameterSet` by their equivalents implementing the `Rangeable` interface.

  Throws:
    `Exception` - if these instances could not be created
  See Also:
    `makeRanged()`

### 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`
  Returns:
    the XML representation

### simplify

    public void simplify()

  Simplifies all `Parameter`s in this `ParameterSet`.

  See Also:
    `Parameter.simplify()`

### reset

    public void reset()

  Resets all `Parameter`s in this `ParameterSet` to their default values or `null` if not default value was provided.

  See Also:
    `Parameter.reset()`

### fromXML

    protected void fromXML(StringBuffer representation)
                    throws NonParsableException

  Parses the instance fields of a `ParameterSet` from the XML representation as returned by `toXML()`.

  Parameters:
    `representation` - the XML representation as `StringBuffer`
  Throws:
    `NonParsableException` - if the XML code could not be parsed
  See Also:
    `toXML()`

### recieveId

    protected void recieveId()

  Searches for all `Parameter.neededReferenceId`s in the hierarchy below this `ParameterSet` and sets the corresponding `Parameter.neededReference`s.

### propagateId

    protected void propagateId()

  Propagates the id of this `ParameterSet` to all `Parameter`s above and below in the hierarchy.

### getId

    public long getId()

  Returns the id of this `ParameterSet`.

  Returns:
    the id of the `ParameterSet`

### getParent

    public ParameterSetContainer getParent()

  Returns the enclosing `ParameterSetContainer` of this `ParameterSet` or `null` if none exists.

  Returns:
    the enclosing `ParameterSetContainer` (`parent`)

### setParent

    public void setParent(ParameterSetContainer parent)

  Sets the enclosing `ParameterSetContainer` of this `ParameterSet` to `parent`.

  Parameters:
    `parent` - the new parent

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