|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.java.util.Configurations
This class is used to encapsulate properties and addresses the need for a flexible, portable and fast configurations repository.
While properties are just considered as strings, configurations have methods to return different types such as int and long.
Performance is needed to avoid the use of properties only at startup to fill variables: configurations encapsulate properties in the sense that objects retrieved by parsing property strings are stored for faster reuse. This allows a program to use configurations instead of global variables in a central repository, that, if updated, will reflect instantly the changes throughout the whole application.
The behavior of this class is syntax indipendent because it's only an encapsulator. This allows greater flexibility throught the use of syntax abstraction and faster transition between different configuration syntax.
Field Summary | |
private Configurations |
defaults
Default configurations repository. |
private ConfigurationsRepository |
repository
Configuration repository. |
Constructor Summary | |
Configurations()
Creates an empty configuration repository with no default values. |
|
Configurations(Configurations defaults)
Creates an empty configuration repository with the specified defaults. |
|
Configurations(ConfigurationsRepository properties)
Creates a configuration repository encapsulating the given properties with no default values. |
|
Configurations(ConfigurationsRepository properties,
Configurations defaults)
Merge the given properties object as configurations. |
Method Summary | |
boolean |
getBoolean(java.lang.String key)
Get a boolean associated with the given configuration key. |
boolean |
getBoolean(java.lang.String key,
boolean defaultValue)
Get a boolean associated with the given configuration key. |
java.lang.Boolean |
getBoolean(java.lang.String key,
java.lang.Boolean defaultValue)
Get a boolean associated with the given configuration key. |
byte |
getByte(java.lang.String key)
Get a byte associated with the given configuration key. |
byte |
getByte(java.lang.String key,
byte defaultValue)
Get a byte associated with the given configuration key. |
java.lang.Byte |
getByte(java.lang.String key,
java.lang.Byte defaultValue)
Get a byte associated with the given configuration key. |
double |
getDouble(java.lang.String key)
Get a double associated with the given configuration key. |
double |
getDouble(java.lang.String key,
double defaultValue)
Get a double associated with the given configuration key. |
java.lang.Double |
getDouble(java.lang.String key,
java.lang.Double defaultValue)
Get a double associated with the given configuration key. |
float |
getFloat(java.lang.String key)
Get a float associated with the given configuration key. |
float |
getFloat(java.lang.String key,
float defaultValue)
Get a float associated with the given configuration key. |
java.lang.Float |
getFloat(java.lang.String key,
java.lang.Float defaultValue)
Get a float associated with the given configuration key. |
int |
getInteger(java.lang.String key)
Get a int associated with the given configuration key. |
int |
getInteger(java.lang.String key,
int defaultValue)
Get a int associated with the given configuration key. |
java.lang.Integer |
getInteger(java.lang.String key,
java.lang.Integer defaultValue)
Get a int associated with the given configuration key. |
java.util.Enumeration |
getKeys()
Get the list of the keys contained in the configuration repository. |
java.util.Enumeration |
getKeys(java.lang.String prefix)
Get the list of the keys contained in the configuration repository that match the specified prefix. |
java.util.Enumeration |
getList(java.lang.String key)
Get a list of strings associated with the given configuration key. |
long |
getLong(java.lang.String key)
Get a long associated with the given configuration key. |
long |
getLong(java.lang.String key,
long defaultValue)
Get a long associated with the given configuration key. |
java.lang.Long |
getLong(java.lang.String key,
java.lang.Long defaultValue)
Get a long associated with the given configuration key. |
java.util.Properties |
getProperties(java.lang.String key)
Get a list of properties associated with the given configuration key. |
java.util.Properties |
getProperties(java.lang.String key,
java.util.Properties defaults)
Get a list of properties associated with the given configuration key. |
java.util.Hashtable |
getRepository()
Get encapsulated configuration repository. |
short |
getShort(java.lang.String key)
Get a short associated with the given configuration key. |
short |
getShort(java.lang.String key,
short defaultValue)
Get a short associated with the given configuration key. |
java.lang.Short |
getShort(java.lang.String key,
java.lang.Short defaultValue)
Get a short associated with the given configuration key. |
java.lang.String |
getString(java.lang.String key)
Get a string associated with the given configuration key. |
java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue)
Get a string associated with the given configuration key. |
java.lang.String[] |
getStringArray(java.lang.String key)
Get an array of strings associated with the given configuration key. |
java.util.Vector |
getVector(java.lang.String key)
Get a Vector of strings associated with the given configuration key. |
java.util.Vector |
getVector(java.lang.String key,
java.util.Vector defaultValue)
Get a Vector of strings associated with the given configuration key. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private Configurations defaults
private ConfigurationsRepository repository
Constructor Detail |
public Configurations()
public Configurations(ConfigurationsRepository properties)
properties
- the properties to encapsulate.public Configurations(Configurations defaults)
defaults
- the default values repository.public Configurations(ConfigurationsRepository properties, Configurations defaults)
properties
- the properties file to mergeMethod Detail |
public java.util.Hashtable getRepository()
public java.util.Enumeration getKeys()
public java.util.Enumeration getKeys(java.lang.String prefix)
prefix
- the prefix to test againstpublic java.lang.String getString(java.lang.String key)
key
- the configuration key.public java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
key
- the configuration key.defaultValue
- the default value.public java.util.Properties getProperties(java.lang.String key)
key
- the configuration key.public java.util.Properties getProperties(java.lang.String key, java.util.Properties defaults)
key
- the configuration key.public java.lang.String[] getStringArray(java.lang.String key)
key
- the configuration key.public java.util.Enumeration getList(java.lang.String key)
key
- the configuration key.public java.util.Vector getVector(java.lang.String key)
key
- the configuration key.public java.util.Vector getVector(java.lang.String key, java.util.Vector defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public boolean getBoolean(java.lang.String key)
key
- the configuration key.public boolean getBoolean(java.lang.String key, boolean defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public java.lang.Boolean getBoolean(java.lang.String key, java.lang.Boolean defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public byte getByte(java.lang.String key)
key
- the configuration key.public byte getByte(java.lang.String key, byte defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public java.lang.Byte getByte(java.lang.String key, java.lang.Byte defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public short getShort(java.lang.String key)
key
- the configuration key.public short getShort(java.lang.String key, short defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public java.lang.Short getShort(java.lang.String key, java.lang.Short defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public int getInteger(java.lang.String key)
key
- the configuration key.public int getInteger(java.lang.String key, int defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public java.lang.Integer getInteger(java.lang.String key, java.lang.Integer defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public long getLong(java.lang.String key)
key
- the configuration key.public long getLong(java.lang.String key, long defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public java.lang.Long getLong(java.lang.String key, java.lang.Long defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public float getFloat(java.lang.String key)
key
- the configuration key.public float getFloat(java.lang.String key, float defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public java.lang.Float getFloat(java.lang.String key, java.lang.Float defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public double getDouble(java.lang.String key)
key
- the configuration key.public double getDouble(java.lang.String key, double defaultValue)
key
- the configuration key.defaultValue
- the defaul value.public java.lang.Double getDouble(java.lang.String key, java.lang.Double defaultValue)
key
- the configuration key.defaultValue
- the defaul value.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |