wt.util
Class PropertiesMap

java.lang.Object
  extended byjava.util.Dictionary
      extended bycom.objectspace.jgl.Map
          extended bycom.objectspace.jgl.OrderedMap
              extended bywt.util.PropertiesMap
All Implemented Interfaces:
Cloneable, com.objectspace.jgl.Container, Serializable

public class PropertiesMap
extends com.objectspace.jgl.OrderedMap

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

What PropertiesMap adds, beyond what java.util.Properties provides, is the ability to have multiple entries with the same key.

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

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

// add new entry registry.add( "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, "List of class names and their respective package names" ); fileOutput.close();

See Also:
Properties, ClassPathRepository, MappedRegistry, Serialized Form

Field Summary
private static String versionID
           
 
Fields inherited from class com.objectspace.jgl.OrderedMap
 
Constructor Summary
PropertiesMap()
          Construct myself to be an empty PropertiesMap that orders its keys based on the LessString comparator and does not allow duplicates.
PropertiesMap(com.objectspace.jgl.BinaryPredicate comparator)
          Construct myself to be an empty PropertiesMap that orders its keys using a specified binary predicate and does not allow duplicates.
PropertiesMap(com.objectspace.jgl.BinaryPredicate comparator, boolean allowDuplicates)
          Construct myself to be an empty PropertiesMap that orders its keys using a specified binary predicate and conditionally allows duplicates.
PropertiesMap(boolean allowDuplicates)
          Construct myself to be an empty PropertiesMap that orders its keys based on the LessString comparator and conditionally allows duplicates.
PropertiesMap(PropertiesMap map)
          Construct myself to be a shallow copy of an existing PropertiesMap.
 
Method Summary
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 PropertiesMap with the values from the Reader.
protected  void load(StreamTokenizer tokenStream)
          Loads the PropertiesMap with the values from the StreamTokenizer.
 void save(PrintWriter output, String header)
          Saves the key/value pairs of the PropertiesMap to the PrintWriter.
 
Methods inherited from class com.objectspace.jgl.OrderedMap
add, add, allowsDuplicates, begin, clear, clone, copy, count, countValues, elements, end, equalRange, equals, equals, find, finish, get, getComparator, hashCode, isEmpty, keys, keys, lowerBound, maxSize, put, remove, remove, remove, remove, size, start, swap, toString, upperBound, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

versionID

private static final String versionID
See Also:
Constant Field Values
Constructor Detail

PropertiesMap

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


PropertiesMap

public PropertiesMap(com.objectspace.jgl.BinaryPredicate comparator)
Construct myself to be an empty PropertiesMap that orders its keys using a specified binary predicate and does not allow duplicates.

Parameters:
comparator - The predicate for ordering keys.

PropertiesMap

public PropertiesMap(com.objectspace.jgl.BinaryPredicate comparator,
                     boolean allowDuplicates)
Construct myself to be an empty PropertiesMap that orders its keys using a specified binary predicate and conditionally allows duplicates.

Parameters:
comparator - The predicate for ordering keys.
allowDuplicates - true if duplicates are allowed.

PropertiesMap

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

Parameters:
map - The PropertiesMap to copy.

PropertiesMap

public PropertiesMap(boolean allowDuplicates)
Construct myself to be an empty PropertiesMap that orders its keys based on the LessString comparator and conditionally allows duplicates.

Parameters:
allowDuplicates - true if duplicates are allowed.
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 PropertiesMap 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 PropertiesMap 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 PropertiesMap with the values from the StreamTokenizer.

Throws:
IOException

save

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

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