org.knime.core.node.config
Class Config

java.lang.Object
  extended by org.knime.core.node.config.AbstractConfigEntry
      extended by org.knime.core.node.config.Config
All Implemented Interfaces:
Serializable, Iterable<String>, TreeNode, ConfigRO, ConfigWO
Direct Known Subclasses:
ModelContent, NodeSettings

public abstract class Config
extends AbstractConfigEntry
implements Serializable, ConfigRO, ConfigWO

Supports a mechanism to save settings by their type and a key. Furthermore, it provides a method to recursively add new sub Config objects to this Config object, which then results in a tree-like structure.

This class provides several types of settings which are int, double, char, short, byte, boolean, java.lang.String, java.lang.Class, DataCell, and Config. For these supported elements, methods to add either a single or an array or retrieve them back by throwing an InvalidSettingsException or passing a default valid in advance have been implemented.

Author:
Thomas Gabriel, University of Konstanz
See Also:
Serialized Form

Nested Class Summary
(package private) static interface Config.DataCellEntry
          Interface for all registered DataCell objects.
 
Constructor Summary
protected Config(String key)
          Creates a new, empty config object with the given key.
 
Method Summary
 void addBoolean(String key, boolean value)
          Adds this boolean value to the Config by the given key.
 void addBooleanArray(String key, boolean... values)
          Adds this boolean values to the Config by the given key.
 void addByte(String key, byte value)
          Adds this byte value to the Config by the given key.
 void addByteArray(String key, byte... values)
          Adds this byte array to the Config by the given key.
 void addChar(String key, char value)
          Adds this char value to the Config by the given key.
 void addCharArray(String key, char... values)
          Adds this char array to the Config by the given key.
protected  void addConfig(Config config)
          Appends the given Config to this Config which has to directly derived from this class.
 Config addConfig(String key)
          Creates a new Config with the given key and returns it.
 void addDataCell(String key, DataCell cell)
          Adds this DataCell object to the Config by the given key.
 void addDataCellArray(String key, DataCell... values)
          Adds an array of DataCell objects to this Config.
 void addDataType(String key, DataType type)
          Adds this DataType object value to the Config by the given key.
 void addDataTypeArray(String key, DataType... values)
          Adds an array of DataType objects to this Config.
 void addDouble(String key, double value)
          Adds a double by the given key.
 void addDoubleArray(String key, double... values)
          Adds this double array value to the Config by the given key.
(package private)  void addEntry(AbstractConfigEntry entry)
          Adds the given Config entry to this Config.
 void addFloat(String key, float value)
          Adds a float by the given key.
 void addFloatArray(String key, float... values)
          Adds this float array value to the Config by the given key.
 void addInt(String key, int value)
          Adds an int.
 void addIntArray(String key, int... values)
          Adds this int array to the Config by the given key.
 void addLong(String key, long value)
          Adds this long value to the Config by the given key.
 void addLongArray(String key, long... values)
          Adds this long array to the Config by the given key.
 void addRowKey(String key, RowKey rowKey)
          Adds this RowKey object to this Config by the given key.
 void addRowKeyArray(String key, RowKey... rowKey)
          Adds this RowKey array to this Config by the given key.
 void addShort(String key, short value)
          Adds this short value to the Config by the given key.
 void addShortArray(String key, short... values)
          Adds this short array to the Config by the given key.
 void addString(String key, String value)
          Adds this String object to the Config by the given key.
 void addStringArray(String key, String... values)
          Adds this array of String object to the Config by the given key.
 Enumeration<TreeNode> children()
          An enumeration of a values.
 boolean containsKey(String key)
          Checks if this key for a particular type is in this Config.
 void copyTo(ConfigWO dest)
          Makes a deep copy of this Config and all sub-configs.
 boolean getBoolean(String key)
          Return boolean for key.
 boolean getBoolean(String key, boolean def)
          Return boolean for key or the default value if not available.
 boolean[] getBooleanArray(String key)
          Return a boolean array for key which can be null.
 boolean[] getBooleanArray(String key, boolean... def)
          Return a boolean array which can be null for key, or the default value if not available.
 byte getByte(String key)
          Return byte for key.
 byte getByte(String key, byte def)
          Return byte for key.
 byte[] getByteArray(String key)
          Return byte array which can be null for key.
 byte[] getByteArray(String key, byte... def)
          Return byte array which can be null for key, or the default value if not available.
 char getChar(String key)
          Return char for key.
 char getChar(String key, char def)
          Return char for key or the default value if not available.
 char[] getCharArray(String key)
          Return char array which can be null for key.
 char[] getCharArray(String key, char... def)
          Return char array which can be null for key, or the default array if the key is not available.
 TreeNode getChildAt(int childIndex)
          The TreeNode for the given index.
 int getChildCount()
           
 Config getConfig(String key)
          Retrieves Config by key.
 DataCell getDataCell(String key)
          Return DataCell for key.
 DataCell getDataCell(String key, DataCell def)
          Return a DataCell which can be null, or the default value if the key is not available.
 DataCell[] getDataCellArray(String key)
          Return DataCell array.
 DataCell[] getDataCellArray(String key, DataCell... def)
          Return DataCell array which can be null for key, or the default array if the key is not available.
 DataType getDataType(String key)
          Return DataType for key.
 DataType getDataType(String key, DataType def)
          Return a DataType elements or null for key, or the default value if not available.
 DataType[] getDataTypeArray(String key)
          Returns an array of DataType objects which can be null.
 DataType[] getDataTypeArray(String key, DataType... v)
          Returns the array of DataType objects for the given key or if not available the given array.
 double getDouble(String key)
          Return double for key.
 double getDouble(String key, double def)
          Return double for key or the default value if not available.
 double[] getDoubleArray(String key)
          Return double array for key or the default value if not available.
 double[] getDoubleArray(String key, double... def)
          Return double array which can be null for key, or the default array if the key is not available.
(package private)  AbstractConfigEntry getEntry(String key)
          Returns Config entry for a key.
 float getFloat(String key)
          Return float for key.
 float getFloat(String key, float def)
          Return float for key or the default value if not available.
 float[] getFloatArray(String key)
          Return float array for key or the default value if not available.
 float[] getFloatArray(String key, float... def)
          Return float array which can be null for key, or the default array if the key is not available.
 int getIndex(TreeNode node)
          Returns the index for a given TreeNode.
protected abstract  Config getInstance(String key)
          Creates a new Config of this type.
 int getInt(String key)
          Return int for key.
 int getInt(String key, int def)
          Return int for key or the default value if not available.
 int[] getIntArray(String key)
          Return int array which can be null for key, or the default array if the key is not available.
 int[] getIntArray(String key, int... def)
          Return int array which can be null for key, or the default array if the key is not available.
 long getLong(String key)
          Return long for key.
 long getLong(String key, long def)
          Return long value for key or the default if the key is not available.
 long[] getLongArray(String key)
          Return a long array which can be null for key, or the default value if not available.
 long[] getLongArray(String key, long... def)
          Return long array which can be null for key, or the default array if the key is not available.
 RowKey getRowKey(String key)
          Return RowKey for key.
 RowKey getRowKey(String key, RowKey def)
          Return a RowKey which can be null, or the default value if the key is not available.
 RowKey[] getRowKeyArray(String key)
          Return RowKey array for the given key.
 RowKey[] getRowKeyArray(String key, RowKey... def)
          Return a RowKey array which can be null, or the default value if the key is not available.
 short getShort(String key)
          Return short for key.
 short getShort(String key, short def)
          Return short value for key or the default if the key is not available.
 short[] getShortArray(String key)
          Return a short array which can be null for key, or the default value if not available.
 short[] getShortArray(String key, short... def)
          Return short array which can be null for key, or the default array if the key is not available.
 String getString(String key)
          Return String for key.
 String getString(String key, String def)
          Return String object which can be null, or the default array if the key is not available.
 String[] getStringArray(String key)
          Return String array which can be null for key.
 String[] getStringArray(String key, String... def)
          Return String array which can be null for key, or the default array if the key is not available.
 boolean hasIdenticalValue(AbstractConfigEntry otherConfig)
          Derived classes must compare their value with the value in the passed argument (on equality).
 boolean isLeaf()
           
 Iterator<String> iterator()
          
 Set<String> keySet()
          Returns an unmodifiable Set of keys in this Config.
protected  void load(InputStream is)
          Read config entries from an XML file into this object.
protected static Config loadFromXML(Config config, InputStream in)
          Reads Config from XML into a new Config object.
protected static Config readFromFile(ObjectInputStream ois)
          Creates new Config from the given file using the serialized object stream.
 void saveToXML(OutputStream os)
          Writes this Config to the given stream as XML.
 String toString()
          String summary of this object including key, type, and value.
 void toString(StringBuffer buf)
          Adds this and all children String representations to the given buffer.
 String toStringValue()
          Returns a String representation for this Config entry which is the used to re-load this Config entry.
 void writeToFile(ObjectOutputStream oos)
          Writes this Config into the given stream.
 
Methods inherited from class org.knime.core.node.config.AbstractConfigEntry
equals, getAllowsChildren, getKey, getParent, getType, hashCode, isIdentical, setKey, setParent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.knime.core.node.config.ConfigRO
getKey
 
Methods inherited from interface javax.swing.tree.TreeNode
getAllowsChildren, getParent
 
Methods inherited from interface org.knime.core.node.config.ConfigWO
getKey
 

Constructor Detail

Config

protected Config(String key)
Creates a new, empty config object with the given key.

Parameters:
key - The key for this Config.
Method Detail

getInstance

protected abstract Config getInstance(String key)
Creates a new Config of this type.

Parameters:
key - The new Config's key.
Returns:
A new instance of this Config.

addConfig

public final Config addConfig(String key)
Creates a new Config with the given key and returns it.

Specified by:
addConfig in interface ConfigWO
Parameters:
key - An identifier.
Returns:
A new Config object.

addConfig

protected final void addConfig(Config config)
Appends the given Config to this Config which has to directly derived from this class.

Parameters:
config - The Config to append.
Throws:
NullPointerException - If config is null.
IllegalArgumentException - If config is not instance of this class.

getConfig

public final Config getConfig(String key)
                       throws InvalidSettingsException
Retrieves Config by key.

Specified by:
getConfig in interface ConfigRO
Parameters:
key - The key.
Returns:
A Config object.
Throws:
InvalidSettingsException - If the key is not available.

addInt

public void addInt(String key,
                   int value)
Adds an int.

Specified by:
addInt in interface ConfigWO
Parameters:
key - The key.
value - The int value.

getInt

public int getInt(String key)
           throws InvalidSettingsException
Return int for key.

Specified by:
getInt in interface ConfigRO
Parameters:
key - The key.
Returns:
A generic int.
Throws:
InvalidSettingsException - If the key is not available.

addDouble

public void addDouble(String key,
                      double value)
Adds a double by the given key.

Specified by:
addDouble in interface ConfigWO
Parameters:
key - The key.
value - The double value to add.

getDouble

public double getDouble(String key)
                 throws InvalidSettingsException
Return double for key.

Specified by:
getDouble in interface ConfigRO
Parameters:
key - The key.
Returns:
A generic double.
Throws:
InvalidSettingsException - If the key is not available.

addFloat

public void addFloat(String key,
                     float value)
Adds a float by the given key.

Specified by:
addFloat in interface ConfigWO
Parameters:
key - The key.
value - The float value to add.

getFloat

public float getFloat(String key)
               throws InvalidSettingsException
Return float for key.

Specified by:
getFloat in interface ConfigRO
Parameters:
key - The key.
Returns:
A generic float.
Throws:
InvalidSettingsException - If the key is not available.

addChar

public void addChar(String key,
                    char value)
Adds this char value to the Config by the given key.

Specified by:
addChar in interface ConfigWO
Parameters:
key - The key.
value - The char to add.

getChar

public char getChar(String key)
             throws InvalidSettingsException
Return char for key.

Specified by:
getChar in interface ConfigRO
Parameters:
key - The key.
Returns:
A generic char.
Throws:
InvalidSettingsException - If the key is not available.

addShort

public void addShort(String key,
                     short value)
Adds this short value to the Config by the given key.

Specified by:
addShort in interface ConfigWO
Parameters:
key - The key.
value - The short to add.

getShort

public short getShort(String key)
               throws InvalidSettingsException
Return short for key.

Specified by:
getShort in interface ConfigRO
Parameters:
key - The key.
Returns:
A generic short.
Throws:
InvalidSettingsException - If the key is not available.

addLong

public void addLong(String key,
                    long value)
