Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

source.org.apache.java.util
Class Configurations  view Configurations download Configurations.java

java.lang.Object
  extended bysource.org.apache.java.util.Configurations

public class Configurations
extends java.lang.Object

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.

Version:
$Revision: 1.4 $ $Date: 2003/01/20 23:59:32 $

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 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaults

private Configurations defaults
Default configurations repository.


repository

private ConfigurationsRepository repository
Configuration repository.

Constructor Detail

Configurations

public Configurations()
Creates an empty configuration repository with no default values.


Configurations

public Configurations(Configurations defaults)
Creates an empty configuration repository with the specified defaults.


Configurations

public Configurations(ConfigurationsRepository properties)
Creates a configuration repository encapsulating the given properties with no default values.


Configurations

public Configurations(ConfigurationsRepository properties,
                      Configurations defaults)
Merge the given properties object as configurations.

Method Detail

getBoolean

public boolean getBoolean(java.lang.String key)
Get a boolean associated with the given configuration key.


getBoolean

public java.lang.Boolean getBoolean(java.lang.String key,
                                    java.lang.Boolean defaultValue)
Get a boolean associated with the given configuration key.


getBoolean

public boolean getBoolean(java.lang.String key,
                          boolean defaultValue)
Get a boolean associated with the given configuration key.


getByte

public byte getByte(java.lang.String key)
Get a byte associated with the given configuration key.


getByte

public byte getByte(java.lang.String key,
                    byte defaultValue)
Get a byte associated with the given configuration key.


getByte

public java.lang.Byte getByte(java.lang.String key,
                              java.lang.Byte defaultValue)
Get a byte associated with the given configuration key.


getDouble

public double getDouble(java.lang.String key)
Get a double associated with the given configuration key.


getDouble

public double getDouble(java.lang.String key,
                        double defaultValue)
Get a double associated with the given configuration key.


getDouble

public java.lang.Double getDouble(java.lang.String key,
                                  java.lang.Double defaultValue)
Get a double associated with the given configuration key.


getFloat

public float getFloat(java.lang.String key)
Get a float associated with the given configuration key.


getFloat

public float getFloat(java.lang.String key,
                      float defaultValue)
Get a float associated with the given configuration key.


getFloat

public java.lang.Float getFloat(java.lang.String key,
                                java.lang.Float defaultValue)
Get a float associated with the given configuration key.


getInteger

public int getInteger(java.lang.String key)
Get a int associated with the given configuration key.


getInteger

public int getInteger(java.lang.String key,
                      int defaultValue)
Get a int associated with the given configuration key.


getInteger

public java.lang.Integer getInteger(java.lang.String key,
                                    java.lang.Integer defaultValue)
Get a int associated with the given configuration key.


getKeys

public java.util.Enumeration getKeys()
Get the list of the keys contained in the configuration repository.


getList

public java.util.Enumeration getList(java.lang.String key)
Get a list of strings associated with the given configuration key.


getLong

public long getLong(java.lang.String key)
Get a long associated with the given configuration key.


getLong

public long getLong(java.lang.String key,
                    long defaultValue)
Get a long associated with the given configuration key.


getLong

public java.lang.Long getLong(java.lang.String key,
                              java.lang.Long defaultValue)
Get a long associated with the given configuration key.


getProperties

public java.util.Properties getProperties(java.lang.String key)
Get a list of properties associated with the given configuration key.


getProperties

public java.util.Properties getProperties(java.lang.String key,
                                          java.util.Properties defaults)
Get a list of properties associated with the given configuration key.


getRepository

public java.util.Hashtable getRepository()
Get encapsulated configuration repository.


getShort

public short getShort(java.lang.String key)
Get a short associated with the given configuration key.


getShort

public java.lang.Short getShort(java.lang.String key,
                                java.lang.Short defaultValue)
Get a short associated with the given configuration key.


getShort

public short getShort(java.lang.String key,
                      short defaultValue)
Get a short associated with the given configuration key.


getString

public java.lang.String getString(java.lang.String key)
Get a string associated with the given configuration key.


getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.String defaultValue)
Get a string associated with the given configuration key.


getStringArray

public java.lang.String[] getStringArray(java.lang.String key)
Get an array of strings associated with the given configuration key.


getVector

public java.util.Vector getVector(java.lang.String key)
Get a Vector of strings associated with the given configuration key.


getVector

public java.util.Vector getVector(java.lang.String key,
                                  java.util.Vector defaultValue)
Get a Vector of strings associated with the given configuration key.