de.unidu.is.util
Class StreamPropertyMap
java.lang.Object
de.unidu.is.util.PropertyMap
de.unidu.is.util.DelegatedPropertyMap
de.unidu.is.util.StreamPropertyMap
- All Implemented Interfaces:
- java.util.Map
- Direct Known Subclasses:
- FilePropertyMap
- public abstract class StreamPropertyMap
- extends DelegatedPropertyMap
A PropertyMap which can be loaded from and saved into a stream. The format is
nearly the same as for java.util.Properties (which means it
consists of lines key=value, and lines starting with
a hash are ignored), only colons are not escaped (altough files with an
escaped colon can be read).
Instances can either use a HashMap or any other Map for storing the items
loaded from the stream.
Changes to this map are directly written into a stream.
- Since:
- 2003-06-20
- Version:
- $Revision: 1.15 $, $Date: 2005/03/14 17:33:13 $
- Author:
- Henrik Nottelmann
| Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
|
Field Summary |
protected java.lang.String |
header
Starting header (may be null). |
|
Constructor Summary |
StreamPropertyMap(java.util.Map map,
java.lang.String header)
Creates a new instance without loading its properties. |
StreamPropertyMap(java.util.Map map,
java.lang.String header,
boolean multiple)
Creates a new instance without loading its properties. |
StreamPropertyMap(java.io.Reader[] streams)
Creates a new instance and loads the properties given by the array of
readers. |
StreamPropertyMap(java.io.Reader[] streams,
boolean multiple)
Creates a new instance and loads the properties given by the array of
readers. |
StreamPropertyMap(java.lang.String header)
Creates a new instance without loading its properties. |
StreamPropertyMap(java.lang.String header,
boolean multiple)
Creates a new instance without loading its properties. |
StreamPropertyMap(java.net.URL[] urls)
Creates a new instance and loads the properties given by the array of
URLs. |
StreamPropertyMap(java.net.URL[] urls,
boolean multiple)
Creates a new instance and loads the properties given by the array of
URLs. |
|
Method Summary |
void |
add(java.io.Reader reader)
Adds the map from the sream. |
void |
add(java.net.URL url)
Adds the map from the url. |
protected void |
changed()
Saves the properties in the config file. |
protected abstract java.io.Reader |
getReader()
Returns a Reader from which keys and values are read.
|
protected abstract java.io.Writer |
getWriter()
Returns a Writer to which keys and values are written.
|
void |
load()
Loads this map from a stream. |
void |
save()
Saves this map into a stream.
|
void |
write(java.io.Writer writer)
Writes this map into a stream, if that is not null. |
| Methods inherited from class de.unidu.is.util.DelegatedPropertyMap |
clear, containsKey, containsValue, entrySet, equals, get, getAll, getInitKeys, getMap, hashCode, init, isEmpty, keySet, put, putAll, putInitial, putNoChange, remove, remove, setInitKeys, setMap, size, toString, values |
| Methods inherited from class de.unidu.is.util.PropertyMap |
addDouble, addDouble, addDouble, addInt, addInt, addInt, apply, convertString, divDouble, divDouble, divDouble, divInt, divInt, divInt, getBoolean, getDouble, getInt, getLength, getLong, getMaxDouble, getMaxKey, getMinDouble, getString, getString, getSum, hasMultipleValues, inc, initDouble, isMultipleValues, multDouble, multDouble, multDouble, multDouble, multInt, multInt, multInt, normalizeLength, removeCloseToZero, removeZero, set, setBoolean, setDouble, setInt, setLong, setMultipleValues, setString, subDouble, subDouble, subDouble, subInt, subInt, subInt |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
header
protected java.lang.String header
- Starting header (may be null).
StreamPropertyMap
public StreamPropertyMap(java.lang.String header)
- Creates a new instance without loading its properties.
- Parameters:
header - starting header (may be null)
StreamPropertyMap
public StreamPropertyMap(java.util.Map map,
java.lang.String header)
- Creates a new instance without loading its properties.
- Parameters:
map - to which calls are delegatedheader - starting header (may be null)
StreamPropertyMap
public StreamPropertyMap(java.net.URL[] urls)
- Creates a new instance and loads the properties given by the array of
URLs.
- Parameters:
urls - array of URLs from which the properties are loaded
StreamPropertyMap
public StreamPropertyMap(java.io.Reader[] streams)
- Creates a new instance and loads the properties given by the array of
readers.
- Parameters:
streams - array of readers from which the properties are loaded
StreamPropertyMap
public StreamPropertyMap(java.lang.String header,
boolean multiple)
- Creates a new instance without loading its properties.
- Parameters:
header - starting header (may be null)multiple - values if true, multiple values can be hold for a key
StreamPropertyMap
public StreamPropertyMap(java.util.Map map,
java.lang.String header,
boolean multiple)
- Creates a new instance without loading its properties.
- Parameters:
map - to which calls are delegatedheader - starting header (may be null)multiple - values if true, multiple values can be hold for a key
StreamPropertyMap
public StreamPropertyMap(java.net.URL[] urls,
boolean multiple)
- Creates a new instance and loads the properties given by the array of
URLs.
- Parameters:
urls - array of URLs from which the properties are loadedmultiple - multiple values if true, multiple values can be hold for a key
StreamPropertyMap
public StreamPropertyMap(java.io.Reader[] streams,
boolean multiple)
- Creates a new instance and loads the properties given by the array of
readers.
- Parameters:
streams - array of readers from which the properties are loadedmultiple - multiple values if true, multiple values can be hold for a key
add
public void add(java.net.URL url)
- Adds the map from the url.
- Parameters:
url - url from where to read
add
public void add(java.io.Reader reader)
- Adds the map from the sream.
- Parameters:
reader - stream from where to read
write
public void write(java.io.Writer writer)
- Writes this map into a stream, if that is not
null.
- Parameters:
writer - stream into which this map is written.
load
public void load()
- Loads this map from a stream.
save
public void save()
- Saves this map into a stream.
The map is written to the writer returned by getWriter(),
if that method does not return null
changed
protected void changed()
- Saves the properties in the config file.
- Overrides:
changed in class DelegatedPropertyMap
getReader
protected abstract java.io.Reader getReader()
throws java.io.IOException
- Returns a Reader from which keys and values are read.
Subclasses have to overwrite this method.
- Returns:
- Reader from which keys and values are read
- Throws:
java.io.IOException
getWriter
protected abstract java.io.Writer getWriter()
throws java.io.IOException
- Returns a Writer to which keys and values are written.
Subclasses have to overwrite this method.
- Returns:
- Reader to which keys and values are written
- Throws:
java.io.IOException