|
EAF 7.6 Util | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lutris.util.KeywordValueTable
com.lutris.util.Config
public class Config
Config is essentially a KeywordValueTable used for recursive
storage of data derived from a config file. The contents is
initialized but ConfigFile
.
ConfigFile
,
KeywordValueTable
,
Serialized FormConstructor Summary | |
---|---|
Config()
Default constructor for an empty Config. |
|
Config(org.enhydra.util.ConfigFileInterface configFile)
Constructor that associates this Config with a given ConfigFile. |
|
Config(KeywordValueTable kvt)
Constructor that takes a KeywordValueTable as initialization. |
|
Config(KeywordValueTable kvt,
org.enhydra.util.ConfigFileInterface configFile)
Constructor that takes a KeywordValueTable and a ConfigFile as initialization. |
Method Summary | |
---|---|
java.util.Hashtable |
allConfigParams(java.lang.String prefix)
Returns the hashtable containing names and values of all config parameters Names are in the form name-level-0_name-level-1_name-level-2... |
int |
containsCount(java.lang.String key)
Returns the number of data elements for a given key, or -1 if
the key is not found. |
boolean |
containsKey(java.lang.String key)
Returns true if the specified key is found,
false otherwise. |
boolean |
getBoolean(java.lang.String key)
Returns a single boolean value associated with a given key. |
boolean |
getBoolean(java.lang.String key,
boolean defaultValue)
Returns a single boolean value associated with a given key. |
boolean[] |
getBooleans(java.lang.String key)
Returns all boolean values associated with a given key. |
boolean[] |
getBooleans(java.lang.String key,
boolean[] defaultValue)
Returns all boolean values associated with a given key. |
Config |
getClonedConfig()
Returnes cloned Config object. |
Config |
getConfig(java.lang.String keyword)
Get the value of a section as a Config object. |
org.enhydra.util.ConfigFileInterface |
getConfigFile()
Gets the ConfigFile associated with this object. |
java.lang.Object |
getDataSource(java.lang.String key)
Returns a DataSource value associated with a given key. |
java.lang.Object |
getDataSource(java.lang.String key,
java.lang.Object defaultValue)
Returns a single DataSource value associated with a given key. |
double |
getDouble(java.lang.String key)
Returns a single double value associated with a given key. |
double |
getDouble(java.lang.String key,
double defaultValue)
Returns a single double value associated with a given key. |
double[] |
getDoubles(java.lang.String key)
Returns all double values associated with a given key. |
double[] |
getDoubles(java.lang.String key,
double[] defaultValue)
Returns all double values associated with a given key. |
int |
getInt(java.lang.String key)
Returns a single integer value associated with a given key. |
int |
getInt(java.lang.String key,
int defaultValue)
Returns a single integer value associated with a given key. |
int[] |
getInts(java.lang.String key)
Returns all integer values associated with a given key. |
int[] |
getInts(java.lang.String key,
int[] defaultValue)
Returns all integer values associated with a given key. |
long |
getLong(java.lang.String key)
Returns a single long integer value associated with a given key. |
long |
getLong(java.lang.String key,
long defaultValue)
Returns a single long integer value associated with a given key. |
long[] |
getLongs(java.lang.String key)
Returns all long integer values associated with a given key. |
long[] |
getLongs(java.lang.String key,
long[] defaultValue)
Returns all long integer values associated with a given key. |
KeywordValueTable |
getSection(java.lang.String keyword)
Gets the value of a section as a KeywordValueTable object. |
java.lang.String |
getString(java.lang.String key)
Returns a single String value associated with a given key. |
java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue)
Returns a single String value associated with a given key. |
java.lang.String[] |
getStrings(java.lang.String key)
Returns all String values associated with a given key. |
java.lang.String[] |
getStrings(java.lang.String key,
java.lang.String[] defaultValue)
Returns all String values associated with a given key. |
void |
importConfig(Config config)
Imorts and synchronizes to, all parameters (key-value pairs) according to given Config object parameters. |
boolean |
isArray(java.lang.String key)
Is the key is an array, or a single value. |
protected KeywordValueTable |
newSection()
Allocates a new section. |
void |
setConfigFile(org.enhydra.util.ConfigFileInterface configFile)
Sets the ConfigFile associated with this object. |
Methods inherited from class com.lutris.util.KeywordValueTable |
---|
get, get, keys, leafKeys, remove, set, setDefault, toHtml, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Config()
public Config(KeywordValueTable kvt)
kvt
- KeywordValueTable with which to initialize Configpublic Config(KeywordValueTable kvt, org.enhydra.util.ConfigFileInterface configFile)
kvt
- KeywordValueTable with which to initialize ConfigconfigFile
- ConfigFile to associate this Config object withpublic Config(org.enhydra.util.ConfigFileInterface configFile)
configFile
- ConfigFile to associate this object withMethod Detail |
---|
public Config getClonedConfig() throws com.lutris.util.KeywordValueException
KeywordValueException
public java.util.Hashtable allConfigParams(java.lang.String prefix) throws com.lutris.util.KeywordValueException
prefix
- - previous level name
com.lutris.util.KeywordValueException
public void importConfig(Config config) throws com.lutris.util.KeywordValueException
config
- Config object which has key-value pairs for importing.
KeywordValueException
protected KeywordValueTable newSection()
Config.
- Overrides:
newSection
in class KeywordValueTable
- Returns:
- A reference to a new section.
- See Also:
KeywordValueTable.newSection()
public org.enhydra.util.ConfigFileInterface getConfigFile()
ConfigFile
associated with this object.
ConfigFile
,
null
if there is no config file associated with this
object.public void setConfigFile(org.enhydra.util.ConfigFileInterface configFile)
ConfigFile
associated with this object.
For use by ConfigFile
only, anyone else please use
the appropriate constructor
configFile
- ConfigFile object associated with this objectpublic Config getConfig(java.lang.String keyword) throws com.lutris.util.KeywordValueException
Config
object.
keyword
- The keyword of the field. This can be a simple keyword
or a recursive, dot-seperated keyword path.
KeywordValueException
- If the keyword is not syntactically
legal or a non-leaf element of the keyword is not a section or the value
object is not a KeywordValueTable.KeywordValueTable.getSection(java.lang.String)
public KeywordValueTable getSection(java.lang.String keyword) throws com.lutris.util.KeywordValueException
KeywordValueTable
object.
This method overrides the KeywordValueTable.getSection in order to
insure that Config.getSection() always returns a Config object even
if a KeywordValueTable was inserted into the Config as a section.
getSection
in class KeywordValueTable
keyword
- The keyword of the field. This can be a simple keyword
or a recursive, dot-seperated keyword path.
KeywordValueException
- If the keyword is not syntactically legal
or a non-leaf element of the keyword is not a section or the value object is
not a KeywordValueTable.KeywordValueTable.getSection(java.lang.String)
public boolean containsKey(java.lang.String key)
true
if the specified key is found,
false
otherwise.
containsKey
in class KeywordValueTable
key
- The key whose existence is to be tested.
true
if the key was found, otherwise false
.public int containsCount(java.lang.String key) throws com.lutris.util.ConfigException
-1
if
the key is not found.
key
- The key to search for.
-1
if
the key is not found.
ConfigException
public boolean isArray(java.lang.String key) throws com.lutris.util.ConfigException
getStrings()
(or if you know the type
of the data, you can use, for example, getInts()
).
If this returns false, you shoud use getString()
(or if you know the type of the data, you can use, for example,
getInt()
).
key
- The key to search for.
ConfigException
- If the key is not found.public long getLong(java.lang.String key) throws com.lutris.util.ConfigException
ConfigException
exception is thrown.
key
- The key to use to search for the configuration entry.
ConfigException
- Thrown if the requested entry does not exist
or elements are not in the requested format.ConfigException
public long getLong(java.lang.String key, long defaultValue) throws com.lutris.util.ConfigException
ConfigException
error is thrown with reason
set to COUNT
. If the retrieved element cannot be
converted to a long integer then a ConfigException
error
is thrown with reason
set to FORMAT
.
key
- The key to use to search for the configuration entry.defaultValue
- The default value to use if the requested entry
does not exist.
ConfigException
- Thrown if there was not exactly one requested
element, or if the element is of the wrong data type or format.ConfigException
public long[] getLongs(java.lang.String key) throws com.lutris.util.ConfigException
ConfigException
error is thrown.
key
- The key to use to search for the configuration entry.
ConfigException
- Thrown if the requested entry does not exist
or elements are not in the requested format.ConfigException
public long[] getLongs(java.lang.String key, long[] defaultValue) throws com.lutris.util.ConfigException
ConfigException
error is thrown.
key
- The key to use to search for the configuration entry.defaultValue
- The default value to use if the requested entry
does not exist.
ConfigException
- Thrown if the requested entries are of the wrong
data type or format.ConfigException
public int getInt(java.lang.String key) throws com.lutris.util.ConfigException
ConfigException
exception is thrown.
key
- The key to use to search for the configuration entry.
ConfigException
- Thrown if the requested entry does not exist
or elements are not in the requested format.ConfigException
public int getInt(java.lang.String key, int defaultValue) throws com.lutris.util.ConfigException
ConfigException
exception is thrown.
key
- The key to use to search for the configuration entry.defaultValue
- The default value to use if the requested entry
does not exist.
ConfigException
- Thrown if there was not exactly one
requested element, or if the element is of the wrong data type or format.ConfigException
public int[] getInts(java.lang.String key) throws com.lutris.util.ConfigException
ConfigException
error is thrown.
key
- The key to use to search for the configuration entry.
ConfigException
- Thrown if the requested entry does not exist
or elements are not in the requested format.ConfigException
public int[] getInts(java.lang.String key, int[] defaultValue) throws com.lutris.util.ConfigException
ConfigException
error is thrown.
key
- The key to use to search for the configuration entry.defaultValue
- The default value to use if the requested entry
does not exist.
ConfigException
- Thrown if the requested entries are of
the wrong data type or format.ConfigException
public java.lang.String getString(java.lang.String key) throws com.lutris.util.ConfigException
ConfigException
exception is thrown.
getString
in class KeywordValueTable
key
- The key to use to search for the configuration entry.
ConfigException
- Thrown if the requested entry does not exist
or elements are not in the requested format.ConfigException
public java.lang.String getString(java.lang.String key, java.lang.String defaultValue) throws com.lutris.util.ConfigException
ConfigException
exception is thrown.
getString
in class KeywordValueTable
key
- The key to use to search for the configuration entry.defaultValue
- The default value to use if the requested entry
does not exist.
ConfigException
- Thrown if there was not exactly one
requested element, or if the element is of the wrong data type or format.ConfigException
public java.lang.String[] getStrings(java.lang.String key) throws com.lutris.util.ConfigException
ConfigException
error is thrown.
key
- The key to use to search for the configuration entry.
ConfigException
- Thrown if the requested entry does not exist
or elements are not in the requested format.ConfigException
public java.lang.String[] getStrings(java.lang.String key, java.lang.String[] defaultValue) throws com.lutris.util.ConfigException
ConfigException
error is thrown.
key
- The key to use to search for the configuration entry.defaultValue
- The default value to use if the requested entry
does not exist.
ConfigException
- Thrown if the requested entries are of
the wrong data type or format.ConfigException
public boolean getBoolean(java.lang.String key) throws com.lutris.util.ConfigException
ConfigException
exception is thrown.
key
- The key to use to search for the configuration entry.
ConfigException
- Thrown if the requested entry does not exist
or elements are not in the requested format.ConfigException
public boolean getBoolean(java.lang.String key, boolean defaultValue) throws com.lutris.util.ConfigException
ConfigException
exception is thrown.
key
- The key to use to search for the configuration entry.defaultValue
- The default value to use if the requested entry
does not exist.
ConfigException
- Thrown if there was not exactly one requested
element, or if the element is of the wrong data type or format.ConfigException
public boolean[] getBooleans(java.lang.String key) throws com.lutris.util.ConfigException
ConfigException
error is thrown.
key
- The key to use to search for the configuration entry.
ConfigException
- Thrown if the requested entry does not exist
or elements are not in the requested format.ConfigException
public boolean[] getBooleans(java.lang.String key, boolean[] defaultValue) throws com.lutris.util.ConfigException
ConfigException
error is thrown.
key
- The key to use to search for the configuration entry.defaultValue
- The default value to use if the requested entry does not
exist.
ConfigException
- Thrown if the requested entries are of
the wrong data type or format.ConfigException
public double getDouble(java.lang.String key) throws com.lutris.util.ConfigException
ConfigException
exception is thrown.
key
- The key to use to search for the configuration entry.
ConfigException
- Thrown if the requested entry does not exist
or elements are not in the requested format.ConfigException
public double getDouble(java.lang.String key, double defaultValue) throws com.lutris.util.ConfigException
ConfigException
exception is thrown.
key
- The key to use to search for the configuration entry.defaultValue
- The default value to use if the requested entry
does not exist.
ConfigException
- Thrown if there was not exactly one requested
element, or if the element is of the wrong data type or format.ConfigException
public double[] getDoubles(java.lang.String key) throws com.lutris.util.ConfigException
ConfigException
error is thrown.
key
- The key to use to search for the configuration entry.
ConfigException
- Thrown if the requested entry does not exist
or elements are not in the requested format.ConfigException
public double[] getDoubles(java.lang.String key, double[] defaultValue) throws com.lutris.util.ConfigException
ConfigException
error is thrown.
key
- The key to use to search for the configuration entry.defaultValue
- The default value to use if the requested entry
does not exist.
ConfigException
- Thrown if the requested entries are of
the wrong data type or format.ConfigException
public java.lang.Object getDataSource(java.lang.String key) throws com.lutris.util.ConfigException
key
- The key to use to search for the configuration entry.
ConfigException
- Thrown if the requested entry does not exist
or elements are not in the requested format.ConfigException
public java.lang.Object getDataSource(java.lang.String key, java.lang.Object defaultValue) throws com.lutris.util.ConfigException
ConfigException
exception is thrown.
key
- The key to use to search for the configuration entry.defaultValue
- The default value to use if the requested entry
does not exist.
ConfigException
- Thrown if there was not exactly one
requested element, or if the element is of the wrong data type or format.ConfigException
|
EAF 7.6 Util | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |