public interface IConfigStore
In the following example:
param1=value1
configStore1.param11=value11
configStore1.param12=value12
configStore1.subStore1.param111=value111
configStore1.subStore1.param112=value112
configStore2.param21=value21
The top config store has parameters param1 and sub-stores configStore1 and configStore2.
// the top config store is passed to the following method.
public void init(IConfigStore config) throws EBaseException {
IConfigStore store = config;
String valx = config.getString("param1");
// valx is "value1" <p>
IConfigStore substore1 = config.getSubStore("configStore1");
String valy = substore1.getString("param11");
// valy is "value11" <p>
IConfigStore substore2 = config.getSubStore("configStore2");
String valz = substore2.getString("param21");
// valz is "value21" <p>
}
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear the config store.
|
void |
commit(boolean createBackup)
Store config into storage (file or LDAP).
|
java.lang.String |
get(java.lang.String name)
Gets a property.
|
java.math.BigInteger |
getBigInteger(java.lang.String name)
Retrieves the given property as a big integer.
|
java.math.BigInteger |
getBigInteger(java.lang.String name,
java.math.BigInteger defval)
Retrieves the given property as a big integer.
|
boolean |
getBoolean(java.lang.String name)
Retrieves the given property as a boolean.
|
boolean |
getBoolean(java.lang.String name,
boolean defval)
Retrieves the given property as a boolean.
|
byte[] |
getByteArray(java.lang.String name)
Retrieves the value of a property as a byte array.
|
byte[] |
getByteArray(java.lang.String name,
byte[] defval)
Retrieves the value of a property as a byte array, using the
given default value if property is not present.
|
int |
getInteger(java.lang.String name)
Retrieves the given property as an integer.
|
int |
getInteger(java.lang.String name,
int defval)
Retrieves the given property as an integer.
|
java.lang.String |
getName()
Gets the name of this Configuration Store.
|
java.util.Map<java.lang.String,java.lang.String> |
getProperties()
Get properties as a map.
|
java.util.Enumeration<java.lang.String> |
getPropertyNames()
Retrives and enumeration of all properties in this config-store.
|
java.lang.String |
getString(java.lang.String name)
Retrieves the value of the given property as a string.
|
java.lang.String |
getString(java.lang.String name,
java.lang.String defval)
Retrieves the value of a given property as a string or the
given default value if the property is not present.
|
IConfigStore |
getSubStore(java.lang.String name)
Retrieves the given sub-store.
|
<T extends IConfigStore> |
getSubStore(java.lang.String name,
java.lang.Class<T> clazz) |
java.util.Enumeration<java.lang.String> |
getSubStoreNames()
Returns an enumeration of the names of the substores of
this config-store.
|
java.util.Enumeration<java.lang.String> |
keys()
Returns an enumeration of the config store's keys.
|
void |
load()
Load config from storage storage (file or LDAP).
|
void |
load(java.io.InputStream in)
Reads a config store from an input stream.
|
IConfigStore |
makeSubStore(java.lang.String name)
Creates a nested sub-store with the specified name.
|
java.lang.String |
put(java.lang.String name,
java.lang.String value)
Retrieves a property.
|
void |
putBigInteger(java.lang.String name,
java.math.BigInteger value)
Sets a property and its value as an integer.
|
void |
putBoolean(java.lang.String name,
boolean value)
Stores the given property and its value as a boolean.
|
void |
putByteArray(java.lang.String name,
byte[] value)
Stores the given property and value as a byte array.
|
void |
putInteger(java.lang.String name,
int value)
Sets a property and its value as an integer.
|
void |
putString(java.lang.String name,
java.lang.String value)
Stores a property and its value as a string.
|
void |
remove(java.lang.String name) |
void |
removeSubStore(java.lang.String name)
Removes sub-store with the given name.
|
int |
size()
Return the number of items in this substore
|
void |
store(java.io.OutputStream out)
Stores this config store to the specified output stream.
|
java.lang.String get(java.lang.String name)
name - The property namejava.lang.String put(java.lang.String name,
java.lang.String value)
name - The property namevalue - The property valuejava.util.Enumeration<java.lang.String> keys()
Hashtable.elements(),
Enumerationvoid clear()
void load() throws java.lang.Exception
java.lang.Exception - If an error occurs while loading.void commit(boolean createBackup)
throws EBaseException
createBackup - true if a backup file should be createdEBaseException - failed to commitvoid load(java.io.InputStream in) throws java.io.IOException
in - input stream where the properties are locatedjava.io.IOException - If an IO error occurs while loading from input.void store(java.io.OutputStream out)
throws java.lang.Exception
out - output stream where the properties should be serializedjava.lang.Exceptionjava.lang.String getName()
java.lang.String getString(java.lang.String name)
throws EPropertyNotFound,
EBaseException
name - The name of the property to getEPropertyNotFound - If the property is not presentEBaseException - If an internal error occurredjava.lang.String getString(java.lang.String name,
java.lang.String defval)
throws EBaseException
name - The property to retrivedefval - The default value to return if the property is not presentEBaseException - If an internal error occurredvoid putString(java.lang.String name,
java.lang.String value)
name - The name of the propertyvalue - The value as a stringbyte[] getByteArray(java.lang.String name)
throws EPropertyNotFound,
EBaseException
name - The property nameEPropertyNotFound - If the property is not presentEBaseException - If an internal error occurredbyte[] getByteArray(java.lang.String name,
byte[] defval)
throws EBaseException
name - The name of the propertydefval - The default value if the property is not present.EBaseException - If an internal error occurredvoid putByteArray(java.lang.String name,
byte[] value)
name - The property namevalue - The value as a byte array to storeboolean getBoolean(java.lang.String name)
throws EPropertyNotFound,
EBaseException
name - The name of the property as a string.EPropertyNotFound - If the property is not presentEBaseException - If an internal error occurredboolean getBoolean(java.lang.String name,
boolean defval)
throws EBaseException
name - The name of the propertydefval - The default value to turn as a boolean if
property is not presentEBaseException - If an internal error occurredvoid putBoolean(java.lang.String name,
boolean value)
name - The property namevalue - The value as a booleanint getInteger(java.lang.String name)
throws EPropertyNotFound,
EBaseException
name - The property nameEPropertyNotFound - If property is not foundEBaseException - If an internal error occurredint getInteger(java.lang.String name,
int defval)
throws EBaseException
name - The property nameEBaseException - If the value cannot be converted to a
integervoid putInteger(java.lang.String name,
int value)
name - parameter namevalue - integer valuejava.math.BigInteger getBigInteger(java.lang.String name)
throws EPropertyNotFound,
EBaseException
name - The property nameEPropertyNotFound - If property is not foundEBaseException - If an internal error occurredjava.math.BigInteger getBigInteger(java.lang.String name,
java.math.BigInteger defval)
throws EBaseException
name - The property nameEBaseException - If the value cannot be converted to a
integervoid putBigInteger(java.lang.String name,
java.math.BigInteger value)
name - parameter namevalue - big integer valueIConfigStore makeSubStore(java.lang.String name)
name - The name of the sub-storeIConfigStore getSubStore(java.lang.String name)
name - The name of the sub-store<T extends IConfigStore> T getSubStore(java.lang.String name, java.lang.Class<T> clazz)
void removeSubStore(java.lang.String name)
name - The name of the sub-store to removevoid remove(java.lang.String name)
java.util.Enumeration<java.lang.String> getPropertyNames()
java.util.Enumeration<java.lang.String> getSubStoreNames()
int size()
java.util.Map<java.lang.String,java.lang.String> getProperties()
throws EBaseException
EBaseException