Adds this long value to the Config by the given key.

Specified by:
addLong in interface ConfigWO
Parameters:
key - The key.
value - The long to add.

getLong

public long getLong(String key)
             throws InvalidSettingsException
Return long for key.

Specified by:
getLong in interface ConfigRO
Parameters:
key - The key.
Returns:
A generic long.
Throws:
InvalidSettingsException - If the key is not available.

addByte

public void addByte(String key,
                    byte value)
Adds this byte value to the Config by the given key.

Specified by:
addByte in interface ConfigWO
Parameters:
key - The key.
value - The byte to add.

getByte

public byte getByte(String key)
             throws InvalidSettingsException
Return byte for key.

Specified by:
getByte in interface ConfigRO
Parameters:
key - The key.
Returns:
A generic byte.
Throws:
InvalidSettingsException - If the key is not available.

addString

public void addString(String key,
                      String value)
Adds this String object to the Config by the given key. The String can be null.

Specified by:
addString in interface ConfigWO
Parameters:
key - The key.
value - The boolean to add.

getString

public String getString(String key)
                 throws InvalidSettingsException
Return String for key.

Specified by:
getString in interface ConfigRO
Parameters:
key - The key.
Returns:
A String object.
Throws:
InvalidSettingsException - If the key is not available.

addDataCell

public void addDataCell(String key,
                        DataCell cell)
Adds this DataCell object to the Config by the given key. The cell can be null.

Specified by:
addDataCell in interface ConfigWO
Parameters:
key - The key.
cell - The DataCell to add.

addDataType

public void addDataType(String key,
                        DataType type)
Adds this DataType object value to the Config by the given key. The type can be null.

Specified by:
addDataType in interface ConfigWO
Parameters:
key - The key.
type - The DataType object to add.

getDataCell

public DataCell getDataCell(String key)
                     throws InvalidSettingsException
Return DataCell for key.

Specified by:
getDataCell in interface ConfigRO
Parameters:
key - The key.
Returns:
A DataCell.
Throws:
InvalidSettingsException - If the key is not available.

getDataType

public DataType getDataType(String key)
                     throws InvalidSettingsException
Return DataType for key.

Specified by:
getDataType in interface ConfigRO
Parameters:
key - The key.
Returns:
A DataType.
Throws:
InvalidSettingsException - If the key is not available.

keySet

public Set<String> keySet()
Returns an unmodifiable Set of keys in this Config.

Specified by:
keySet in interface ConfigRO
Returns:
A Set of keys.

hasIdenticalValue

public boolean hasIdenticalValue(AbstractConfigEntry otherConfig)
Description copied from class: AbstractConfigEntry
Derived classes must compare their value with the value in the passed argument (on equality). They can safely assume that the specified object has the same java class, the same type and key.

Specified by:
hasIdenticalValue in class AbstractConfigEntry
Parameters:
otherConfig - The other Config to check.
Returns:
true if both Config objects store identical entries.

containsKey

public boolean containsKey(String key)
Checks if this key for a particular type is in this Config.

Specified by:
containsKey in interface ConfigRO
Parameters:
key - The key.
Returns:
true if available, false if key is null or not available.

getBoolean

public boolean getBoolean(String key)
                   throws InvalidSettingsException
Return boolean for key.

Specified by:
getBoolean in interface ConfigRO
Parameters:
key - The key.
Returns:
A generic boolean.
Throws:
InvalidSettingsException - If the key is not available.

addBoolean

public void addBoolean(String key,
                       boolean value)
Adds this boolean value to the Config by the given key.

Specified by:
addBoolean in interface ConfigWO
Parameters:
key - The key.
value - The boolean to add.

getInt

public int getInt(String key,
                  int def)
Return int for key or the default value if not available.

Specified by:
getInt in interface ConfigRO
Parameters:
key - The key.
def - Returned if no value available for the given key.
Returns:
A generic int.

getIntArray

public int[] getIntArray(String key)
                  throws InvalidSettingsException
Return int array which can be null for key, or the default array if the key is not available.

Specified by:
getIntArray in interface ConfigRO
Parameters:
key - The key.
Returns:
An int array.
Throws:
InvalidSettingsException - If the key is not available.

getIntArray

public int[] getIntArray(String key,
                         int... def)
