|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.knime.core.node.config.AbstractConfigEntry
org.knime.core.node.config.Config
public abstract class Config
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.
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 |
---|
protected Config(String key)
key
- The key for this Config.Method Detail |
---|
protected abstract Config getInstance(String key)
key
- The new Config's key.
public final Config addConfig(String key)
addConfig
in interface ConfigWO
key
- An identifier.
protected final void addConfig(Config config)
config
- The Config to append.
NullPointerException
- If config
is null.
IllegalArgumentException
- If config
is not instance
of this class.public final Config getConfig(String key) throws InvalidSettingsException
getConfig
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public void addInt(String key, int value)
addInt
in interface ConfigWO
key
- The key.value
- The int value.public int getInt(String key) throws InvalidSettingsException
getInt
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public void addDouble(String key, double value)
addDouble
in interface ConfigWO
key
- The key.value
- The double value to add.public double getDouble(String key) throws InvalidSettingsException
getDouble
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public void addFloat(String key, float value)
addFloat
in interface ConfigWO
key
- The key.value
- The float value to add.public float getFloat(String key) throws InvalidSettingsException
getFloat
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public void addChar(String key, char value)
addChar
in interface ConfigWO
key
- The key.value
- The char to add.public char getChar(String key) throws InvalidSettingsException
getChar
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public void addShort(String key, short value)
addShort
in interface ConfigWO
key
- The key.value
- The short to add.public short getShort(String key) throws InvalidSettingsException
getShort
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public void addLong(String key, long value)
addLong
in interface ConfigWO
key
- The key.value
- The long to add.public long getLong(String key) throws InvalidSettingsException
getLong
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public void addByte(String key, byte value)
addByte
in interface ConfigWO
key
- The key.value
- The byte to add.public byte getByte(String key) throws InvalidSettingsException
getByte
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public void addString(String key, String value)
addString
in interface ConfigWO
key
- The key.value
- The boolean to add.public String getString(String key) throws InvalidSettingsException
getString
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public void addDataCell(String key, DataCell cell)
addDataCell
in interface ConfigWO
key
- The key.cell
- The DataCell to add.public void addDataType(String key, DataType type)
addDataType
in interface ConfigWO
key
- The key.type
- The DataType object to add.public DataCell getDataCell(String key) throws InvalidSettingsException
getDataCell
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public DataType getDataType(String key) throws InvalidSettingsException
getDataType
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public Set<String> keySet()
keySet
in interface ConfigRO
public boolean hasIdenticalValue(AbstractConfigEntry otherConfig)
AbstractConfigEntry
hasIdenticalValue
in class AbstractConfigEntry
otherConfig
- The other Config to check.
public boolean containsKey(String key)
containsKey
in interface ConfigRO
key
- The key.
null
or not available.public boolean getBoolean(String key) throws InvalidSettingsException
getBoolean
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public void addBoolean(String key, boolean value)
addBoolean
in interface ConfigWO
key
- The key.value
- The boolean to add.public int getInt(String key, int def)
getInt
in interface ConfigRO
key
- The key.def
- Returned if no value available for the given key.
public int[] getIntArray(String key) throws InvalidSettingsException
getIntArray
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public int[] getIntArray(String key, int... def)
getIntArray
in interface ConfigRO
key
- The key.def
- The default array returned if the key is not available.
public void addIntArray(String key, int... values)
addIntArray
in interface ConfigWO
key
- The key.values
- The int array to add.public double getDouble(String key, double def)
getDouble
in interface ConfigRO
key
- The key.def
- Returned if no value available for the given key.
public double[] getDoubleArray(String key) throws InvalidSettingsException
getDoubleArray
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public double[] getDoubleArray(String key, double... def)
getDoubleArray
in interface ConfigRO
key
- The key.def
- The default array returned if the key is not available.
public float getFloat(String key, float def)
getFloat
in interface ConfigRO
key
- The key.def
- Returned if no value available for the given key.
public float[] getFloatArray(String key) throws InvalidSettingsException
getFloatArray
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public float[] getFloatArray(String key, float... def)
getFloatArray
in interface ConfigRO
key
- The key.def
- The default array returned if the key is not available.
public void addDoubleArray(String key, double... values)
addDoubleArray
in interface ConfigWO
key
- The key.values
- The double array to add.public void addFloatArray(String key, float... values)
addFloatArray
in interface ConfigWO
key
- The key.values
- The float array to add.public char getChar(String key, char def)
getChar
in interface ConfigRO
key
- The key.def
- Returned if no value available for the given key.
public char[] getCharArray(String key) throws InvalidSettingsException
getCharArray
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the the key is not available.public byte[] getByteArray(String key, byte... def)
getByteArray
in interface ConfigRO
key
- The key.def
- Returned if no value available for the given key.
public byte[] getByteArray(String key) throws InvalidSettingsException
getByteArray
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the the key is not available.public void addByteArray(String key, byte... values)
addByteArray
in interface ConfigWO
key
- The key.values
- The byte array to add.public byte getByte(String key, byte def)
getByte
in interface ConfigRO
key
- The key.def
- Returned if no value available for the given key.
public short[] getShortArray(String key) throws InvalidSettingsException
getShortArray
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public short[] getShortArray(String key, short... def)
getShortArray
in interface ConfigRO
key
- The key.def
- The default array returned if the key is not available.
public long[] getLongArray(String key) throws InvalidSettingsException
getLongArray
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public long[] getLongArray(String key, long... def)
getLongArray
in interface ConfigRO
key
- The key.def
- The default array returned if the key is not available.
public void addShortArray(String key, short... values)
addShortArray
in interface ConfigWO
key
- The key.values
- The short to add.public short getShort(String key, short def)
getShort
in interface ConfigRO
key
- The key.def
- The default values returned if the key is not available.
public void addLongArray(String key, long... values)
addLongArray
in interface ConfigWO
key
- The key.values
- The long arry to add.public long getLong(String key, long def)
getLong
in interface ConfigRO
key
- The key.def
- The default values returned if the key is not available.
public char[] getCharArray(String key, char... def)
getCharArray
in interface ConfigRO
key
- The key.def
- The default array returned if the key is not available.
public void addCharArray(String key, char... values)
addCharArray
in interface ConfigWO
key
- The key.values
- The char array to add.public boolean getBoolean(String key, boolean def)
getBoolean
in interface ConfigRO
key
- The key.def
- Returned if no value available for the given key.
public boolean[] getBooleanArray(String key) throws InvalidSettingsException
getBooleanArray
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public boolean[] getBooleanArray(String key, boolean... def)
getBooleanArray
in interface ConfigRO
key
- The key.def
- Returned if no value available for the given key.
public void addBooleanArray(String key, boolean... values)
addBooleanArray
in interface ConfigWO
key
- The key.values
- The boolean array to add.public String getString(String key, String def)
getString
in interface ConfigRO
key
- The key.def
- The default String returned if the key is not available.
public String[] getStringArray(String key) throws InvalidSettingsException
getStringArray
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the key is not available.public String[] getStringArray(String key, String... def)
getStringArray
in interface ConfigRO
key
- The key.def
- The default array returned if the key is not available.
public void addStringArray(String key, String... values)
addStringArray
in interface ConfigWO
key
- The key.values
- The String array to add.public DataCell getDataCell(String key, DataCell def)
getDataCell
in interface ConfigRO
key
- The key.def
- The default value, returned id the key is not available.
public DataType getDataType(String key, DataType def)
getDataType
in interface ConfigRO
key
- The key.def
- Returned if no value available for the given key.
public DataCell[] getDataCellArray(String key) throws InvalidSettingsException
getDataCellArray
in interface ConfigRO
key
- The key.
InvalidSettingsException
- If the the key is not available.public DataCell[] getDataCellArray(String key, DataCell... def)
getDataCellArray
in interface ConfigRO
key
- The key.def
- The default array returned if the key is not available.
public RowKey getRowKey(String key) throws InvalidSettingsException
RowKey
for key.
getRowKey
in interface ConfigRO
key
- the identifier used to store the RowKey
before
RowKey
InvalidSettingsException
- if the key is not availablepublic RowKey getRowKey(String key, RowKey def)
RowKey
which can be null, or the default value if
the key is not available.
getRowKey
in interface ConfigRO
key
- identifier used to store the RowKey
beforedef
- default value, returned if the key is not available
RowKey
public void addRowKey(String key, RowKey rowKey)
RowKey
object to this Config by the given key.
The row key can be null.
addRowKey
in interface ConfigWO
key
- identifier used to store and the load the RowKey
rowKey
- value to storepublic RowKey[] getRowKeyArray(String key) throws InvalidSettingsException
RowKey
array for the given key.
getRowKeyArray
in interface ConfigRO
key
- the identifier used to store the RowKey
array
before
RowKey
array
InvalidSettingsException
- if the key is not availablepublic RowKey[] getRowKeyArray(String key, RowKey... def)
RowKey
array which can be null, or the default
value if the key is not available.
getRowKeyArray
in interface ConfigRO
key
- identifier used to store the RowKey
array beforedef
- default value, returned if the key is not available
RowKey
arraypublic void addRowKeyArray(String key, RowKey... rowKey)
RowKey
array to this Config by the given key.
The row key array can be null.
addRowKeyArray
in interface ConfigWO
key
- identifier used to store and the load the RowKey
arrayrowKey
- array to storepublic DataType[] getDataTypeArray(String key) throws InvalidSettingsException
getDataTypeArray
in interface ConfigRO
key
- The key.
InvalidSettingsException
- The the object is not available for the
given key.public DataType[] getDataTypeArray(String key, DataType... v)
getDataTypeArray
in interface ConfigRO
key
- The key.v
- The default array, returned if no entry available for the key.
public void addDataCellArray(String key, DataCell... values)
addDataCellArray
in interface ConfigWO
key
- The key.values
- The data cells, elements can be null.public void addDataTypeArray(String key, DataType... values)
addDataTypeArray
in interface ConfigWO
key
- The key.values
- The data types, elements can be null.AbstractConfigEntry getEntry(String key)
key
- The key.
void addEntry(AbstractConfigEntry entry)
entry
- The Config entry to add.public final Iterator<String> iterator()
iterator
in interface Iterable<String>
iterator
in interface ConfigRO
public final String toStringValue()
toStringValue
in class AbstractConfigEntry
public final void toString(StringBuffer buf)
buf
- The string buffer to which this Config's String all all
children String representation is added.public String toString()
toString
in class AbstractConfigEntry
Object.toString()
public final void writeToFile(ObjectOutputStream oos) throws IOException
oos
- Write Config to this stream.
IOException
- If the file can not be accessed.protected static Config readFromFile(ObjectInputStream ois) throws IOException
ois
- Read Config from this stream.
IOException
- Problem opening the file or content is not a Config.public final void saveToXML(OutputStream os) throws IOException
saveToXML
in interface ConfigRO
os
- The stream to write into.
IOException
- If this Config could be stored to the stream.protected static Config loadFromXML(Config config, InputStream in) throws IOException
config
- Depending on the readRoot, we write into this Config and
return it.in
- The stream to read XML Config from.
IOException
- If the Config could not be load from stream.protected void load(InputStream is) throws IOException
is
- The XML inputstream storing the configuration to read
IOException
- If the stream could not be read.public void copyTo(ConfigWO dest)
copyTo
in interface ConfigRO
dest
- the destination this Config object is copied to.public TreeNode getChildAt(int childIndex)
getChildAt
in interface TreeNode
getChildAt
in class AbstractConfigEntry
childIndex
- The index to retrieve the TreeNode for.
public int getChildCount()
getChildCount
in interface TreeNode
getChildCount
in class AbstractConfigEntry
TreeNode.getChildCount()
public int getIndex(TreeNode node)
getIndex
in interface TreeNode
getIndex
in class AbstractConfigEntry
node
- The TreeNode to get the index for.
TreeNode.getIndex(javax.swing.tree.TreeNode)
public final boolean isLeaf()
isLeaf
in interface TreeNode
isLeaf
in class AbstractConfigEntry
TreeNode.isLeaf()
public final Enumeration<TreeNode> children()
children
in interface TreeNode
children
in class AbstractConfigEntry
TreeNode.children()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |