Package ec.util

# Class Parameter

java.lang.Object
ec.util.Parameter

All Implemented Interfaces:
  `Serializable`

public class Parameter extends Object implements Serializable

A Parameter is an object which the ParameterDatabase class uses as a key to associate with strings, forming a key-value pair. Parameters are designed to be hierarchical in nature, consisting of "path items" separated by a path separator. Parameters are created either from a single path item, from an array of path items, or both. For example, a parameter with the path foo.bar.baz might be created from `new Parameter(new String[] {"foo","bar","baz"})`

Parameters are not mutable -- but once a parameter is created, path items may be pushed an popped from it, forming a new parameter. For example, if a parameter p consists of the path foo.bar.baz, p.pop() results in a new parameter whose path is foo.bar This pushing and popping isn't cheap, so be sparing.

Because this system internally uses "." as its path separator, you should not use that character in parts of the path that you provide; however if you need some other path separator, you can change the delimiter in the code trivially. In fact, you can create a new Parameter with a path foo.bar.baz simply by calling `new Parameter("foo.bar.baz")` but you'd better know what you're doing.

Additionally, parameters must not contain "#", "=", non-ascii values, or whitespace. Yes, a parameter path item may be empty.

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final char`
  `delimiter`
  `String`
  `param`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Parameter(String s)`
  Creates a new parameter from the single path item in s.
  `Parameter(String[] s)`
  Creates a new parameter by joining the path items in s into a single path.
  `Parameter(String s, String[] s2)`
  Creates a new parameter from the path item in s, plus the path items in s2.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Parameter`
  `pop()`
  Returns a new parameter with one path item popped off the end.
  `Parameter`
  `popn(int n)`
  Returns a new parameter with n path items popped off the end.
  `Parameter`
  `push(String s)`
  Returns a new parameter with s added to the end of the current path items.
  `Parameter`
  `push(String[] s)`
  Returns a new parameter with the path items in s added to the end of the current path items.
  `String`
  `top()`
  Returns the path item at the far end of the parameter.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### param

    public String param

  - ### delimiter

    public static final char delimiter
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### Parameter

    public Parameter(String[] s) throws BadParameterException
    Creates a new parameter by joining the path items in s into a single path.
    Throws:
      `BadParameterException`

  - ### Parameter

    public Parameter(String s) throws BadParameterException
    Creates a new parameter from the single path item in s.
    Throws:
      `BadParameterException`

  - ### Parameter

    public Parameter(String s, String[] s2)
    Creates a new parameter from the path item in s, plus the path items in s2. s2 may be null or empty, but not s

- ## Method Details

  - ### push

    public Parameter push(String s)
    Returns a new parameter with s added to the end of the current path items. If s is empty, nothing is pushed on (and no delimiter is added to the end).

  - ### push

    public Parameter push(String[] s)
    Returns a new parameter with the path items in s added to the end of the current path items.

  - ### pop

    public Parameter pop()
    Returns a new parameter with one path item popped off the end. If this would result in a parameter with an empty collection of path items, null is returned.

  - ### popn

    public Parameter popn(int n)
    Returns a new parameter with n path items popped off the end. If this would result in a parameter with an empty collection of path items, null is returned.

  - ### top

    public String top()
    Returns the path item at the far end of the parameter.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`