Return int array which can be null for key, or the default array if the key is not available.

Specified by:
getIntArray in interface ConfigRO
Parameters:
key - The key.
def - The default array returned if the key is not available.
Returns:
An int array.

addIntArray

public void addIntArray(String key,
                        int... values)
Adds this int array to the Config by the given key.

Specified by:
addIntArray in interface ConfigWO
Parameters:
key - The key.
values - The int array to add.

getDouble

public double getDouble(String key,
                        double def)
Return double for key or the default value if not available.

Specified by:
getDouble in interface ConfigRO
Parameters:
key - The key.
def - Returned if no value available for the given key.
Returns:
A generic double.

getDoubleArray

public double[] getDoubleArray(String key)
                        throws InvalidSettingsException
Return double array for key or the default value if not available.

Specified by:
getDoubleArray in interface ConfigRO
Parameters:
key - The key.
Returns:
An array of double values.
Throws:
InvalidSettingsException - If the key is not available.

getDoubleArray

public double[] getDoubleArray(String key,
                               double... def)
Return double array which can be null for key, or the default array if the key is not available.

Specified by:
getDoubleArray in interface ConfigRO
Parameters:
key - The key.
def - The default array returned if the key is not available.
Returns:
A double array.

getFloat

public float getFloat(String key,
                      float def)
Return float for key or the default value if not available.

Specified by:
getFloat in interface ConfigRO
Parameters:
key - The key.
def - Returned if no value available for the given key.
Returns:
A generic float.

getFloatArray

public float[] getFloatArray(String key)
                      throws InvalidSettingsException
Return float array for key or the default value if not available.

Specified by:
getFloatArray in interface ConfigRO
Parameters:
key - The key.
Returns:
An array of float values.
Throws:
InvalidSettingsException - If the key is not available.

getFloatArray

public float[] getFloatArray(String key,
                             float... def)
Return float array which can be null for key, or the default array if the key is not available.

Specified by:
getFloatArray in interface ConfigRO
Parameters:
key - The key.
def - The default array returned if the key is not available.
Returns:
A float array.

addDoubleArray

public void addDoubleArray(String key,
                           double... values)
Adds this double array value to the Config by the given key. The array can be null.

Specified by:
addDoubleArray in interface ConfigWO
Parameters:
key - The key.
values - The double array to add.

addFloatArray

public void addFloatArray(String key,
                          float... values)
Adds this float array value to the Config by the given key. The array can be null.

Specified by:
addFloatArray in interface ConfigWO
Parameters:
key - The key.
values - The float array to add.

getChar

public char getChar(String key,
                    char def)
Return char for key or the default value if not available.

Specified by:
getChar in interface ConfigRO
Parameters:
key - The key.
def - Returned if no value available for the given key.
Returns:
A generic char.

getCharArray

public char[] getCharArray(String key)
                    throws InvalidSettingsException
Return char array which can be null for key.

Specified by:
getCharArray in interface ConfigRO
Parameters:
key - The key.
Returns:
A char array.
Throws:
InvalidSettingsException - If the the key is not available.

getByteArray

public byte[] getByteArray(String key,
                           byte... def)
Return byte array which can be null for key, or the default value if not available.

Specified by:
getByteArray in interface ConfigRO
Parameters:
key - The key.
def - Returned if no value available for the given key.
Returns:
A byte array.

getByteArray

public byte[] getByteArray(String key)
                    throws InvalidSettingsException
Return byte array which can be null for key.

Specified by:
getByteArray in interface ConfigRO
Parameters:
key - The key.
Returns:
A byte array.
Throws:
InvalidSettingsException - If the the key is not available.

addByteArray

public void addByteArray(String key,
                         byte... values)
Adds this byte array to the Config by the given key. The array can be null.

Specified by:
addByteArray in interface ConfigWO
Parameters:
key - The key.
values - The byte array to add.

getByte

public byte getByte(String key,
                    byte def)
Return byte for key.

Specified by:
getByte in interface ConfigRO
Parameters:
key - The key.
def - Returned if no value available for the given key.
Returns:
A generic byte.

getShortArray

public short[] getShortArray(String key)
                      throws InvalidSettingsException
Return a short array which can be null for key, or the default value if not available.

