wt.sysadm
Class PropertyMap

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended bywt.sysadm.PropertyMap
All Implemented Interfaces:
Cloneable, Map, Serializable

public class PropertyMap
extends HashMap

PropertyMap is an extension of a HashMap, which adds the ability to load and save the values of a Map, to a stream, similar to java.util.Properties.

What PropertyMap adds, beyond what java.util.Properties provides, is the ability to have multiple entries with the same key. It also adds the ability to print the data in same order as read from the original file. Any changes made are such that only the last occurance of the property is modified.

The following is an example of how PropertyMap could be used:

    // load properties from a file
    FileReader fileInput = new FileReader( "c:\temp\my.properties" );
    PropertyMap registry = new PropertyMap( );
    registry.load( fileInput );
    fileInput.close();

// add new entry registry.put( "String", "java.lang" );

// re-write the properties back to the file PrintWriter fileOutput = new PrintWriter( new FileWriter( "c:\temp\my.properties", false ), true ); registry.save( fileOutput, "Name of user saving the changes" ); fileOutput.close();

See Also:
Properties, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.HashMap
 
Nested classes inherited from class java.util.AbstractMap
 
Field Summary
private  LinkedList all
           
private  LinkedList defaultll
           
private  LinkedList dll
           
private  LinkedList ll
           
private  LinkedList ull
           
 
Fields inherited from class java.util.HashMap
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
PropertyMap()
          Construct myself to be an empty PropertyMap that orders its keys based on the LessString comparator and does not allow duplicates.
PropertyMap(PropertyMap map)
          Construct myself to be a shallow copy of an existing PropertyMap.
 
Method Summary
 void add(String key, String value)
           
 void change(String key, String value)
           
 void changeAdd(String key, String value)
           
 void changeDefault(String key, String value)
           
 void changeDel(String key, String value)
           
private  StreamTokenizer getTokenStream(InputStream input)
           
private  StreamTokenizer getTokenStream(Reader input)
           
 void load(InputStream input)
          Deprecated. Replaced by load(Reader)
 void load(Reader input)
          Loads the PropertyMap with the values from the Reader.
protected  void load(StreamTokenizer tokenStream)
          Loads the PropertyMap with the values from the StreamTokenizer.
static void main(String[] args)
           
 void save(PrintWriter output, String header)
          Saves the key/value pairs of the PropertyMap to the PrintWriter.
 void saveSiteXConfFile(String wt_home, String propFile)
           
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

ll

private LinkedList ll

all

private LinkedList all

dll

private LinkedList dll

ull

private LinkedList ull

defaultll

private LinkedList defaultll
Constructor Detail

PropertyMap

public PropertyMap()
Construct myself to be an empty PropertyMap that orders its keys based on the LessString comparator and does not allow duplicates.


PropertyMap

public PropertyMap(PropertyMap map)
Construct myself to be a shallow copy of an existing PropertyMap.

Parameters:
map - The PropertyMap to copy.
Method Detail

getTokenStream

private StreamTokenizer getTokenStream(InputStream input)

getTokenStream

private StreamTokenizer getTokenStream(Reader input)

load

public void load(InputStream input)
          throws IOException
Deprecated. Replaced by load(Reader)

Loads the PropertyMap with the values from the InputStream.

Parameters:
input - the InputStream from which values will be loaded
Throws:
IOException
See Also:
load(Reader)

load

public void load(Reader input)
          throws IOException
Loads the PropertyMap with the values from the Reader.

Parameters:
input - the Reader from which values will be loaded
Throws:
IOException

load

protected void load(StreamTokenizer tokenStream)
             throws IOException
Loads the PropertyMap with the values from the StreamTokenizer.

Throws:
IOException

save

public void save(PrintWriter output,
                 String header)
Saves the key/value pairs of the PropertyMap to the PrintWriter.

Parameters:
header - optional header to be written as the first line of output

change

public void change(String key,
                   String value)

changeDel

public void changeDel(String key,
                      String value)

changeAdd

public void changeAdd(String key,
                      String value)

add

public void add(String key,
                String value)

changeDefault

public void changeDefault(String key,
                          String value)

saveSiteXConfFile

public void saveSiteXConfFile(String wt_home,
                              String propFile)

main

public static void main(String[] args)