|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Dictionary<K,V> java.util.Hashtable org.apache.velocity.runtime.configuration.Configuration
@Deprecated public class Configuration
This class extends normal Java properties by adding the possibility to use the same key many times concatenating the value strings instead of overwriting them.
The Extended Properties syntax is explained here:
key = value
Here is an example of a valid extended properties file:
# lines starting with # are comments # This is the simplest property key = value # A long property may be separated on multiple lines longvalue = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa # This is a property with many tokens tokens_on_a_line = first token, second token # This sequence generates exactly the same result tokens_on_multiple_lines = first token tokens_on_multiple_lines = second token # commas may be escaped in tokens commas.excaped = Hi\, what'up?
NOTE: this class has not been written for performance nor low memory usage. In fact, it's way slower than it could be and generates too much memory garbage. But since performance is not an issue during intialization (and there is not much time to improve it), I wrote it this way. If you don't like it, go ahead and tune it up!
Field Summary | |
---|---|
protected String |
basePath
Deprecated. Base path of the configuration file used to create this Configuration object. |
protected String |
file
Deprecated. The file connected to this repository (holding comments and such). |
protected String |
fileSeparator
Deprecated. File separator. |
protected static String |
include
Deprecated. This is the name of the property that can point to other properties file for including other properties files. |
protected boolean |
isInitialized
Deprecated. Has this configuration been intialized. |
protected ArrayList |
keysAsListed
Deprecated. These are the keys in the order they listed in the configuration file. |
Constructor Summary | |
---|---|
Configuration()
Deprecated. Creates an empty extended properties object. |
|
Configuration(String file)
Deprecated. Creates and loads the extended properties from the specified file. |
|
Configuration(String file,
String defaultFile)
Deprecated. Creates and loads the extended properties from the specified file. |
Method Summary | |
---|---|
void |
addProperty(String key,
Object token)
Deprecated. Add a property to the configuration. |
void |
clearProperty(String key)
Deprecated. Clear a property in the configuration. |
void |
combine(Configuration c)
Deprecated. Combines an existing Hashtable with this Hashtable. |
static Configuration |
convertProperties(Properties p)
Deprecated. Convert a standard properties class into a configuration class. |
void |
display()
Deprecated. Display the configuration for debugging purposes. |
boolean |
getBoolean(String key)
Deprecated. Get a boolean associated with the given configuration key. |
boolean |
getBoolean(String key,
boolean defaultValue)
Deprecated. Get a boolean associated with the given configuration key. |
Boolean |
getBoolean(String key,
Boolean defaultValue)
Deprecated. Get a boolean associated with the given configuration key. |
byte |
getByte(String key)
Deprecated. Get a byte associated with the given configuration key. |
byte |
getByte(String key,
byte defaultValue)
Deprecated. Get a byte associated with the given configuration key. |
Byte |
getByte(String key,
Byte defaultValue)
Deprecated. Get a byte associated with the given configuration key. |
double |
getDouble(String key)
Deprecated. Get a double associated with the given configuration key. |
double |
getDouble(String key,
double defaultValue)
Deprecated. Get a double associated with the given configuration key. |
Double |
getDouble(String key,
Double defaultValue)
Deprecated. Get a double associated with the given configuration key. |
org.apache.commons.collections.ExtendedProperties |
getExtendedProperties()
Deprecated. Do not use. For deprecation assistance only. |
float |
getFloat(String key)
Deprecated. Get a float associated with the given configuration key. |
float |
getFloat(String key,
float defaultValue)
Deprecated. Get a float associated with the given configuration key. |
Float |
getFloat(String key,
Float defaultValue)
Deprecated. Get a float associated with the given configuration key. |
String |
getInclude()
Deprecated. Gets the property value for including other properties files. |
int |
getInt(String name)
Deprecated. The purpose of this method is to get the configuration resource with the given name as an integer. |
int |
getInt(String name,
int def)
Deprecated. The purpose of this method is to get the configuration resource with the given name as an integer, or a default value. |
int |
getInteger(String key)
Deprecated. Get a int associated with the given configuration key. |
int |
getInteger(String key,
int defaultValue)
Deprecated. Get a int associated with the given configuration key. |
Integer |
getInteger(String key,
Integer defaultValue)
Deprecated. Get a int associated with the given configuration key. |
Iterator |
getKeys()
Deprecated. Get the list of the keys contained in the configuration repository. |
Iterator |
getKeys(String prefix)
Deprecated. Get the list of the keys contained in the configuration repository that match the specified prefix. |
long |
getLong(String key)
Deprecated. Get a long associated with the given configuration key. |
long |
getLong(String key,
long defaultValue)
Deprecated. Get a long associated with the given configuration key. |
Long |
getLong(String key,
Long defaultValue)
Deprecated. Get a long associated with the given configuration key. |
Properties |
getProperties(String key)
Deprecated. Get a list of properties associated with the given configuration key. |
Properties |
getProperties(String key,
Properties defaults)
Deprecated. Get a list of properties associated with the given configuration key. |
Object |
getProperty(String key)
Deprecated. Gets a property from the configuration. |
short |
getShort(String key)
Deprecated. Get a short associated with the given configuration key. |
short |
getShort(String key,
short defaultValue)
Deprecated. Get a short associated with the given configuration key. |
Short |
getShort(String key,
Short defaultValue)
Deprecated. Get a short associated with the given configuration key. |
String |
getString(String key)
Deprecated. Get a string associated with the given configuration key. |
String |
getString(String key,
String defaultValue)
Deprecated. Get a string associated with the given configuration key. |
String[] |
getStringArray(String key)
Deprecated. Get an array of strings associated with the given configuration key. |
Vector |
getVector(String key)
Deprecated. Get a Vector of strings associated with the given configuration key. |
Vector |
getVector(String key,
Vector defaultValue)
Deprecated. Get a Vector of strings associated with the given configuration key. |
boolean |
isInitialized()
Deprecated. Indicate to client code whether property resources have been initialized or not. |
void |
load(InputStream input)
Deprecated. Load the properties from the given input stream. |
void |
save(OutputStream output,
String Header)
Deprecated. Save the properties to the given outputstream. |
void |
setInclude(String inc)
Deprecated. Sets the property value for including other properties files. |
void |
setProperty(String key,
Object value)
Deprecated. Set a property, this will replace any previously set values. |
Configuration |
subset(String prefix)
Deprecated. Create a Configurations object that is a subset of this one. |
String |
testBoolean(String value)
Deprecated. Test whether the string represent by value maps to a boolean value or not. |
Methods inherited from class java.util.Hashtable |
---|
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected String file
protected String basePath
protected String fileSeparator
protected boolean isInitialized
protected static String include
protected ArrayList keysAsListed
Constructor Detail |
---|
public Configuration()
public Configuration(String file) throws IOException
file
- A String.
IOException
public Configuration(String file, String defaultFile) throws IOException
file
- A String.
IOException
Method Detail |
---|
public boolean isInitialized()
public String getInclude()
public void setInclude(String inc)
inc
- A String.public void load(InputStream input) throws IOException
input
- An InputStream.
IOException
public Object getProperty(String key)
key
- property to retrieve
public void addProperty(String key, Object token)
key
- token
- public void setProperty(String key, Object value)
key
- value
- public void save(OutputStream output, String Header)
output
- An OutputStream.Header
- A String.
IOException
public void combine(Configuration c)
c
- public void clearProperty(String key)
key
- key to remove along with corresponding value.public Iterator getKeys()
public Iterator getKeys(String prefix)
prefix
- The prefix to test against.
public Configuration subset(String prefix)
prefix
- public void display()
public String getString(String key)
key
- The configuration key.
ClassCastException
- is thrown if the key maps to an
object that is not a String.public String getString(String key, String defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a String.public Properties getProperties(String key)
key
- The configuration key.
ClassCastException
- is thrown if the key maps to an
object that is not a String/Vector.
IllegalArgumentException
- if one of the tokens is
malformed (does not contain an equals sign).public Properties getProperties(String key, Properties defaults)
key
- The configuration key.defaults
-
ClassCastException
- is thrown if the key maps to an
object that is not a String/Vector.
IllegalArgumentException
- if one of the tokens is
malformed (does not contain an equals sign).public String[] getStringArray(String key)
key
- The configuration key.
ClassCastException
- is thrown if the key maps to an
object that is not a String/Vector.public Vector getVector(String key)
key
- The configuration key.
ClassCastException
- is thrown if the key maps to an
object that is not a Vector.public Vector getVector(String key, Vector defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Vector.public boolean getBoolean(String key)
key
- The configuration key.
NoSuchElementException
- is thrown if the key doesn't
map to an existing object.
ClassCastException
- is thrown if the key maps to an
object that is not a Boolean.public boolean getBoolean(String key, boolean defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Boolean.public Boolean getBoolean(String key, Boolean defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Boolean.public String testBoolean(String value)
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.
value
- The value to test for boolean state.
true
or false
if the supplied
text maps to a boolean value, or null
otherwise.public byte getByte(String key)
key
- The configuration key.
NoSuchElementException
- is thrown if the key doesn't
map to an existing object.
ClassCastException
- is thrown if the key maps to an
object that is not a Byte.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public byte getByte(String key, byte defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Byte.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public Byte getByte(String key, Byte defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Byte.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public short getShort(String key)
key
- The configuration key.
NoSuchElementException
- is thrown if the key doesn't
map to an existing object.
ClassCastException
- is thrown if the key maps to an
object that is not a Short.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public short getShort(String key, short defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Short.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public Short getShort(String key, Short defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Short.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public int getInt(String name)
name
- The resource name.
public int getInt(String name, int def)
name
- The resource namedef
- The default value of the resource.
public int getInteger(String key)
key
- The configuration key.
NoSuchElementException
- is thrown if the key doesn't
map to an existing object.
ClassCastException
- is thrown if the key maps to an
object that is not a Integer.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public int getInteger(String key, int defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Integer.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public Integer getInteger(String key, Integer defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Integer.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public long getLong(String key)
key
- The configuration key.
NoSuchElementException
- is thrown if the key doesn't
map to an existing object.
ClassCastException
- is thrown if the key maps to an
object that is not a Long.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public long getLong(String key, long defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Long.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public Long getLong(String key, Long defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Long.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public float getFloat(String key)
key
- The configuration key.
NoSuchElementException
- is thrown if the key doesn't
map to an existing object.
ClassCastException
- is thrown if the key maps to an
object that is not a Float.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public float getFloat(String key, float defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Float.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public Float getFloat(String key, Float defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Float.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public double getDouble(String key)
key
- The configuration key.
NoSuchElementException
- is thrown if the key doesn't
map to an existing object.
ClassCastException
- is thrown if the key maps to an
object that is not a Double.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public double getDouble(String key, double defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Double.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public Double getDouble(String key, Double defaultValue)
key
- The configuration key.defaultValue
- The default value.
ClassCastException
- is thrown if the key maps to an
object that is not a Double.
NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public static Configuration convertProperties(Properties p)
p
- properties object to convert into
a Configuration object.
@Deprecated public org.apache.commons.collections.ExtendedProperties getExtendedProperties()
Routine intended for deprecation period only as we switch from using the Configuration class in Velocity to the Jakarta Commons ExtendedProperties
Do not use this for general use. It will disappear
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |