uk.ac.bham.gloss
Class ParameterContainer

java.lang.Object
  extended by uk.ac.bham.gloss.ParameterContainer

public class ParameterContainer
extends java.lang.Object

Class to hold a collection of values of the form name="value", where name is a non-null key or parameter-name and value is a non-null string. The name may have an optional namespace in the form "{namespace}name". At present, this class is basically a lightweight wrapper to java.util.TreeMap made specific to String. It adds a few convenient utility methods, including a constructor to clone an existing ParameterContainer. Copyright Richard Kaye 2007-8 for GLOSS, http://gloss.bham.ac.uk Usage permitted according to the GPL. No waranty.


Constructor Summary
ParameterContainer()
          Constructor for a new empty container.
ParameterContainer(ParameterContainer c)
          Constructor for a new container that is a clone of the existing one.
 
Method Summary
 void appendValue(java.lang.String key, java.lang.String value)
          Appends further data to an existing value.
 void appendValue(java.lang.String namespace, java.lang.String name, java.lang.String value)
          Appends further data to an existing value.
 ParameterContainer clone()
          Returns a clone of this container.
 java.lang.String getValue(java.lang.String key)
          Returns the value of the parameter with this name in this container, or null if there is no such parameter.
 java.lang.String getValue(java.lang.String namespace, java.lang.String name)
          Returns the value of the parameter with this name in this container, or null if there is no such parameter.
 boolean hasParameter(java.lang.String key)
          Returns true if the argument is the name of a parameter in this container.
 boolean hasParameter(java.lang.String namespace, java.lang.String name)
          Returns true if the argument is the name of a parameter in this container.
 void incrValue(java.lang.String key, java.lang.String value)
          Numerically increments a value (default = 1) to an existing numerical value.
 void incrValue(java.lang.String namespace, java.lang.String name, java.lang.String value)
          Numerically increments a value (default = 1) to an existing numerical value.
 java.util.Iterator<java.lang.String> iterator()
          returns an iterator over all keys in this container
static java.lang.String[] parse(java.lang.String key)
          parses a parameter or mode name into: outp[0] = namespace (null if absent) outp[1] = name where key is "{namespace}name" or "name" and namespace has balanced braces, and, in the second case, "name" does not start with "{".
 void putValue(java.lang.String key, java.lang.String value)
          Puts a new parameter or overwrites an existing one.
 void putValue(java.lang.String namespace, java.lang.String name, java.lang.String value)
          Puts a new parameter or overwrites an existing one.
 void putValues(ParameterContainer pc)
          Puts all values in pc into this ParameterContainer by copying them one-by-one.
 void toLog(int mask, Logger logger)
          method to send this ParameterContainer to the logger object with given mask
 java.lang.String toString()
          toString method
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParameterContainer

public ParameterContainer()
Constructor for a new empty container.


ParameterContainer

public ParameterContainer(ParameterContainer c)
Constructor for a new container that is a clone of the existing one.

Method Detail

clone

public ParameterContainer clone()
Returns a clone of this container.

Overrides:
clone in class java.lang.Object

parse

public static java.lang.String[] parse(java.lang.String key)
parses a parameter or mode name into: outp[0] = namespace (null if absent) outp[1] = name where key is "{namespace}name" or "name" and namespace has balanced braces, and, in the second case, "name" does not start with "{".


hasParameter

public boolean hasParameter(java.lang.String namespace,
                            java.lang.String name)
Returns true if the argument is the name of a parameter in this container.


hasParameter

public boolean hasParameter(java.lang.String key)
Returns true if the argument is the name of a parameter in this container.


getValue

public java.lang.String getValue(java.lang.String namespace,
                                 java.lang.String name)
Returns the value of the parameter with this name in this container, or null if there is no such parameter.


getValue

public java.lang.String getValue(java.lang.String key)
Returns the value of the parameter with this name in this container, or null if there is no such parameter.


putValues

public void putValues(ParameterContainer pc)
Puts all values in pc into this ParameterContainer by copying them one-by-one. Inefficient and makes heavy use of the stack. Do not use unless necessary.


iterator

public java.util.Iterator<java.lang.String> iterator()
returns an iterator over all keys in this container


putValue

public void putValue(java.lang.String namespace,
                     java.lang.String name,
                     java.lang.String value)
Puts a new parameter or overwrites an existing one. Neither arguments name nor value may be null, but either of the may be an empty string.


putValue

public void putValue(java.lang.String key,
                     java.lang.String value)
Puts a new parameter or overwrites an existing one. Neither argument may be null, but either of the may be an empty string.


appendValue

public void appendValue(java.lang.String namespace,
                        java.lang.String name,
                        java.lang.String value)
Appends further data to an existing value.


appendValue

public void appendValue(java.lang.String key,
                        java.lang.String value)
Appends further data to an existing value.


incrValue

public void incrValue(java.lang.String namespace,
                      java.lang.String name,
                      java.lang.String value)
Numerically increments a value (default = 1) to an existing numerical value. Leaves other values unchanged.


incrValue

public void incrValue(java.lang.String key,
                      java.lang.String value)
Numerically increments a value (default = 1) to an existing numerical value. Leaves other values unchanged.


toString

public java.lang.String toString()
toString method

Overrides:
toString in class java.lang.Object

toLog

public void toLog(int mask,
                  Logger logger)
method to send this ParameterContainer to the logger object with given mask