Specified by:
getShortArray in interface ConfigRO
Parameters:
key - The key.
Returns:
A short array.
Throws:
InvalidSettingsException - If the key is not available.

getShortArray

public short[] getShortArray(String key,
                             short... def)
Return short array which can be null for key, or the default array if the key is not available.

Specified by:
getShortArray in interface ConfigRO
Parameters:
key - The key.
def - The default array returned if the key is not available.
Returns:
A short array.

getLongArray

public long[] getLongArray(String key)
                    throws InvalidSettingsException
Return a long array which can be null for key, or the default value if not available.

Specified by:
getLongArray in interface ConfigRO
Parameters:
key - The key.
Returns:
A long array.
Throws:
InvalidSettingsException - If the key is not available.

getLongArray

public long[] getLongArray(String key,
                           long... def)
Return long array which can be null for key, or the default array if the key is not available.

Specified by:
getLongArray in interface ConfigRO
Parameters:
key - The key.
def - The default array returned if the key is not available.
Returns:
A long array.

addShortArray

public void addShortArray(String key,
                          short... values)
Adds this short array to the Config by the given key.

Specified by:
addShortArray in interface ConfigWO
Parameters:
key - The key.
values - The short to add.

getShort

public short getShort(String key,
                      short def)
Return short value for key or the default if the key is not available.

Specified by:
getShort in interface ConfigRO
Parameters:
key - The key.
def - The default values returned if the key is not available.
Returns:
A short value.

addLongArray

public void addLongArray(String key,
                         long... values)
Adds this long array to the Config by the given key.

Specified by:
addLongArray in interface ConfigWO
Parameters:
key - The key.
values - The long arry to add.

getLong

public long getLong(String key,
                    long def)
Return long value for key or the default if the key is not available.

Specified by:
getLong in interface ConfigRO
Parameters:
key - The key.
def - The default values returned if the key is not available.
Returns:
A long value.

getCharArray

public char[] getCharArray(String key,
                           char... def)
Return char array which can be null for key, or the default array if the key is not available.

Specified by:
getCharArray in interface ConfigRO
Parameters:
key - The key.
def - The default array returned if the key is not available.
Returns:
A char array.

addCharArray

public void addCharArray(String key,
                         char... values)
Adds this char array to the Config by the given key.

Specified by:
addCharArray in interface ConfigWO
Parameters:
key - The key.
values - The char array to add.

getBoolean

public boolean getBoolean(String key,
                          boolean def)
Return boolean for key or the default value if not available.

Specified by:
getBoolean in interface ConfigRO
Parameters:
key - The key.
def - Returned if no value available for the given key.
Returns:
A generic boolean.

getBooleanArray

public boolean[] getBooleanArray(String key)
                          throws InvalidSettingsException
Return a boolean array for key which can be null.

Specified by:
getBooleanArray in interface ConfigRO
Parameters:
key - The key.
Returns:
A boolean or null.
Throws:
InvalidSettingsException - If the key is not available.

getBooleanArray

public boolean[] getBooleanArray(String key,
                                 boolean... def)
Return a boolean array which can be null for key, or the default value if not available.

Specified by:
getBooleanArray in interface ConfigRO
Parameters:
key - The key.
def - Returned if no value available for the given key.
Returns:
A boolean array.

addBooleanArray

public void addBooleanArray(String key,
                            boolean... values)
Adds this boolean values to the Config by the given key. The array can be null.

Specified by:
addBooleanArray in interface ConfigWO
Parameters:
key - The key.
values - The boolean array to add.

getString

public String getString(String key,
                        String def)
Return String object which can be null, or the default array if the key is not available.

Specified by:
getString in interface ConfigRO
Parameters:
key - The key.
def - The default String returned if the key is not available.
Returns:
A String.

getStringArray

public String[] getStringArray(String key)
                        throws InvalidSettingsException
Return String array which can be null for key.

Specified by:
getStringArray in interface ConfigRO
Parameters:
key - The key.
Returns:
A String array.
Throws:
InvalidSettingsException - If the key is not available.

getStringArray

public String[] getStringArray(String key,
                               String... def)
Return String array which can be null for key, or the default array if the key is not available.

Specified by:
getStringArray in interface ConfigRO
Parameters:
key - The key.
def - The default array returned if the key is not available.
Returns:
A String array.

addStringArray

public void addStringArray(String key,
                           String... values)
Adds this array of String object to the Config by the given key. The array and the elements can be null.

Specified by:
addStringArray in interface ConfigWO
Parameters:
key - The key.
values - The String array to add.

getDataCell

public DataCell getDataCell(String key,
                            DataCell def)
Return a DataCell which can be null, or the default value if the key is not available.

Specified by:
getDataCell in interface ConfigRO
Parameters:
key - The key.
def - The default value, returned id the key is not available.
Returns:
A DataCell object.

getDataType

public DataType getDataType(String key,
                            DataType def)
Return a DataType elements or null for key, or the default value if not available.

Specified by:
getDataType in interface ConfigRO
Parameters:
key - The key.
def - Returned if no value available for the given key.
Returns:
A DataType object or null, or the def value. generic boolean.

getDataCellArray

public DataCell[] getDataCellArray(String key)
                            throws InvalidSettingsException
Return DataCell array. The array an the elements can be null.

Specified by:
getDataCellArray in interface ConfigRO
Parameters:
key - The key.
Returns:
A DataCell array.
Throws:
InvalidSettingsException - If the the key is not available.

getDataCellArray

public DataCell[] getDataCellArray(String key,
                                   DataCell... def)
Return DataCell array which can be null for key, or the default array if the key is not available.

Specified by:
getDataCellArray in interface ConfigRO
Parameters:
key - The key.
def - The default array returned if the key is not available.
Returns:
A char array.

getRowKey

public RowKey getRowKey(String key)
                 throws InvalidSettingsException
Return RowKey for key.

Specified by:
getRowKey in interface ConfigRO
Parameters:
key - the identifier used to store the RowKey before
Returns:
the store RowKey
Throws:
InvalidSettingsException - if the key is not available

getRowKey

public RowKey getRowKey(String key,
                        RowKey def)
Return a RowKey which can be null, or the default value if the key is not available.

Specified by:
getRowKey in interface ConfigRO
Parameters:
key - identifier used to store the RowKey before
def - default value, returned if the key is not available
Returns:
the stored RowKey

addRowKey

public void addRowKey(String key,
                      RowKey rowKey)
Adds this RowKey object to this Config by the given key. The row key can be null.

Specified by:
addRowKey in interface ConfigWO
Parameters:
key - identifier used to store and the load the RowKey
rowKey - value to store

getRowKeyArray

public RowKey[] getRowKeyArray(String key)
                        throws InvalidSettingsException
Return RowKey array for the given key.

Specified by:
getRowKeyArray in interface ConfigRO
Parameters:
key - the identifier used to store the RowKey array before
Returns:
the store RowKey array
Throws:
InvalidSettingsException - if the key is not available

getRowKeyArray

public RowKey[] getRowKeyArray(String key,
                               RowKey... def)
Return a RowKey array which can be null, or the default value if the key is not available.

Specified by:
getRowKeyArray in interface ConfigRO
Parameters:
key - identifier used to store the RowKey array before
def - default value, returned if the key is not available
Returns:
the stored RowKey array

addRowKeyArray

public void addRowKeyArray(String key,
                           RowKey... rowKey)
Adds this RowKey array to this Config by the given key. The row key array can be null.

Specified by:
addRowKeyArray in interface ConfigWO
Parameters:
key - identifier used to store and the load the RowKey array
rowKey - array to store

getDataTypeArray

public DataType[] getDataTypeArray(String key)
                            throws InvalidSettingsException
Returns an array of DataType objects which can be null.

Specified by:
getDataTypeArray in interface ConfigRO
Parameters:
key - The key.
Returns:
An array of DataType objects.
Throws:
InvalidSettingsException - The the object is not available for the given key.

getDataTypeArray

public DataType[] getDataTypeArray(String key,
                                   DataType... v)
Returns the array of DataType objects for the given key or if not available the given array.

Specified by:
getDataTypeArray in interface ConfigRO
Parameters:
key - The key.
v - The default array, returned if no entry available for the key.
Returns:
An array of DataType objects.

addDataCellArray

public void addDataCellArray(String key,
                             DataCell... values)
Adds an array of DataCell objects to this Config. The array and all elements can be null.

Specified by:
addDataCellArray in interface ConfigWO
Parameters:
key - The key.
values - The data cells, elements can be null.

