de.unidu.is.util
Class FilePropertyMap
java.lang.Object
de.unidu.is.util.PropertyMap
de.unidu.is.util.DelegatedPropertyMap
de.unidu.is.util.StreamPropertyMap
de.unidu.is.util.FilePropertyMap
- All Implemented Interfaces:
- java.util.Map
- public class FilePropertyMap
- extends StreamPropertyMap
A PropertyMap which can be loaded from and saved into a file. 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 file.
This class can also be used for merging multiple files (given by file names,
URLs or input streams).
Changes to this map are directly written into the file if a single one is
specified (i.e., this map is not used for merging files).
- 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 |
filename
Filename of this FilePropertyMap. |
|
Constructor Summary |
FilePropertyMap(java.io.Reader stream)
Creates a new instance and loads the properties given by the reader. |
FilePropertyMap(java.io.Reader[] streams)
Creates a new instance and loads the properties given by the array
of readers. |
FilePropertyMap(java.io.Reader[] streams,
boolean multiple)
Creates a new instance and loads the properties given by the array
of readers. |
FilePropertyMap(java.io.Reader stream,
boolean multiple)
Creates a new instance and loads the properties given by the reader. |
FilePropertyMap(java.lang.String name)
Creates a new instance and loads its properties. |
FilePropertyMap(java.lang.String name,
boolean multiple)
Creates a new instance and loads its properties. |
FilePropertyMap(java.lang.String name,
java.util.Map map,
java.lang.String header)
Creates a new instance and loads its properties. |
FilePropertyMap(java.lang.String name,
java.util.Map map,
java.lang.String header,
boolean multiple)
Creates a new instance and loads its properties. |
FilePropertyMap(java.lang.String name,
java.lang.String header)
Creates a new instance and loads its properties. |
FilePropertyMap(java.lang.String name,
java.lang.String header,
boolean multiple)
Creates a new instance and loads its properties. |
FilePropertyMap(java.net.URL url)
Creates a new instance and loads the properties given by the URL |
FilePropertyMap(java.net.URL[] urls)
Creates a new instance and loads the properties given by the array
of URLs. |
FilePropertyMap(java.net.URL[] urls,
boolean multiple)
Creates a new instance and loads the properties given by the array
of URLs. |
FilePropertyMap(java.net.URL url,
boolean multiple)
Creates a new instance and loads the properties given by the URL. |
|
Method Summary |
void |
add(java.io.File file)
Adds the map from the file. |
void |
add(java.lang.String file)
Adds the map from the file. |
static PropertyMap |
getConfiguration()
Deprecated. Use de.unidu.is.util.Config instead. |
protected java.io.Reader |
getReader()
Returns a Reader from which keys and values are read. |
protected java.io.Writer |
getWriter()
Returns a Writer to which keys and values are written. |
| 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 |
filename
protected java.lang.String filename
- Filename of this FilePropertyMap.
FilePropertyMap
public FilePropertyMap(java.lang.String name)
- Creates a new instance and loads its properties.
- Parameters:
name - absolute file name
FilePropertyMap
public FilePropertyMap(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
FilePropertyMap
public FilePropertyMap(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
FilePropertyMap
public FilePropertyMap(java.net.URL url)
- Creates a new instance and loads the properties given by the URL
- Parameters:
url - URL from which the properties are loaded
FilePropertyMap
public FilePropertyMap(java.io.Reader stream)
- Creates a new instance and loads the properties given by the reader.
- Parameters:
stream - reader from which the properties are loaded
FilePropertyMap
public FilePropertyMap(java.lang.String name,
java.util.Map map,
java.lang.String header)
- Creates a new instance and loads its properties.
- Parameters:
name - absolute file namemap - to which calls are delegatedheader - file header (may be null)
FilePropertyMap
public FilePropertyMap(java.lang.String name,
java.lang.String header)
- Creates a new instance and loads its properties.
- Parameters:
name - absolute file nameheader - file header (may be null)
FilePropertyMap
public FilePropertyMap(java.lang.String name,
boolean multiple)
- Creates a new instance and loads its properties.
- Parameters:
name - absolute file namemultiple - values if true, multiple values can be hold for a key
FilePropertyMap
public FilePropertyMap(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
FilePropertyMap
public FilePropertyMap(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
FilePropertyMap
public FilePropertyMap(java.net.URL url,
boolean multiple)
- Creates a new instance and loads the properties given by the URL.
- Parameters:
url - URL from which the properties are loadedmultiple - multiple values if true, multiple values can be hold for a key
FilePropertyMap
public FilePropertyMap(java.io.Reader stream,
boolean multiple)
- Creates a new instance and loads the properties given by the reader.
- Parameters:
stream - reader from which the properties are loadedmultiple - multiple values if true, multiple values can be hold for a key
FilePropertyMap
public FilePropertyMap(java.lang.String name,
java.util.Map map,
java.lang.String header,
boolean multiple)
- Creates a new instance and loads its properties.
- Parameters:
name - absolute file namemap - to which calls are delegatedheader - file header (may be null)multiple - values if true, multiple values can be hold for a key
FilePropertyMap
public FilePropertyMap(java.lang.String name,
java.lang.String header,
boolean multiple)
- Creates a new instance and loads its properties.
- Parameters:
name - absolute file nameheader - file header (may be null)multiple - values if true, multiple values can be hold for a key
add
public void add(java.lang.String file)
- Adds the map from the file.
- Parameters:
file - file from where to read
add
public void add(java.io.File file)
- Adds the map from the file.
- Parameters:
file - file from where to read
getReader
protected java.io.Reader getReader()
throws java.io.IOException
- Returns a Reader from which keys and values are read.
- Specified by:
getReader in class StreamPropertyMap
- Returns:
- Reader from which keys and values are read
- Throws:
java.io.IOException
getWriter
protected java.io.Writer getWriter()
throws java.io.IOException
- Returns a Writer to which keys and values are written.
This method returns null if no filename is given.
This will result in the fact the nothing is saved.
- Specified by:
getWriter in class StreamPropertyMap
- Returns:
- Reader to which keys and values are written
- Throws:
java.io.IOException
getConfiguration
public static PropertyMap getConfiguration()
- Deprecated. Use de.unidu.is.util.Config instead.
- Returns a PropertyMap backed by the config file.
- Returns:
- PropertyMap backed by the config file