com.tivoli.twg.libs
Class CommentedProperties

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended byjava.util.Properties
              extended bycom.tivoli.twg.libs.CommentedProperties
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class CommentedProperties
extends java.util.Properties

Subclass of standard java.util.Properties class, with support for preserving comments and order of properties.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
CommentedProperties()
          Creates an empty property list with no default values.
CommentedProperties(java.util.Properties defaults)
          Creates an empty property list with the specified defaults.
 
Method Summary
 boolean addKeyComment(java.lang.String key, java.lang.String comment)
          Add comment for given property key
 void clear()
          Clear all elements
 void load(java.io.InputStream instr)
          Reads a property list from an input stream.
 void load(java.io.InputStream instr, boolean allowBlanksInKey)
          Reads a property list from an input stream.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Add or update element into set
 java.lang.Object remove(java.lang.Object key)
          Remove element with given key value
 void store(java.io.OutputStream out, java.lang.String header)
          Stores this property list to the specified output stream.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, propertyNames, save, setProperty
 
Methods inherited from class java.util.Hashtable
clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, putAll, rehash, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CommentedProperties

public CommentedProperties()
Creates an empty property list with no default values.


CommentedProperties

public CommentedProperties(java.util.Properties defaults)
Creates an empty property list with the specified defaults.

Parameters:
defaults - the defaults.
Method Detail

load

public void load(java.io.InputStream instr)
          throws java.io.IOException
Reads a property list from an input stream.

Parameters:
instr - the input stream.
Throws:
java.io.IOException - if an error occurred when reading from the input stream.

load

public void load(java.io.InputStream instr,
                 boolean allowBlanksInKey)
          throws java.io.IOException
Reads a property list from an input stream.

Parameters:
instr - the input stream.
allowBlanksInKey -
Throws:
java.io.IOException - if an error occurred when reading from the input stream.

store

public void store(java.io.OutputStream out,
                  java.lang.String header)
           throws java.io.IOException
Stores this property list to the specified output stream. The string header is printed as a comment at the beginning of the stream.

Parameters:
out - an output stream.
header - a description of the property list.
Throws:
java.io.IOException

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Add or update element into set

Parameters:
key - - key value
value - - value associated with key
Returns:
previous value, or null if none

remove

public java.lang.Object remove(java.lang.Object key)
Remove element with given key value

Parameters:
key - - key value
Returns:
object found, or null if not found

clear

public void clear()
Clear all elements


addKeyComment

public boolean addKeyComment(java.lang.String key,
                             java.lang.String comment)
Add comment for given property key

Parameters:
key - - key value
comment - - comment string
Returns:
true if added, false if property not found