public abstract class ConfigBase extends AbstractConfigEntry implements ConfigBaseRO, ConfigBaseWO
ConfigBase
objects to this ConfigBase 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, and ConfigBase. 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.
| Constructor and Description |
|---|
ConfigBase(String key)
Creates a new, empty config object with the given key.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBoolean(String key,
boolean value)
Adds this boolean value to the ConfigBase by the given key.
|
void |
addBooleanArray(String key,
boolean... values)
Adds this boolean values to the ConfigBase by the given key.
|
void |
addByte(String key,
byte value)
Adds this byte value to the ConfigBase by the given key.
|
void |
addByteArray(String key,
byte... values)
Adds this byte array to the ConfigBase by the given key.
|
void |
addChar(String key,
char value)
Adds this char value to the ConfigBase by the given key.
|
void |
addCharArray(String key,
char... values)
Adds this char array to the ConfigBase by the given key.
|
protected void |
addConfigBase(ConfigBase config)
Appends the given ConfigBase to this ConfigBase which has to directly derived
from this class.
|
ConfigBase |
addConfigBase(String key)
Creates a new ConfigBase with the given key and returns it.
|
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 ConfigBase by the given key.
|
void |
addEntry(AbstractConfigEntry entry)
Adds the given ConfigBase 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 ConfigBase 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 ConfigBase by the given key.
|
void |
addLong(String key,
long value)
Adds this long value to the ConfigBase by the given key.
|
void |
addLongArray(String key,
long... values)
Adds this long array to the ConfigBase by the given key.
|
void |
addPassword(String key,
String encryptionKey,
String value)
Adds a password to the config object.
|
void |
addShort(String key,
short value)
Adds this short value to the ConfigBase by the given key.
|
void |
addShortArray(String key,
short... values)
Adds this short array to the ConfigBase by the given key.
|
void |
addString(String key,
String value)
Adds this String object to the ConfigBase by the given key.
|
void |
addStringArray(String key,
String... values)
Adds this array of String object to the ConfigBase by the given key.
|
void |
addTransientString(String key,
String value)
Adds a 'transient' string to this settings tree.
|
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(ConfigBaseWO dest)
Makes a deep copy of this ConfigBase and all sub ConfigBase objects.
|
protected AbstractConfigEntry |
get(String key) |
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() |
ConfigBase |
getConfigBase(String key)
Retrieves ConfigBase by key.
|
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.
|
AbstractConfigEntry |
getEntry(String key)
Returns ConfigBase 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.
|
abstract ConfigBase |
getInstance(String key)
Creates a new ConfigBase 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.
|
String |
getPassword(String key,
String encryptionKey)
Returns a decrypted password.
|
String |
getPassword(String key,
String encryptionKey,
String def)
Returns a decrypted password.
|
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.
|
String |
getTransientString(String key)
Returns a transient string if present or null if no longer available (setting restored from disc).
|
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.
|
void |
load(InputStream is)
Read config entries from an XML file into this object.
|
protected static ConfigBase |
loadFromXML(ConfigBase config,
InputStream in)
Reads ConfigBase from XML into a new ConfigBase object.
|
protected void |
put(AbstractConfigEntry e) |
protected static ConfigBase |
readFromFile(ObjectInputStream ois)
Creates new ConfigBase from the given file using the serialized object
stream.
|
void |
saveToXML(OutputStream os)
Writes this ConfigBase 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 ConfigBase into the given stream.
|
equals, getAllowsChildren, getKey, getParent, getType, hashCode, isIdentical, setKey, setParentclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetKeyforEach, spliteratorgetKeypublic ConfigBase(String key)
key - The key for this ConfigBase.protected void put(AbstractConfigEntry e)
protected AbstractConfigEntry get(String key)
public abstract ConfigBase getInstance(String key)
key - The new ConfigBase's key.public final ConfigBase addConfigBase(String key)
addConfigBase in interface ConfigBaseWOkey - An identifier.protected final void addConfigBase(ConfigBase config)
config - The ConfigBase to append.NullPointerException - If config is null.IllegalArgumentException - If config is not instance
of this class.public final ConfigBase getConfigBase(String key) throws InvalidSettingsException
getConfigBase in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public void addInt(String key, int value)
addInt in interface ConfigBaseWOkey - The key.value - The int value.public int getInt(String key) throws InvalidSettingsException
getInt in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public void addDouble(String key, double value)
addDouble in interface ConfigBaseWOkey - The key.value - The double value to add.public double getDouble(String key) throws InvalidSettingsException
getDouble in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public void addFloat(String key, float value)
addFloat in interface ConfigBaseWOkey - The key.value - The float value to add.public float getFloat(String key) throws InvalidSettingsException
getFloat in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public void addChar(String key, char value)
addChar in interface ConfigBaseWOkey - The key.value - The char to add.public char getChar(String key) throws InvalidSettingsException
getChar in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public void addShort(String key, short value)
addShort in interface ConfigBaseWOkey - The key.value - The short to add.public short getShort(String key) throws InvalidSettingsException
getShort in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public void addLong(String key, long value)
addLong in interface ConfigBaseWOkey - The key.value - The long to add.public long getLong(String key) throws InvalidSettingsException
getLong in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public void addByte(String key, byte value)
addByte in interface ConfigBaseWOkey - The key.value - The byte to add.public byte getByte(String key) throws InvalidSettingsException
getByte in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public void addString(String key, String value)
addString in interface ConfigBaseWOkey - The key.value - The boolean to add.public String getString(String key) throws InvalidSettingsException
getString in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public Set<String> keySet()
keySet in interface ConfigBaseROpublic boolean hasIdenticalValue(AbstractConfigEntry otherConfig)
AbstractConfigEntryhasIdenticalValue in class AbstractConfigEntryotherConfig - The other ConfigBase to check.public boolean containsKey(String key)
containsKey in interface ConfigBaseROkey - The key.null or not available.public boolean getBoolean(String key) throws InvalidSettingsException
getBoolean in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public void addBoolean(String key, boolean value)
addBoolean in interface ConfigBaseWOkey - The key.value - The boolean to add.public int getInt(String key, int def)
getInt in interface ConfigBaseROkey - The key.def - Returned if no value available for the given key.public int[] getIntArray(String key) throws InvalidSettingsException
getIntArray in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public int[] getIntArray(String key, int... def)
getIntArray in interface ConfigBaseROkey - The key.def - The default array returned if the key is not available.public void addIntArray(String key, int... values)
addIntArray in interface ConfigBaseWOkey - The key.values - The int array to add.public double getDouble(String key, double def)
getDouble in interface ConfigBaseROkey - The key.def - Returned if no value available for the given key.public double[] getDoubleArray(String key) throws InvalidSettingsException
getDoubleArray in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public double[] getDoubleArray(String key, double... def)
getDoubleArray in interface ConfigBaseROkey - The key.def - The default array returned if the key is not available.public float getFloat(String key, float def)
getFloat in interface ConfigBaseROkey - The key.def - Returned if no value available for the given key.public float[] getFloatArray(String key) throws InvalidSettingsException
getFloatArray in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public float[] getFloatArray(String key, float... def)
getFloatArray in interface ConfigBaseROkey - The key.def - The default array returned if the key is not available.public void addDoubleArray(String key, double... values)
addDoubleArray in interface ConfigBaseWOkey - The key.values - The double array to add.public void addFloatArray(String key, float... values)
addFloatArray in interface ConfigBaseWOkey - The key.values - The float array to add.public char getChar(String key, char def)
getChar in interface ConfigBaseROkey - The key.def - Returned if no value available for the given key.public char[] getCharArray(String key) throws InvalidSettingsException
getCharArray in interface ConfigBaseROkey - The key.InvalidSettingsException - If the the key is not available.public byte[] getByteArray(String key, byte... def)
getByteArray in interface ConfigBaseROkey - The key.def - Returned if no value available for the given key.public byte[] getByteArray(String key) throws InvalidSettingsException
getByteArray in interface ConfigBaseROkey - The key.InvalidSettingsException - If the the key is not available.public void addByteArray(String key, byte... values)
addByteArray in interface ConfigBaseWOkey - The key.values - The byte array to add.public byte getByte(String key, byte def)
getByte in interface ConfigBaseROkey - The key.def - Returned if no value available for the given key.public short[] getShortArray(String key) throws InvalidSettingsException
getShortArray in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public short[] getShortArray(String key, short... def)
getShortArray in interface ConfigBaseROkey - The key.def - The default array returned if the key is not available.public long[] getLongArray(String key) throws InvalidSettingsException
getLongArray in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public long[] getLongArray(String key, long... def)
getLongArray in interface ConfigBaseROkey - The key.def - The default array returned if the key is not available.public void addShortArray(String key, short... values)
addShortArray in interface ConfigBaseWOkey - The key.values - The short to add.public short getShort(String key, short def)
getShort in interface ConfigBaseROkey - The key.def - The default values returned if the key is not available.public void addLongArray(String key, long... values)
addLongArray in interface ConfigBaseWOkey - The key.values - The long arry to add.public long getLong(String key, long def)
getLong in interface ConfigBaseROkey - The key.def - The default values returned if the key is not available.public char[] getCharArray(String key, char... def)
getCharArray in interface ConfigBaseROkey - The key.def - The default array returned if the key is not available.public void addCharArray(String key, char... values)
addCharArray in interface ConfigBaseWOkey - The key.values - The char array to add.public boolean getBoolean(String key, boolean def)
getBoolean in interface ConfigBaseROkey - The key.def - Returned if no value available for the given key.public boolean[] getBooleanArray(String key) throws InvalidSettingsException
getBooleanArray in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public boolean[] getBooleanArray(String key, boolean... def)
getBooleanArray in interface ConfigBaseROkey - The key.def - Returned if no value available for the given key.public void addBooleanArray(String key, boolean... values)
addBooleanArray in interface ConfigBaseWOkey - The key.values - The boolean array to add.public String getString(String key, String def)
getString in interface ConfigBaseROkey - The key.def - The default String returned if the key is not available.public String[] getStringArray(String key) throws InvalidSettingsException
getStringArray in interface ConfigBaseROkey - The key.InvalidSettingsException - If the key is not available.public String[] getStringArray(String key, String... def)
getStringArray in interface ConfigBaseROkey - The key.def - The default array returned if the key is not available.public void addStringArray(String key, String... values)
addStringArray in interface ConfigBaseWOkey - The key.values - The String array to add.public AbstractConfigEntry getEntry(String key)
key - The key.public void addEntry(AbstractConfigEntry entry)
entry - The ConfigBase entry to add.public final Iterator<String> iterator()
iterator in interface Iterable<String>iterator in interface ConfigBaseROpublic final String toStringValue()
toStringValue in class AbstractConfigEntrypublic 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 AbstractConfigEntryObject.toString()public final void writeToFile(ObjectOutputStream oos) throws IOException
oos - Write ConfigBase to this stream.IOException - If the file cannot be accessed.protected static ConfigBase readFromFile(ObjectInputStream ois) throws IOException
ois - Read ConfigBase 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 ConfigBaseROos - The stream to write into.IOException - If this ConfigBase could be stored to the stream.protected static ConfigBase loadFromXML(ConfigBase config, InputStream in) throws IOException
config - Depending on the readRoot, we write into this ConfigBase and
return it.in - The stream to read XML ConfigBase from.IOException - If the ConfigBase could not be load from stream.public void load(InputStream is) throws IOException
is - The XML inputstream storing the configuration to readIOException - If the stream could not be read.public void copyTo(ConfigBaseWO dest)
copyTo in interface ConfigBaseROdest - the destination this ConfigBase object is copied to.public TreeNode getChildAt(int childIndex)
getChildAt in interface TreeNodegetChildAt in class AbstractConfigEntrychildIndex - The index to retrieve the TreeNode for.public int getChildCount()
getChildCount in interface TreeNodegetChildCount in class AbstractConfigEntryTreeNode.getChildCount()public int getIndex(TreeNode node)
getIndex in interface TreeNodegetIndex in class AbstractConfigEntrynode - The TreeNode to get the index for.TreeNode.getIndex(javax.swing.tree.TreeNode)public final boolean isLeaf()
isLeaf in interface TreeNodeisLeaf in class AbstractConfigEntryTreeNode.isLeaf()public final Enumeration<TreeNode> children()
children in interface TreeNodechildren in class AbstractConfigEntryTreeNode.children()public void addPassword(String key, String encryptionKey, String value)
ConfigBaseRO with the same encryption key in order to the get the
decrypted password.addPassword in interface ConfigBaseWOkey - the key for storing the password, must not be nullencryptionKey - key used for encrypting the passwordvalue - the password, may be nullpublic String getPassword(String key, String encryptionKey) throws InvalidSettingsException
getPassword in interface ConfigBaseROkey - the key, must not be nullencryptionKey - key used for encrypting the passwordnullInvalidSettingsException - if no password for the given key existspublic String getPassword(String key, String encryptionKey, String def)
getPassword in interface ConfigBaseROkey - the key, must not be nullencryptionKey - key used for encrypting the passworddef - the (decrypted) default valuenullpublic void addTransientString(String key, String value)
addTransientString in interface ConfigBaseWOkey - the key for lookupvalue - that value (password)ConfigBaseRO.getTransientString(String)public String getTransientString(String key)
getTransientString in interface ConfigBaseROkey - the key, must not be nullConfigBaseWO.addTransientString(String, String)
KNIME GmbH, Konstanz, Germany
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.