org.crosswire.common.util
Class PropertyMap
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<String,String>
org.crosswire.common.util.PropertyMap
- All Implemented Interfaces:
- Serializable, Cloneable, Map<String,String>
public class PropertyMap
- extends LinkedHashMap<String,String>
A PropertyMap is a Map sitting over top a Property file.
As such it must be defined in the same way as a java.lang.Properties expects.
- Author:
- DM Smith
- See Also:
Properties
,
for license details.
The copyright to this program is held by it's authors.
,
Serialized Form
Constructor Summary |
PropertyMap()
Creates an empty property list with no default values. |
PropertyMap(PropertyMap defaults)
Creates an empty property map with the specified defaults. |
Methods inherited from interface java.util.Map |
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
defaults
private PropertyMap defaults
- Default values for any keys not found in this property map.
serialVersionUID
private static final long serialVersionUID
- Serialization ID
- See Also:
- Constant Field Values
PropertyMap
public PropertyMap()
- Creates an empty property list with no default values.
PropertyMap
public PropertyMap(PropertyMap defaults)
- Creates an empty property map with the specified defaults.
- Parameters:
defaults
- the defaults.
get
public String get(String key)
- Searches for the property with the specified key in this property list.
If the key is not found in this property list, the default property list,
and its defaults, recursively, are then checked. The method returns
null
if the property is not found.
- Parameters:
key
- the lookup key.
- Returns:
- the value in this property list with the specified key value.
- See Also:
Properties
,
defaults
get
public String get(String key,
String defaultValue)
- Searches for the property with the specified key in this property list.
If the key is not found in this property list, the default property list,
and its defaults, recursively, are then checked. The method returns the
default value argument if the property is not found.
- Parameters:
key
- the lookup key.defaultValue
- a default value.
- Returns:
- the value in this property list with the specified key value.
- See Also:
Properties
,
defaults
setProperty
@Deprecated
public String setProperty(String key,
String value)
- Deprecated. use
put(String, String)
instead.
- Merely a call to
put(String, String)
, provided as
a simple way to migrate from Properties
.
- Parameters:
key
- the key to be placed into this property list.value
- the value corresponding to key.
- Returns:
- the previous value of the specified key in this property
list, or
null
if it did not have one.
getProperty
@Deprecated
public String getProperty(String key)
- Deprecated. use
get(String)
instead
- Merely a call to
get(String)
, provided as
a simple way to migrate from Properties
.
- Parameters:
key
- the lookup key
- Returns:
- the value in this property list with the specified key value.
getProperty
@Deprecated
public String getProperty(String key,
String defaultValue)
- Deprecated. use
get(String, String)
instead
- Merely a call to
get(String, String)
, provided as
a simple way to migrate from Properties
.
- Parameters:
key
- the lookup key.defaultValue
- a default value.
- Returns:
- the value in this property list with the specified key value.
load
public void load(InputStream inStream)
throws IOException
- Reads a property list (key and element pairs) from the input
byte stream. The input stream is in a simple line-oriented
format as specified in
load(InputStream)
and is assumed to use
the ISO 8859-1 character encoding; that is each byte is one Latin1
character. Characters not in Latin1, and certain special characters,
are represented in keys and elements using
Unicode escapes.
The specified stream remains open after this method returns.
- Parameters:
inStream
- the input stream.
- Throws:
IOException
- if an error occurred when reading from the
input stream.
IllegalArgumentException
- if the input stream contains a
malformed Unicode escape sequence.- Since:
- 1.2
store
public void store(OutputStream out,
String comments)
throws IOException
- Writes this property list (key and element pairs) in this
PropertyMap
table to the output stream in a format suitable
for loading into a PropertyMap
table using the
load(InputStream)
method.
Properties from the defaults table of this PropertyMap
table (if any) are not written out by this method.
This method outputs the comments, properties keys and values in
the same format as specified in
store(Writer)
,
After the entries have been written, the output stream is flushed.
The output stream remains open after this method returns.
- Parameters:
out
- an output stream.comments
- a description of the property list.
- Throws:
IOException
- if writing this property list to the specified
output stream throws an IOException.
NullPointerException
- if out
is null.- Since:
- 1.2