| java.lang.Object net.myvietnam.mvncore.configuration.AbstractConfiguration
All known Subclasses: net.myvietnam.mvncore.configuration.HierarchicalConfiguration, net.myvietnam.mvncore.configuration.BaseConfiguration,
AbstractConfiguration | abstract public class AbstractConfiguration implements Configuration(Code) | | Abstract configuration class. Provide basic functionality but does not
store any data. If you want to write your own Configuration class
then you should implement only abstract methods from this class.
author: Konstantin Shaposhnikov author: Oliver Heger version: $Id: AbstractConfiguration.java,v 1.6 2007/10/16 06:54:46 lexuanttkhtn Exp $ |
Inner Class :static class Container | |
Method Summary | |
public void | addProperty(String key, Object token) Add a property to the configuration. | abstract protected void | addPropertyDirect(String key, Object obj) Adds a key/value pair to the Configuration. | abstract public void | clearProperty(String key) Clear a property in the configuration. | abstract public boolean | containsKey(String key) | public boolean | getBoolean(String key) Get a boolean associated with the given configuration key.
Parameters: key - The configuration key. | public boolean | getBoolean(String key, boolean defaultValue) Get a boolean associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public Boolean | getBoolean(String key, Boolean defaultValue) Get a boolean associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public byte | getByte(String key) Get a byte associated with the given configuration key.
Parameters: key - The configuration key. | public byte | getByte(String key, byte defaultValue) Get a byte associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public Byte | getByte(String key, Byte defaultValue) Get a byte associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public double | getDouble(String key) Get a double associated with the given configuration key.
Parameters: key - The configuration key. | public double | getDouble(String key, double defaultValue) Get a double associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public Double | getDouble(String key, Double defaultValue) Get a double associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public float | getFloat(String key) Get a float associated with the given configuration key.
Parameters: key - The configuration key. | public float | getFloat(String key, float defaultValue) Get a float associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public Float | getFloat(String key, Float defaultValue) Get a float associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public int | getInt(String key) Get a int associated with the given configuration key.
Parameters: key - The configuration key. | public int | getInt(String key, int defaultValue) Get a int associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public Integer | getInteger(String key, Integer defaultValue) Get a int associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | abstract public Iterator | getKeys() Get the list of the keys contained in the configuration
repository. | public Iterator | getKeys(String prefix) Get the list of the keys contained in the configuration
repository that match the specified prefix.
Parameters: prefix - The prefix to test against. | public long | getLong(String key) Get a long associated with the given configuration key.
Parameters: key - The configuration key. | public long | getLong(String key, long defaultValue) Get a long associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public Long | getLong(String key, Long defaultValue) Get a long associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public Properties | getProperties(String key) Get a list of properties associated with the given
configuration key.
Parameters: key - The configuration key. | public Properties | getProperties(String key, Properties defaults) Get a list of properties associated with the given
configuration key.
Parameters: key - The configuration key. Parameters: defaults - Any default values for the returnedProperties object. | public Object | getProperty(String key) Gets a property from the configuration.
Parameters: key - property to retrieve value as object. | abstract protected Object | getPropertyDirect(String key) Read property. | public short | getShort(String key) Get a short associated with the given configuration key.
Parameters: key - The configuration key. | public short | getShort(String key, short defaultValue) Get a short associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public Short | getShort(String key, Short defaultValue) Get a short associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public String | getString(String key) Get a string associated with the given configuration key.
Parameters: key - The configuration key. | public String | getString(String key, String defaultValue) Get a string associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | public String[] | getStringArray(String key) Get an array of strings associated with the given configuration
key.
Parameters: key - The configuration key. | public Vector | getVector(String key) Get a Vector of strings associated with the given configuration key.
Parameters: key - The configuration key. | public Vector | getVector(String key, Vector defaultValue) Get a Vector of strings associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. | protected String | interpolate(String base) | protected String | interpolateHelper(String base, List priorVariables) Recursive handler for multple levels of interpolation.
When called the first time, priorVariables should be null.
Parameters: base - string with the ${key} variables Parameters: priorVariables - serves two purposes: to allow checking forloops, and creating a meaningful exception message should a loopoccur. | abstract public boolean | isEmpty() | protected List | processString(String token) Returns a Vector of Strings built from the supplied
String. | public void | setProperty(String key, Object value) Set a property, this will replace any previously
set values. | public Configuration | subset(String prefix) Create an BaseConfiguration object that is a subset
of this one. | final protected Boolean | testBoolean(String value) Test whether the string represent by value maps to a boolean
value or not. |
END_TOKEN | final protected static String END_TOKEN(Code) | | end token
|
START_TOKEN | final protected static String START_TOKEN(Code) | | start token
|
AbstractConfiguration | public AbstractConfiguration()(Code) | | Empty constructor.
|
AbstractConfiguration | public AbstractConfiguration(Configuration defaults)(Code) | | Creates an empty AbstractConfiguration object with
a Super-Object which is queries for every key.
Parameters: defaults - Configuration defaults to use if key not in file |
addProperty | public void addProperty(String key, Object token)(Code) | | Add a property to the configuration. If it already exists then the value
stated here will be added to the configuration entry. For example, if
resource.loader = file
is already present in the configuration and you
addProperty("resource.loader", "classpath")
Then you will end up with a Vector like the following:
["file", "classpath"]
Parameters: key - The Key to add the property to. Parameters: token - The Value to add. |
addPropertyDirect | abstract protected void addPropertyDirect(String key, Object obj)(Code) | | Adds a key/value pair to the Configuration. Override this method to
provide write acces to underlying Configuration store.
Parameters: key - key to use for mapping Parameters: obj - object to store |
clearProperty | abstract public void clearProperty(String key)(Code) | | Clear a property in the configuration.
Parameters: key - the key to remove along with corresponding value. |
containsKey | abstract public boolean containsKey(String key)(Code) | | check if the configuration contains the key
Parameters: key - the configuration key true if Configuration contain given key,false otherwise. |
getBoolean | public boolean getBoolean(String key)(Code) | | Get a boolean associated with the given configuration key.
Parameters: key - The configuration key. The associated boolean. throws: NoSuchElementException - is thrown if the key doesn'tmap to an existing object. throws: ClassCastException - is thrown if the key maps to anobject that is not a Boolean. |
getBoolean | public boolean getBoolean(String key, boolean defaultValue)(Code) | | Get a boolean associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated boolean. throws: ClassCastException - is thrown if the key maps to anobject that is not a Boolean. |
getBoolean | public Boolean getBoolean(String key, Boolean defaultValue)(Code) | | Get a boolean associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated boolean if key is found and has validformat, default value otherwise. throws: ClassCastException - is thrown if the key maps to anobject that is not a Boolean. |
getByte | public byte getByte(String key)(Code) | | Get a byte associated with the given configuration key.
Parameters: key - The configuration key. The associated byte. throws: NoSuchElementException - is thrown if the key doesn'tmap to an existing object. throws: ClassCastException - is thrown if the key maps to anobject that is not a Byte. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getByte | public byte getByte(String key, byte defaultValue)(Code) | | Get a byte associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated byte. throws: ClassCastException - is thrown if the key maps to anobject that is not a Byte. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getByte | public Byte getByte(String key, Byte defaultValue)(Code) | | Get a byte associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated byte if key is found and has valid format, defaultvalue otherwise. throws: ClassCastException - is thrown if the key maps to an object thatis not a Byte. throws: NumberFormatException - is thrown if the value mapped by the keyhas not a valid number format. |
getDouble | public double getDouble(String key)(Code) | | Get a double associated with the given configuration key.
Parameters: key - The configuration key. The associated double. throws: NoSuchElementException - is thrown if the key doesn'tmap to an existing object. throws: ClassCastException - is thrown if the key maps to anobject that is not a Double. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getDouble | public double getDouble(String key, double defaultValue)(Code) | | Get a double associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated double. throws: ClassCastException - is thrown if the key maps to anobject that is not a Double. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getDouble | public Double getDouble(String key, Double defaultValue)(Code) | | Get a double associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated double if key is found and has validformat, default value otherwise. throws: ClassCastException - is thrown if the key maps to anobject that is not a Double. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getFloat | public float getFloat(String key)(Code) | | Get a float associated with the given configuration key.
Parameters: key - The configuration key. The associated float. throws: NoSuchElementException - is thrown if the key doesn'tmap to an existing object. throws: ClassCastException - is thrown if the key maps to anobject that is not a Float. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getFloat | public float getFloat(String key, float defaultValue)(Code) | | Get a float associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated float. throws: ClassCastException - is thrown if the key maps to anobject that is not a Float. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getFloat | public Float getFloat(String key, Float defaultValue)(Code) | | Get a float associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated float if key is found and has validformat, default value otherwise. throws: ClassCastException - is thrown if the key maps to anobject that is not a Float. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getInt | public int getInt(String key)(Code) | | Get a int associated with the given configuration key.
Parameters: key - The configuration key. The associated int. throws: NoSuchElementException - is thrown if the key doesn'tmap to an existing object. throws: ClassCastException - is thrown if the key maps to anobject that is not a Integer. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getInt | public int getInt(String key, int defaultValue)(Code) | | Get a int associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated int. throws: ClassCastException - is thrown if the key maps to anobject that is not a Integer. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getInteger | public Integer getInteger(String key, Integer defaultValue)(Code) | | Get a int associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated int if key is found and has valid format, defaultvalue otherwise. throws: ClassCastException - is thrown if the key maps to an object thatis not a Integer. throws: NumberFormatException - is thrown if the value mapped by the keyhas not a valid number format. |
getKeys | abstract public Iterator getKeys()(Code) | | Get the list of the keys contained in the configuration
repository.
An Iterator. |
getKeys | public Iterator getKeys(String prefix)(Code) | | Get the list of the keys contained in the configuration
repository that match the specified prefix.
Parameters: prefix - The prefix to test against. An Iterator of keys that match the prefix. |
getLong | public long getLong(String key)(Code) | | Get a long associated with the given configuration key.
Parameters: key - The configuration key. The associated long. throws: NoSuchElementException - is thrown if the key doesn'tmap to an existing object. throws: ClassCastException - is thrown if the key maps to anobject that is not a Long. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getLong | public long getLong(String key, long defaultValue)(Code) | | Get a long associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated long. throws: ClassCastException - is thrown if the key maps to anobject that is not a Long. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getLong | public Long getLong(String key, Long defaultValue)(Code) | | Get a long associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated long if key is found and has validformat, default value otherwise. throws: ClassCastException - is thrown if the key maps to anobject that is not a Long. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getProperties | public Properties getProperties(String key, Properties defaults)(Code) | | Get a list of properties associated with the given
configuration key.
Parameters: key - The configuration key. Parameters: defaults - Any default values for the returnedProperties object. Ignored if null . The associated properties if key is found. throws: ClassCastException - is thrown if the key maps to anobject that is not a String/Vector of Strings. throws: IllegalArgumentException - if one of the tokens ismalformed (does not contain an equals sign). |
getProperty | public Object getProperty(String key)(Code) | | Gets a property from the configuration.
Parameters: key - property to retrieve value as object. Will return user value if exists,if not then default value if exists, otherwise null |
getPropertyDirect | abstract protected Object getPropertyDirect(String key)(Code) | | Read property. Should return null if the key doesn't
map to an existing object.
Parameters: key - key to use for mapping object associated with the given configuration key. |
getShort | public short getShort(String key)(Code) | | Get a short associated with the given configuration key.
Parameters: key - The configuration key. The associated short. throws: NoSuchElementException - is thrown if the key doesn'tmap to an existing object. throws: ClassCastException - is thrown if the key maps to anobject that is not a Short. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getShort | public short getShort(String key, short defaultValue)(Code) | | Get a short associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated short. throws: ClassCastException - is thrown if the key maps to anobject that is not a Short. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getShort | public Short getShort(String key, Short defaultValue)(Code) | | Get a short associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated short if key is found and has validformat, default value otherwise. throws: ClassCastException - is thrown if the key maps to anobject that is not a Short. throws: NumberFormatException - is thrown if the value mappedby the key has not a valid number format. |
getString | public String getString(String key)(Code) | | Get a string associated with the given configuration key.
Parameters: key - The configuration key. The associated string. throws: ClassCastException - is thrown if the key maps to an object thatis not a String. throws: NoSuchElementException - is thrown if the key doesn'tmap to an existing object. |
getString | public String getString(String key, String defaultValue)(Code) | | Get a string associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated string if key is found, default value otherwise. throws: ClassCastException - is thrown if the key maps to an object thatis not a String. |
getStringArray | public String[] getStringArray(String key)(Code) | | Get an array of strings associated with the given configuration
key.
Parameters: key - The configuration key. The associated string array if key is found. throws: ClassCastException - is thrown if the key maps to anobject that is not a String/Vector of Strings. |
getVector | public Vector getVector(String key)(Code) | | Get a Vector of strings associated with the given configuration key.
Parameters: key - The configuration key. The associated Vector. throws: ClassCastException - is thrown if the key maps to anobject that is not a Vector. throws: NoSuchElementException - is thrown if the key doesn'tmap to an existing object. |
getVector | public Vector getVector(String key, Vector defaultValue)(Code) | | Get a Vector of strings associated with the given configuration key.
Parameters: key - The configuration key. Parameters: defaultValue - The default value. The associated Vector. throws: ClassCastException - is thrown if the key maps to anobject that is not a Vector. |
interpolate | protected String interpolate(String base)(Code) | | interpolate key names to handle ${key} stuff
Parameters: base - string to interpolate returns the key name with the ${key} substituted |
interpolateHelper | protected String interpolateHelper(String base, List priorVariables)(Code) | | Recursive handler for multple levels of interpolation.
When called the first time, priorVariables should be null.
Parameters: base - string with the ${key} variables Parameters: priorVariables - serves two purposes: to allow checking forloops, and creating a meaningful exception message should a loopoccur. It's 0'th element will be set to the value of base fromthe first call. All subsequent interpolated variables are addedafterward. the string with the interpolation taken care of |
isEmpty | abstract public boolean isEmpty()(Code) | | Check if the configuration is empty
true if Configuration is empty,false otherwise. |
processString | protected List processString(String token)(Code) | | Returns a Vector of Strings built from the supplied
String. Splits up CSV lists. If no commas are in the
String, simply returns a Vector with the String as its
first element
Parameters: token - The String to tokenize A List of Strings |
setProperty | public void setProperty(String key, Object value)(Code) | | Set a property, this will replace any previously
set values. Set values is implicitly a call
to clearProperty(key), addProperty(key,value).
Parameters: key - the configuration key Parameters: value - the property value |
subset | public Configuration subset(String prefix)(Code) | | Create an BaseConfiguration object that is a subset
of this one.
Parameters: prefix - prefix string for keys subset of configuration if there is keys, that matchgiven prefix, or null if there is no such keys. |
testBoolean | final protected Boolean testBoolean(String value)(Code) | | Test whether the string represent by value maps to a boolean
value or not. We will allow true , on ,
and yes for a true boolean value, and
false , off , and no for
false boolean values. Case of value to test for
boolean status is ignored.
Parameters: value - The value to test for boolean state. true or false if the suppliedtext maps to a boolean value, or null otherwise. |
|
|