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 ExpandableParameterSet

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

All Implemented Interfaces:
  GalaxyConvertible, RangeIterator, Storable, Cloneable

Direct Known Subclasses:
  AlphabetContainerParameterSet.SectionDefinedAlphabetParameterSet, ArrayParameterSet

    public class ExpandableParameterSet

extends ParameterSet

A class for a `ParameterSet` that can be expanded by additional `Parameter`s at runtime. The `Parameter`s are all of type `ParameterSetContainer`. The contents of these `Parameter`s are provided by a `ParameterSet`-template, which is cloned each time `addParameterToSet()` is called and set as value of a `ParameterSetContainer` that is added to the `Parameter`s of the `ExpandableParameterSet`. Already added `Parameter`s can also be removed from the set using `removeParameterFromSet()`.

Author:
  Jan Grau

Nested Class Summary

Nested classes/interfaces inherited from class de.jstacs.parameters.ParameterSet
`ParameterSet.ParameterList`

Field Summary
`protected String` | `commentTemplate` A template for the comment of the enclosing `ParameterSetContainer`
`protected String` | `nameTemplate` A template for the name of the enclosing `ParameterSetContainer`
`protected ParameterSet` | `template` The template for each `ParameterSet`

Fields inherited from class de.jstacs.parameters.ParameterSet
`errorMessage, parameters, parent, ranged`

Constructor Summary
`ExpandableParameterSet(ParameterSet[] templateAndContent, String nameTemplate, String commentTemplate)` Creates a new `ExpandableParameterSet` from a `ParameterSet` -array.
`ExpandableParameterSet(ParameterSet template, String nameTemplate, String commentTemplate)` Creates a new `ExpandableParameterSet` from a `Class` that can be instantiated using this `ExpandableParameterSet` and templates for the `ParameterSet` in each element of the array, the name and the comment that are displayed for the `ParameterSetContainer`s enclosing the `ParameterSet`s.
`ExpandableParameterSet(ParameterSet template, String nameTemplate, String commentTemplate, int initCount)` Creates a new `ExpandableParameterSet` from a `Class` that can be instantiated using this `ExpandableParameterSet` and templates for the `ParameterSet` in each element of the array, the name and the comment that are displayed for the `ParameterSetContainer`s enclosing the `ParameterSet`s.
`ExpandableParameterSet(StringBuffer representation)` The standard constructor for the interface `Storable`.

Method Summary
`void` | `addParameterToSet()` Adds a new `ParameterSetContainer` containing a clone of the `ParameterSet`-template to the set of `Parameter`s.
`ExpandableParameterSet` | `clone()` Creates a full clone (deep copy) of this `ParameterSet`.
`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 void` | `fromXML(StringBuffer representation)` Parses the instance fields of a `ParameterSet` from the XML representation as returned by `ParameterSet.toXML()`.
`protected void` | `loadParameters()` Loads the parameters for this `ParameterSet`.
`boolean` | `parameterRemovable()` Returns `true` if there is still a `Parameter` that can be removed from the set.
`void` | `removeParameterFromSet()` Removes the last `Parameter` from set.
`boolean` | `replaceContentWith(ParameterSet[] paramSetArray)` First removes all previous added `ParameterSetContainer`s and afterwards adds all given `ParameterSet`s (in the given order) enclosed in new `ParameterSetContainer`s.
`protected void` | `replaceParametersWithRangedInstance()` Replaces all `Parameter`s in this `ParameterSet` by their equivalents implementing the `Rangeable` interface.
`void` | `toGalaxy(String namePrefix, String configPrefix, int depth, StringBuffer descBuffer, StringBuffer configBuffer)` Creates an Galaxy XML-representation of the parameters and appends it to `descBuffer` and variable configuration and appends it to `configBuffer`.
`StringBuffer` | `toXML()` This method returns an XML representation as `StringBuffer` of an instance of the implementing class.

Methods inherited from class de.jstacs.parameters.ParameterSet
`getErrorMessage, getId, getIndex, getNumberOfParameters, getNumberOfValues, getParameterAt, getParent, hasDefaultOrIsSet, initParameterList, initParameterList, isAtomic, isRanged, makeRanged, next, parametersLoaded, propagateId, recieveId, reset, resetToFirst, setParent, simplify, valuesToString`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### template

    protected ParameterSet template

  The template for each `ParameterSet`

### nameTemplate

    protected String nameTemplate

  A template for the name of the enclosing `ParameterSetContainer`

### commentTemplate

    protected String commentTemplate

  A template for the comment of the enclosing `ParameterSetContainer`

Constructor Detail

### ExpandableParameterSet

    public ExpandableParameterSet(ParameterSet template,
                                  String nameTemplate,
                                  String commentTemplate)

  Creates a new `ExpandableParameterSet` from a `Class` that can be instantiated using this `ExpandableParameterSet` and templates for the `ParameterSet` in each element of the array, the name and the comment that are displayed for the `ParameterSetContainer`s enclosing the `ParameterSet`s. Initially, the method `loadParameters()` creates one copy of the template.

  Parameters:
    `template` - the template of the `ParameterSet`
    `nameTemplate` - the name-template
    `commentTemplate` - the comment-template

### ExpandableParameterSet

    public ExpandableParameterSet(ParameterSet template,
                                  String nameTemplate,
                                  String commentTemplate,
                                  int initCount)

  Creates a new `ExpandableParameterSet` from a `Class` that can be instantiated using this `ExpandableParameterSet` and templates for the `ParameterSet` in each element of the array, the name and the comment that are displayed for the `ParameterSetContainer`s enclosing the `ParameterSet`s. Using this constructor, the method `loadParameters()` initially creates `initCount` copies of the template.

  Parameters:
    `template` - the template of the `ParameterSet`
    `nameTemplate` - the name-template
    `commentTemplate` - the comment-template
    `initCount` - the number of initial copies of the template

### ExpandableParameterSet

    public ExpandableParameterSet(StringBuffer representation)
                           throws NonParsableException

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

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

### ExpandableParameterSet

    public ExpandableParameterSet(ParameterSet[] templateAndContent,
                                  String nameTemplate,
                                  String commentTemplate)

  Creates a new `ExpandableParameterSet` from a `ParameterSet` -array. The first element of this array is taken as a template for further calls of `addParameterToSet()`.

  Parameters:
    `templateAndContent` - the content (and template)
    `nameTemplate` - the name-template
    `commentTemplate` - the comment-template

Method Detail

### clone

    public ExpandableParameterSet clone()
                                 throws CloneNotSupportedException

  Description copied from class: `ParameterSet`
  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 `ParameterSet`
  Returns:
    a deep clone/copy of this `ParameterSet`
  Throws:
    `CloneNotSupportedException`

### loadParameters

    protected void loadParameters()
                           throws Exception

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

  Specified by:
    `loadParameters` in class `ParameterSet`
  Throws:
    `Exception` - if the parameters could not be loaded
  See Also:
    `Parameter`, `ParameterSet.parameters`, `ParameterSet.initParameterList()`, `ParameterSet.initParameterList(int)`

### replaceParametersWithRangedInstance

    protected void replaceParametersWithRangedInstance()
                                                throws Exception

  Description copied from class: `ParameterSet`
  Replaces all `Parameter`s in this `ParameterSet` by their equivalents implementing the `Rangeable` interface.

  Overrides:
    `replaceParametersWithRangedInstance` in class `ParameterSet`
  Throws:
    `Exception` - if these instances could not be created
  See Also:
    `ParameterSet.makeRanged()`

### addParameterToSet

    public void addParameterToSet()
                           throws CloneNotSupportedException

  Adds a new `ParameterSetContainer` containing a clone of the `ParameterSet`-template to the set of `Parameter`s.

  Throws:
    `CloneNotSupportedException` - if the template could not be cloned

### replaceContentWith

    public boolean replaceContentWith(ParameterSet[] paramSetArray)

  First removes all previous added `ParameterSetContainer`s and afterwards adds all given `ParameterSet`s (in the given order) enclosed in new `ParameterSetContainer`s.

  Parameters:
    `paramSetArray` - the `ParameterSet`s to be set
  Returns:
    `true`, if all given `ParameterSet`s are of the same class as the defined template-`ParameterSet` of this `ExpandableParameterSet`, `false` otherwise (In this case, neither the previous added `ParameterSetContainer`s are removed nor is any given `ParameterSet` added. Hence the `ExpandableParameterSet` stays unchanged.)

### parameterRemovable

    public boolean parameterRemovable()

  Returns `true` if there is still a `Parameter` that can be removed from the set.

  Returns:
    `true if a `Parameter` can be removed from the set`

### removeParameterFromSet

    public void removeParameterFromSet()

  Removes the last `Parameter` from set.

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

### fromXML

    protected void fromXML(StringBuffer representation)
                    throws NonParsableException

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

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

### toGalaxy

    public void toGalaxy(String namePrefix,
                         String configPrefix,
                         int depth,
                         StringBuffer descBuffer,
                         StringBuffer configBuffer)
                  throws Exception

  Description copied from interface: `GalaxyConvertible`
  Creates an Galaxy XML-representation of the parameters and appends it to `descBuffer` and variable configuration and appends it to `configBuffer`. The variable configuation is also used to parse user-supplied values returned by Galaxy.

  Specified by:
    `toGalaxy` in interface `GalaxyConvertible`
  Overrides:
    `toGalaxy` in class `ParameterSet`
  Parameters:
    `namePrefix` - the prefix of the variable name used in Galaxy
    `configPrefix` - the prefix for conditionals
    `depth` - the depth in the parameter hierarchy, used for graphical representation of nesting
    `descBuffer` - the buffer for the parameter description
    `configBuffer` - the buffer for the configuration line
  Throws:
    `Exception` - if the conversion fails

### 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`
  Overrides:
    `fromGalaxy` in class `ParameterSet`
  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