org.apache.java.util
Class ExtendedProperties
java.lang.Object
|
+--java.util.Dictionary
|
+--java.util.Hashtable
|
+--org.apache.java.util.ConfigurationsRepository
|
+--org.apache.java.util.ExtendedProperties
- public class ExtendedProperties
- extends ConfigurationsRepository
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:
- each property has the syntax
key = value
- the key may use any character but the equal sign '='
- value may be separated on different lines if a backslash
is placed at the end of the line that continues below.
- if value is a list of strings, each token is separated
by a comma ','
- Commas in each token are escaped placing a backslash right before
the comma.
- if a key is used more than once, the values are appended
like if they were on the same line separated with commas.
- blank lines and lines starting with character '#' are skipped
- If a property is named "include" (or whatever is defined by setInclude()
and getInclude() and the value of that property
is the full path to a file on disk, that file will be included
into the ConfigurationsRepository. Duplicate name values will be
replaced, so be careful.
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 = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# 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 it's not an
issue during intialization (and there no much time to improve it),
I wrote it this way. If you don't like it, go ahead and tune it up!
- Version:
- $Revision: 1.11 $ $Date: 2000/04/29 01:26:04 $
- See Also:
Configurations
, Serialized Form
Field Summary |
private static java.lang.String |
include
this is the name of the property that can point to other
properties file for including other properties files |
Fields inherited from class java.util.Hashtable |
count,
ENTRIES,
entrySet,
KEYS,
keySet,
loadFactor,
modCount,
serialVersionUID,
table,
threshold,
values,
VALUES |
Constructor Summary |
ExtendedProperties()
Creates an empty extended properties object. |
ExtendedProperties(java.lang.String file)
Creates and loads the extended properties from the specified file. |
Method Summary |
java.lang.String |
getInclude()
Gets the property value for including other properties files
By default it is "include" |
void |
load(java.io.InputStream input)
Load the properties from the given input stream. |
void |
save(java.io.OutputStream output,
java.lang.String Header)
Save the properties to the given outputstream. |
void |
setInclude(java.lang.String inc)
Sets the property value for including other properties files. |
Methods inherited from class java.util.Hashtable |
clear,
clone,
contains,
containsKey,
containsValue,
elements,
entrySet,
equals,
get,
hashCode,
isEmpty,
keys,
keySet,
put,
putAll,
readObject,
rehash,
remove,
size,
toString,
values,
writeObject |
Methods inherited from class java.lang.Object |
,
finalize,
getClass,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
include
private static java.lang.String include
- this is the name of the property that can point to other
properties file for including other properties files
ExtendedProperties
public ExtendedProperties()
- Creates an empty extended properties object.
ExtendedProperties
public ExtendedProperties(java.lang.String file)
throws java.io.IOException
- Creates and loads the extended properties from the specified file.
getInclude
public java.lang.String getInclude()
- Gets the property value for including other properties files
By default it is "include"
setInclude
public void setInclude(java.lang.String inc)
- Sets the property value for including other properties files.
By default it is "include"
load
public void load(java.io.InputStream input)
throws java.io.IOException
- Load the properties from the given input stream.
- Overrides:
- load in class ConfigurationsRepository
save
public void save(java.io.OutputStream output,
java.lang.String Header)
throws java.io.IOException
- Save the properties to the given outputstream.
- Overrides:
- save in class ConfigurationsRepository