Overview Package Class Use Tree Deprecated Index Help
Prev Class Next Class Frames NoFrames All Classes
Summary: Nested Field Constr Method Detail: Field Constr Method
org.apache.velocity.runtime.configuration
public class Configuration extends Hashtable
Deprecated: As of version 1.1, please use ExtendedProperties from the Jakarta Commons Collections component.
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!
Version: $Id: Configuration.java,v 1.34 2003/05/04 17:14:37 geirm Exp $
Author: Stefano Mazzocchi Jon S. Stevens Dave Bryson Jason van Zyl Geir Magnusson Jr. Leon Messerschmidt
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. Serial: Parameters: file A String. Throws: IOException. Parameters: file A String. Throws: IOException. Parameters: String key String value Parameters: String key to remove along with corresponding value. Parameters: Configuration Parameters: Properties properties object to convert into
a Configuration object.
Returns: Configuration configuration created from the
properties object. Parameters: key The configuration key. Returns: The associated boolean. Throws: 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. Parameters: key The configuration key. defaultValue The default value. Returns: The associated boolean. Throws: ClassCastException is thrown if the key maps to an
object that is not a Boolean. Parameters: key The configuration key. defaultValue The default value. Returns: The associated boolean if key is found and has valid
format, default value otherwise. Throws: ClassCastException is thrown if the key maps to an
object that is not a Boolean. Parameters: key The configuration key. Returns: The associated byte. Throws: 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. Parameters: key The configuration key. defaultValue The default value. Returns: The associated byte. Throws: 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. Parameters: key The configuration key. defaultValue The default value. Returns: The associated byte if key is found and has valid
format, default value otherwise. Throws: 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. Parameters: key The configuration key. Returns: The associated double. Throws: 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. Parameters: key The configuration key. defaultValue The default value. Returns: The associated double. Throws: 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. Parameters: key The configuration key. defaultValue The default value. Returns: The associated double if key is found and has valid
format, default value otherwise. Throws: 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. Deprecated: Do not use. For deprecation assistance only.
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
Returns: ExtendedProperties containing data of Configuration
Parameters: key The configuration key. Returns: The associated float. Throws: 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. Parameters: key The configuration key. defaultValue The default value. Returns: The associated float. Throws: 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. Parameters: key The configuration key. defaultValue The default value. Returns: The associated float if key is found and has valid
format, default value otherwise. Throws: 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. Returns: A String. Parameters: name The resource name. Returns: The value of the resource as an integer. Parameters: name The resource name def The default value of the resource. Returns: The value of the resource as an integer. Parameters: key The configuration key. Returns: The associated int. Throws: 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. Parameters: key The configuration key. defaultValue The default value. Returns: The associated int. Throws: 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. Parameters: key The configuration key. defaultValue The default value. Returns: The associated int if key is found and has valid
format, default value otherwise. Throws: 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. Returns: An Iterator. Parameters: prefix The prefix to test against. Returns: An Iterator of keys that match the prefix. Parameters: key The configuration key. Returns: The associated long. Throws: 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. Parameters: key The configuration key. defaultValue The default value. Returns: The associated long. Throws: 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. Parameters: key The configuration key. defaultValue The default value. Returns: The associated long if key is found and has valid
format, default value otherwise. Throws: 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. Parameters: key The configuration key. Returns: The associated properties if key is found. Throws: 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). Parameters: key The configuration key. Returns: The associated properties if key is found. Throws: 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). Parameters: key property to retrieve Returns: value as object. Will return user value if exists,
if not then default value if exists, otherwise null Parameters: key The configuration key. Returns: The associated short. Throws: 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. Parameters: key The configuration key. defaultValue The default value. Returns: The associated short. Throws: 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. Parameters: key The configuration key. defaultValue The default value. Returns: The associated short if key is found and has valid
format, default value otherwise. Throws: 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. Parameters: key The configuration key. Returns: The associated string. Throws: ClassCastException is thrown if the key maps to an
object that is not a String. Parameters: key The configuration key. defaultValue The default value. Returns: The associated string if key is found,
default value otherwise. Throws: ClassCastException is thrown if the key maps to an
object that is not a String. Parameters: key The configuration key. Returns: The associated string array if key is found. Throws: ClassCastException is thrown if the key maps to an
object that is not a String/Vector. Parameters: key The configuration key. Returns: The associated Vector. Throws: ClassCastException is thrown if the key maps to an
object that is not a Vector. Parameters: key The configuration key. defaultValue The default value. Returns: The associated Vector. Throws: ClassCastException is thrown if the key maps to an
object that is not a Vector. Throws: IOException, if there was an I/O problem. Parameters: input An InputStream. Throws: IOException. Parameters: output An OutputStream. header A String. Throws: IOException. Parameters: inc A String. Parameters: String key String value Parameters: String prefix Parameters: String The value to test for boolean state. Returns:
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Class
Next Class
Frames
NoFrames
All Classes
Summary:
Nested
Field
Constr
Method
Detail:
Field
Constr
Method
Nested Class Summary class Configuration.PropertiesReader class Configuration.PropertiesTokenizer
Field Summary protected String basePath Configuration defaults ExtendedProperties deprecationCrutch protected String file protected String fileSeparator protected static String include protected boolean isInitialized protected ArrayList keysAsListed
Constructor Summary Configuration() Configuration(String file) Configuration(String file, String defaultFile)
Method Summary void addProperty(String key, Object token) void addStringProperty(String key, String token) void clearProperty(String key) void combine(Configuration c) static Configuration convertProperties(Properties p) void display() boolean getBoolean(String key) boolean getBoolean(String key, boolean defaultValue) Boolean getBoolean(String key, Boolean defaultValue) byte getByte(String key) byte getByte(String key, byte defaultValue) Byte getByte(String key, Byte defaultValue) double getDouble(String key) double getDouble(String key, double defaultValue) Double getDouble(String key, Double defaultValue) ExtendedProperties getExtendedProperties() float getFloat(String key) float getFloat(String key, float defaultValue) Float getFloat(String key, Float defaultValue) String getInclude() int getInt(String name) int getInt(String name, int def) int getInteger(String key) int getInteger(String key, int defaultValue) Integer getInteger(String key, Integer defaultValue) Iterator getKeys() Iterator getKeys(String prefix) long getLong(String key) long getLong(String key, long defaultValue) Long getLong(String key, Long defaultValue) Properties getProperties(String key) Properties getProperties(String key, Properties defaults) Object getProperty(String key) short getShort(String key) short getShort(String key, short defaultValue) Short getShort(String key, Short defaultValue) String getString(String key) String getString(String key, String defaultValue) String[] getStringArray(String key) Vector getVector(String key) Vector getVector(String key, Vector defaultValue) void init(Configuration exp) boolean isInitialized() void load(InputStream input) void save(OutputStream output, String Header) void setInclude(String inc) void setProperty(String key, Object value) Configuration subset(String prefix) String testBoolean(String value) Field Detail
basePath
defaults
deprecationCrutch
file
fileSeparator
include
isInitialized
keysAsListed
Constructor Detail
Configuration
Configuration
Configuration
Method Detail
addProperty
addStringProperty
clearProperty
combine
convertProperties
display
getBoolean
getBoolean
getBoolean
getByte
getByte
getByte
getDouble
getDouble
getDouble
getExtendedProperties
getFloat
getFloat
getFloat
getInclude
getInt
getInt
getInteger
getInteger
getInteger
getKeys
getKeys
getLong
getLong
getLong
getProperties
getProperties
getProperty
getShort
getShort
getShort
getString
getString
getStringArray
getVector
getVector
init
isInitialized
load
save
setInclude
setProperty
subset
testBoolean
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.
true
or false
if the supplied
text maps to a boolean value, or null
otherwise.