| java.util.Properties org.jaffa.util.ListProperties
ListProperties | public class ListProperties extends Properties (Code) | | This class combines the utility of the Properties class with a List. Features are:
1) Maintains the order of properties when loading them from an InputStream and when the properties are added manually.
2) Provides a sort capability for the properties
3) Provides a 'comments' attribute for each property
4) Stores the properties in an OutputStream, maintaining the order of the properties and the comments
NOTE: Even though this class extends HashTable (since Properties extends HashTable), this implementation is not synchronized !!
|
Constructor Summary | |
public | ListProperties() Creates an empty property list with no default values. | public | ListProperties(Properties defaults) Creates an empty property list with the specified defaults. |
Method Summary | |
public void | clear() Removes all mappings from this map. | public Object | clone() Returns a clone of this object. | public boolean | containsKey(Object key) Returns true if this map contains a mapping for the specified key.
The default mappings are not searched for the key.
Parameters: key - key whose presence in this map is to be tested. | public boolean | containsValue(Object value) Returns true if this map maps one or more keys to the specified value.
The default mappings are not searched for the value.
Parameters: value - value whose presence in this map is to be tested. | public Enumeration | elements() Returns an enumeration of the values in this hashtable. | public Set | entrySet() Returns a set view of the mappings contained in this map. | public boolean | equals(Object o) Compares the specified object with this map for equality.
Returns true if the given object is also a ListProperties and the two Properties represent the same mappings.
The comments are not compared.
The default mappings are not compared.
Parameters: o - object to be compared for equality with this map. | public Object | get(Object key) Returns the value to which this map maps the specified key.
Returns null if the map contains no mapping for this key.
A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null.
The containsKey operation may be used to distinguish these two cases.
The default mappings are not searched for the key.
Parameters: key - key whose associated value is to be returned. | public String | getComments(String key) Returns the comments for the property.
Parameters: key - The key used for adding the property. | public String | getProperty(String key) Searches for the property with the specified key in this property list. | public String | getProperty(String key, String defaultValue) Searches for the property with the specified key in this property list. | public int | hashCode() Returns the hash code value for this map. | public boolean | isEmpty() Returns true if this map contains no key-value mappings. | public Set | keySet() Returns a set view of the keys contained in this map. | public Enumeration | keys() Returns an enumeration of the keys in this hashtable. | public void | list(PrintStream out) Prints this property list out to the specified output stream. | public void | list(PrintWriter out) Prints this property list out to the specified output stream. | public void | load(InputStream inStream) Reads a property list (key and element pairs) from the input stream. | public Enumeration | propertyNames() Returns an enumeration of all the keys in this property list, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list. | public Object | put(Object key, Object value) Adds an object to the Map. | public void | putAll(Map t) Copies all of the mappings from the specified map to this map. | public Object | remove(Object key) Removes the mapping for this key from this map if it is present.
The default mappings are not touched.
Parameters: key - key whose mapping is to be removed from the map. | public void | setComments(String key, String comments) Sets the comments for the property. | public Object | setProperty(String key, String value, String comments) Adds a new property, or updates if it already exists.
Parameters: key - The key for the property. Parameters: value - The value for the property. Parameters: comments - The comment for the property. | public Object | setProperty(String key, String value) Adds a new property, or updates if it already exists.
Parameters: key - The key for the property. Parameters: value - The value for the property. | public int | size() Returns the number of key-value mappings in this map. | public void | sort() This sorts the Properties based on the keys. | public void | store(OutputStream out, String header) Writes this property list (key and element pairs) in this Properties table to the output stream.
Properties from the defaults table of this Properties table (if any) are not written out by this method.
After the entries have been written, the output stream is flushed. | public String | toString() Returns debug info. | public Collection | values() Returns a collection view of the values contained in this map. |
ListProperties | public ListProperties()(Code) | | Creates an empty property list with no default values.
|
ListProperties | public ListProperties(Properties defaults)(Code) | | Creates an empty property list with the specified defaults.
Parameters: defaults - The defaults. |
clear | public void clear()(Code) | | Removes all mappings from this map.
The default mappings are not touched.
|
clone | public Object clone()(Code) | | Returns a clone of this object.
a clone of the Map. |
containsKey | public boolean containsKey(Object key)(Code) | | Returns true if this map contains a mapping for the specified key.
The default mappings are not searched for the key.
Parameters: key - key whose presence in this map is to be tested. true if this map contains a mapping for the specified key. |
containsValue | public boolean containsValue(Object value)(Code) | | Returns true if this map maps one or more keys to the specified value.
The default mappings are not searched for the value.
Parameters: value - value whose presence in this map is to be tested. true if this map maps one or more keys to the specified value. |
elements | public Enumeration elements()(Code) | | Returns an enumeration of the values in this hashtable.
Use the Enumeration methods on the returned object to fetch the elements sequentially.
The values from the default mappings are not part of the Enumeration.
an enumeration of the values in this hashtable. |
entrySet | public Set entrySet()(Code) | | Returns a set view of the mappings contained in this map.
The entries from the default mappings are not part of the Set.
a set view of the mappings contained in this map. |
equals | public boolean equals(Object o)(Code) | | Compares the specified object with this map for equality.
Returns true if the given object is also a ListProperties and the two Properties represent the same mappings.
The comments are not compared.
The default mappings are not compared.
Parameters: o - object to be compared for equality with this map. true if the specified object is equal to this map. |
get | public Object get(Object key)(Code) | | Returns the value to which this map maps the specified key.
Returns null if the map contains no mapping for this key.
A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null.
The containsKey operation may be used to distinguish these two cases.
The default mappings are not searched for the key.
Parameters: key - key whose associated value is to be returned. the value to which this map maps the specified key, or null if the map contains no mapping for this key. |
getComments | public String getComments(String key)(Code) | | Returns the comments for the property.
Parameters: key - The key used for adding the property. the comments for the property. |
getProperty | public String getProperty(String key)(Code) | | 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 property key. the value in this property list with the specified key value. |
getProperty | public String getProperty(String key, String defaultValue)(Code) | | 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 property key. Parameters: defaultValue - a default value. the value in this property list with the specified key value. |
hashCode | public int hashCode()(Code) | | Returns the hash code value for this map.
The hashCode will not take into account the comments, if any.
The default mappings do not affect the return value.
the hash code value for this map. |
isEmpty | public boolean isEmpty()(Code) | | Returns true if this map contains no key-value mappings.
The default mappings have no effect on the return value.
true if this map contains no key-value mappings. |
keySet | public Set keySet()(Code) | | Returns a set view of the keys contained in this map.
The keys from the default mappings are not part of the Set.
a set view of the keys contained in this map. |
keys | public Enumeration keys()(Code) | | Returns an enumeration of the keys in this hashtable.
The keys from the default mappings are not part of the Enumeration.
an enumeration of the keys in this hashtable. |
list | public void list(PrintStream out)(Code) | | Prints this property list out to the specified output stream. This method is useful for debugging.
Parameters: out - an output stream. |
list | public void list(PrintWriter out)(Code) | | Prints this property list out to the specified output stream. This method is useful for debugging.
Parameters: out - an output stream. |
load | public void load(InputStream inStream) throws IOException(Code) | | Reads a property list (key and element pairs) from the input stream.
Parameters: inStream - the input stream throws: IOException - if an error occurred when reading from the input stream. |
propertyNames | public Enumeration propertyNames()(Code) | | Returns an enumeration of all the keys in this property list, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.
an enumeration of all the keys in this property list, including the keys in the default property list. |
put | public Object put(Object key, Object value)(Code) | | Adds an object to the Map. If the map previously contained a mapping for this key, the old value is replaced by the specified value.
An IllegalArgumentException is thrown if either of the key and value are not Strings.
Parameters: key - The key used for adding the object. Parameters: value - The object to be added. previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key. |
putAll | public void putAll(Map t)(Code) | | Copies all of the mappings from the specified map to this map.
This will invoke the put() method for each entry from the specified map.
An IllegalArgumentException is thrown if either of the key and value are not Strings.
Parameters: t - Mappings to be stored in this map. |
remove | public Object remove(Object key)(Code) | | Removes the mapping for this key from this map if it is present.
The default mappings are not touched.
Parameters: key - key whose mapping is to be removed from the map. previous value associated with specified key, or null if there was no mapping for key. |
setComments | public void setComments(String key, String comments)(Code) | | Sets the comments for the property.
Nothing will be done, in case there is no existing property for the input key.
Parameters: key - The key used for adding the property. Parameters: comments - The comments for the property. |
setProperty | public Object setProperty(String key, String value, String comments)(Code) | | Adds a new property, or updates if it already exists.
Parameters: key - The key for the property. Parameters: value - The value for the property. Parameters: comments - The comment for the property. the previous value of the specified key in this property list, or null if it did not have one. |
setProperty | public Object setProperty(String key, String value)(Code) | | Adds a new property, or updates if it already exists.
Parameters: key - The key for the property. Parameters: value - The value for the property. the previous value of the specified key in this property list, or null if it did not have one. |
size | public int size()(Code) | | Returns the number of key-value mappings in this map.
The default mappings are not included in the result.
the number of key-value mappings in this map. |
sort | public void sort()(Code) | | This sorts the Properties based on the keys.
|
store | public void store(OutputStream out, String header) throws IOException(Code) | | Writes this property list (key and element pairs) in this Properties table to the output stream.
Properties from the defaults table of this Properties table (if any) are not written out by this method.
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. Parameters: header - a description of the property list. throws: IOException - if writing this property list to the specified output stream throws an IOException. |
toString | public String toString()(Code) | | Returns debug info.
debug info. |
values | public Collection values()(Code) | | Returns a collection view of the values contained in this map.
The values from the default mappings are not part of the Collection.
a collection view of the values contained in this map. |
|
|