Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.devtools.util
Class MultiProperties  view MultiProperties download MultiProperties.java

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended byjava.util.Properties
              extended byorg.devtools.util.MultiProperties
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class MultiProperties
extends java.util.Properties

Behaves like an ordinary java.util.Properties, except that when it encounters multiple properties of the same name, it concatenates them with the separator string. Properties are written out again similarly.

For example, when MultiProperties loads a properties file containing:

myProp = foo
myProp = bar


The MultiProperties will subsequently contain one property whose name is myProp and whose value is foo:bar. (Assuming that the separator string is ":", which is the default.)


Nested Class Summary
 
Nested classes inherited from class java.util.Hashtable
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
private static java.util.Properties appendProp
           
private  org.devtools.util.debug.Debugger D
           
private static java.lang.String file1
          Test files for the main function, which is a test routine.
private static java.util.Properties file1Prop
          Resulting properties, using various methods
private static java.lang.String file2
           
private static java.util.Properties file2Prop
           
private static java.util.Properties noAppendProp
           
 java.lang.String SEP
          The separator symbol to be used when returning multi-value .properties files.
 
Fields inherited from class java.util.Properties
defaults
 
Fields inherited from class java.util.Hashtable
 
Constructor Summary
MultiProperties()
          Constructs a new empty MultiProperties with no defaults that will replace existing properties with loaded ones instead of appending them by default.
MultiProperties(java.util.Properties defaults)
          Constructs a new empty MultiProperties with the given defaults.
 
Method Summary
 void appendValue(java.lang.String key, java.lang.String val)
          Appends the given value to the existing value for the given key, separating the two with SEP.
 boolean equals(java.lang.Object o)
          Returns true if this has the same keys and values as the given Properties object.
 java.util.Enumeration getValues(java.lang.String key)
          Returns an enumeration of all of the values for a given key.
 void load(java.io.InputStream in)
          Merges some properties from the given input stream into this MultiProperties.
 void load(java.io.InputStream in, boolean appendOnLoad)
          Merges some properties from the given input stream into this MultiProperties.
static void main(java.lang.String[] args)
           
 void mergeFrom(java.util.Properties p)
          Merges all of the keys from the given Properties into this one, appending the values of any duplicate keys to the existing values.
 void replaceFrom(java.util.Properties p)
          Merges all of the keys from the given Properties into this one, replacing the values of any duplicate keys with the new values.
protected static boolean test(java.lang.String[] args)
          A testing function
 void writeContents(java.io.PrintStream out)
          Writes a human-readable representation of this MultiProperties to the given print stream.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, loadFromXML, propertyNames, save, setProperty, store, storeToXML, storeToXML
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SEP

public java.lang.String SEP
The separator symbol to be used when returning multi-value .properties files.


file1

private static java.lang.String file1
Test files for the main function, which is a test routine.


file2

private static java.lang.String file2

file1Prop

private static java.util.Properties file1Prop
Resulting properties, using various methods


file2Prop

private static java.util.Properties file2Prop

noAppendProp

private static java.util.Properties noAppendProp

appendProp

private static java.util.Properties appendProp

D

private org.devtools.util.debug.Debugger D
Constructor Detail

MultiProperties

public MultiProperties()
Constructs a new empty MultiProperties with no defaults that will replace existing properties with loaded ones instead of appending them by default.


MultiProperties

public MultiProperties(java.util.Properties defaults)
Constructs a new empty MultiProperties with the given defaults.

Method Detail

appendValue

public void appendValue(java.lang.String key,
                        java.lang.String val)
Appends the given value to the existing value for the given key, separating the two with SEP.


mergeFrom

public void mergeFrom(java.util.Properties p)
Merges all of the keys from the given Properties into this one, appending the values of any duplicate keys to the existing values.


replaceFrom

public void replaceFrom(java.util.Properties p)
Merges all of the keys from the given Properties into this one, replacing the values of any duplicate keys with the new values.


getValues

public java.util.Enumeration getValues(java.lang.String key)
Returns an enumeration of all of the values for a given key.


load

public void load(java.io.InputStream in)
          throws java.io.IOException
Merges some properties from the given input stream into this MultiProperties. If the InputStream duplicates some existing properties, the existing values will be replaced.


load

public void load(java.io.InputStream in,
                 boolean appendOnLoad)
          throws java.io.IOException
Merges some properties from the given input stream into this MultiProperties. If the InputStream duplicates some existing properties and appendOnLoad is true, they will all be appended to the current values of the duplicate properties. If the InputStream duplicates some existing properties and appendOnLoad is false, the existing values will be replaced.


writeContents

public void writeContents(java.io.PrintStream out)
Writes a human-readable representation of this MultiProperties to the given print stream.


equals

public boolean equals(java.lang.Object o)
Returns true if this has the same keys and values as the given Properties object.


main

public static void main(java.lang.String[] args)

test

protected static boolean test(java.lang.String[] args)
A testing function