addDataTypeArray

public void addDataTypeArray(String key,
                             DataType... values)
Adds an array of DataType objects to this Config. The array and all elements can be null.

Specified by:
addDataTypeArray in interface ConfigWO
Parameters:
key - The key.
values - The data types, elements can be null.

getEntry

AbstractConfigEntry getEntry(String key)
Returns Config entry for a key.

Parameters:
key - The key.
Returns:
The Config entry for the key.

addEntry

void addEntry(AbstractConfigEntry entry)
Adds the given Config entry to this Config.

Parameters:
entry - The Config entry to add.

iterator

public final Iterator<String> iterator()

Specified by:
iterator in interface Iterable<String>
Specified by:
iterator in interface ConfigRO

toStringValue

public final String toStringValue()
Returns a String representation for this Config entry which is the used to re-load this Config entry.

Specified by:
toStringValue in class AbstractConfigEntry
Returns:
A String representing this Config entry which can be null.

toString

public final void toString(StringBuffer buf)
Adds this and all children String representations to the given buffer.

Parameters:
buf - The string buffer to which this Config's String all all children String representation is added.

toString

public String toString()
String summary of this object including key, type, and value.

Overrides:
toString in class AbstractConfigEntry
Returns:
key + type + value
See Also:
Object.toString()

writeToFile

public final void writeToFile(ObjectOutputStream oos)
                       throws IOException
Writes this Config into the given stream.

Parameters:
oos - Write Config to this stream.
Throws:
IOException - If the file can not be accessed.

readFromFile

protected static Config readFromFile(ObjectInputStream ois)
                              throws IOException
Creates new Config from the given file using the serialized object stream.

Parameters:
ois - Read Config from this stream.
Returns:
The new Config.
Throws:
IOException - Problem opening the file or content is not a Config.

saveToXML

public final void saveToXML(OutputStream os)
                     throws IOException
Writes this Config to the given stream as XML. The stream will be closed when finished.

Specified by:
saveToXML in interface ConfigRO
Parameters:
os - The stream to write into.
Throws:
IOException - If this Config could be stored to the stream.

loadFromXML

protected static Config loadFromXML(Config config,
                                    InputStream in)
                             throws IOException
Reads Config from XML into a new Config object.

Parameters:
config - Depending on the readRoot, we write into this Config and return it.
in - The stream to read XML Config from.
Returns:
A new Config filled with the content read from XML.
Throws:
IOException - If the Config could not be load from stream.

load

protected void load(InputStream is)
             throws IOException
Read config entries from an XML file into this object.

Parameters:
is - The XML inputstream storing the configuration to read
Throws:
IOException - If the stream could not be read.

copyTo

public void copyTo(ConfigWO dest)
Makes a deep copy of this Config and all sub-configs.

Specified by:
copyTo in interface ConfigRO
Parameters:
dest - the destination this Config object is copied to.

getChildAt

public TreeNode getChildAt(int childIndex)
The TreeNode for the given index.

Specified by:
getChildAt in interface TreeNode
Overrides:
getChildAt in class AbstractConfigEntry
Parameters:
childIndex - The index to retrieve the TreeNode for.
Returns:
The associated TreeNode.

getChildCount

public int getChildCount()
Specified by:
getChildCount in interface TreeNode
Overrides:
getChildCount in class AbstractConfigEntry
Returns:
The number of entries in this Config.
See Also:
TreeNode.getChildCount()

getIndex

public int getIndex(TreeNode node)
Returns the index for a given TreeNode.

Specified by:
getIndex in interface TreeNode
Overrides:
getIndex in class AbstractConfigEntry
Parameters:
node - The TreeNode to get the index for.
Returns:
The index of the given node.
See Also:
TreeNode.getIndex(javax.swing.tree.TreeNode)

isLeaf

public final boolean isLeaf()
Specified by:
isLeaf in interface TreeNode
Overrides:
isLeaf in class AbstractConfigEntry
Returns:
true, only if the map is empty.
See Also:
TreeNode.isLeaf()

children

public final Enumeration<TreeNode> children()
An enumeration of a values.

Specified by:
children in interface TreeNode
Overrides:
children in class AbstractConfigEntry
Returns:
All elements of this Config.
See Also:
TreeNode.children()


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.