com.scooterframework.common.util
Class OrderedProperties

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<java.lang.Object,java.lang.Object>
          extended by java.util.Properties
              extended by com.scooterframework.common.util.OrderedProperties
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class OrderedProperties
extends java.util.Properties

The OrderedProperties class extends Properties class. The order of properties are preserved.

See Also:
Serialized Form

Field Summary
protected  java.util.List<java.lang.Object> keys
          Holder of keys.
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
OrderedProperties()
          Creates an empty property list with no default values.
OrderedProperties(java.util.Properties defaults)
          Creates an empty property list with the specified defaults.
 
Method Summary
 void clear()
          Clears this property so that it contains no keys.
 boolean equals(java.lang.Object obj)
           
 int hashCode()
           
 java.util.Iterator<java.lang.Object> keyIterator()
          Returns an iterator of keys.
 java.util.List<java.lang.Object> keyList()
          Returns a list of keys.
 java.util.Enumeration<java.lang.Object> keys()
          Returns an enumeration of keys.
 void load(java.io.InputStream inStream)
          Reads a property list (key and element pairs) from an input stream with "utf-8" encoding.
 void load(java.io.InputStream is, java.lang.String encoding)
          Reads a property list (key and element pairs) from an input stream.
 java.util.Enumeration<java.lang.Object> propertyNames()
          Returns an enumeration of all the keys in this property list.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           Maps the specified key to the specified value in this ordered properties.
 java.lang.Object setProperty(java.lang.String key, java.lang.String value)
          Calls the OrderedProperties method put.
 void store(java.io.OutputStream os, java.lang.String header)
          Writes a property list (key and element pairs) to an output stream with "utf-8" encoding.
 void store(java.io.OutputStream os, java.lang.String header, java.lang.String encoding)
          Writes a property list (key and element pairs) to an output stream.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, loadFromXML, save, storeToXML, storeToXML
 
Methods inherited from class java.util.Hashtable
clone, contains, containsKey, containsValue, elements, entrySet, get, isEmpty, keySet, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

keys

protected java.util.List<java.lang.Object> keys
Holder of keys.

Constructor Detail

OrderedProperties

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


OrderedProperties

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

Parameters:
defaults - the defaults.
Method Detail

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
hashCode in class java.util.Hashtable<java.lang.Object,java.lang.Object>

equals

public boolean equals(java.lang.Object obj)
Specified by:
equals in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
equals in class java.util.Hashtable<java.lang.Object,java.lang.Object>

keys

public java.util.Enumeration<java.lang.Object> keys()
Returns an enumeration of keys.

Overrides:
keys in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Returns:
an enumeration of keys.

keyIterator

public java.util.Iterator<java.lang.Object> keyIterator()
Returns an iterator of keys.

Returns:
an iterator of keys.

keyList

public java.util.List<java.lang.Object> keyList()
Returns a list of keys.

Returns:
a list of keys.

load

public void load(java.io.InputStream inStream)
          throws java.io.IOException
Reads a property list (key and element pairs) from an input stream with "utf-8" encoding.

The input stream remains open after this method returns.

Overrides:
load in class java.util.Properties
Parameters:
inStream - an input stream.
Throws:
java.io.IOException - if an error occurred when reading from the input stream.

load

public void load(java.io.InputStream is,
                 java.lang.String encoding)
          throws java.io.IOException
Reads a property list (key and element pairs) from an input stream.

The input stream remains open after this method returns.

Parameters:
is - an input stream.
encoding - a character encoding scheme.
Throws:
java.io.IOException - if an error occurred when reading from the input stream.

store

public void store(java.io.OutputStream os,
                  java.lang.String header)
           throws java.io.IOException
Writes a property list (key and element pairs) to an output stream with "utf-8" encoding.

The output stream remains open after this method returns.

Overrides:
store in class java.util.Properties
Parameters:
os - an output stream.
header - a description of the property list.
Throws:
java.io.IOException - if an error occurred when writing to the output stream.

store

public void store(java.io.OutputStream os,
                  java.lang.String header,
                  java.lang.String encoding)
           throws java.io.IOException
Writes a property list (key and element pairs) to an output stream.

The output stream remains open after this method returns.

Parameters:
os - an output stream.
header - a description of the property list.
encoding - a character encoding scheme.
Throws:
java.io.IOException - if an error occurred when writing to the output stream.

propertyNames

public java.util.Enumeration<java.lang.Object> propertyNames()
Returns an enumeration of all the keys in this property list. The names are in the same order as they are added to the property. The value returned is the result of the OrderedProperties call to keys.

Overrides:
propertyNames in class java.util.Properties
Returns:
an enumeration of all the keys in this property list.

setProperty

public java.lang.Object setProperty(java.lang.String key,
                                    java.lang.String value)
Calls the OrderedProperties method put. Provided for parallelism with the getProperty method. Enforces use of strings for property keys and values. The value returned is the result of the OrderedProperties call to put.

Overrides:
setProperty in class java.util.Properties
Parameters:
key - the key to be placed into this property list.
value - the value corresponding to key.
Returns:
the previous value of the specified key in this property list, or null if it did not have one.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)

Maps the specified key to the specified value in this ordered properties. Neither the key nor the value can be null.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Specified by:
put in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
put in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Parameters:
key - a key.
value - a value.
Returns:
the previous value of the specified key in this properties, or null if it did not have one.
Throws:
java.lang.NullPointerException - if the key or value is null.
See Also:
Object.equals(Object), Hashtable.get(Object)

clear

public void clear()
Clears this property so that it contains no keys.

Specified by:
clear in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
clear in class java.util.Hashtable<java.lang.Object,java.lang.Object>