iaik.utils
Class ExtendedProperties

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
                    |
                    +--iaik.utils.ExtendedProperties

public class ExtendedProperties
extends java.util.Properties

An enhanced property class. This class extends the basic properties class of Java, by providing type conversion and support for multiple values per key. Note that in difference to the JDK Properties class property names are case insensitive!

See Also:
Serialized Form

Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
ExtendedProperties()
           
ExtendedProperties(java.util.Properties props)
          supported for interface compatibility to java.util.Properties only, default properties are not supported.
 
Method Summary
 java.lang.Object get(java.lang.Object key)
          Internal use only, public for compatibility to Hashtable only.
 boolean getBoolean(java.lang.String name, boolean def)
          Get this property value, as a boolean.
 double getDouble(java.lang.String name, double def)
          Get this property value, as a double.
 java.io.File getFile(java.lang.String name, java.io.File def)
          Get this property value, as a File.
 int getInteger(java.lang.String name, int def)
          Get this property value, as an integer.
 java.lang.Object[] getObjectArray(java.lang.String name, java.lang.Object[] def)
          Get this property as an Object array.
 java.lang.String getProperty(java.lang.String key)
           
 java.lang.String getProperty(java.lang.String key, java.lang.String def)
           
 java.lang.String getString(java.lang.String name, java.lang.String def)
          Get this property value, as a String.
 java.lang.String[] getStringArray(java.lang.String name, java.lang.String[] def)
          Get this property as a String array.
 void load(java.io.InputStream in)
          Reads a property list from an input stream.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Maps the specified key to the specified value in this hashtable.
 void save(java.io.OutputStream out, java.lang.String header)
           
 void store(java.io.OutputStream out, java.lang.String header)
           
 
Methods inherited from class java.util.Properties
list, list, propertyNames, setProperty
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, hashCode, isEmpty, keys, keySet, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExtendedProperties

public ExtendedProperties()

ExtendedProperties

public ExtendedProperties(java.util.Properties props)
supported for interface compatibility to java.util.Properties only, default properties are not supported.
Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null.

This method allows to add serveral values for one key. In this case an array is returned.

Overrides:
put in class java.util.Hashtable
Parameters:
key - the hashtable key
value - the value
Returns:
the new value of the specified key in this hashtable

get

public java.lang.Object get(java.lang.Object key)
Internal use only, public for compatibility to Hashtable only.
Overrides:
get in class java.util.Hashtable

getBoolean

public boolean getBoolean(java.lang.String name,
                          boolean def)
Get this property value, as a boolean.
Parameters:
name - the name of the property to be fetched
def - the default value, if the property isn't defined
Returns:
a boolean

getString

public java.lang.String getString(java.lang.String name,
                                  java.lang.String def)
Get this property value, as a String.
Parameters:
name - the name of the property to be fetched
def - the default value, if the property isn't defined
Returns:
a String

getStringArray

public java.lang.String[] getStringArray(java.lang.String name,
                                         java.lang.String[] def)
Get this property as a String array.
Parameters:
name - the property's name
def - the default value (if undefined)
Returns:
a String array, or null if the property is undefined.

getObjectArray

public java.lang.Object[] getObjectArray(java.lang.String name,
                                         java.lang.Object[] def)
Get this property as an Object array.
Parameters:
name - the property's name
def - the default value (if undefined)
Returns:
a String array, or null if the property is undefined.

getInteger

public int getInteger(java.lang.String name,
                      int def)
Get this property value, as an integer. If the value starts with "0x" or with "#" the string is interpreted as a hex number.
Parameters:
name - the name of the property to be fetched
def - the default value, if the property isn't defined
Returns:
a integer value

getDouble

public double getDouble(java.lang.String name,
                        double def)
Get this property value, as a double.
Parameters:
name - the name of the property
def - the default value if undefined
Returns:
a double value

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String def)
Overrides:
getProperty in class java.util.Properties

getProperty

public java.lang.String getProperty(java.lang.String key)
Overrides:
getProperty in class java.util.Properties

getFile

public java.io.File getFile(java.lang.String name,
                            java.io.File def)
Get this property value, as a File.
Parameters:
name - the name of the property to be fetched
def - the default value, if the property isn't defined
Returns:
an instance of File

load

public void load(java.io.InputStream in)
          throws java.io.IOException
Reads a property list from an input stream.
Overrides:
load in class java.util.Properties
Parameters:
in - the input stream
Throws:
java.io.IOException - if an error occurred when reading from the input stream

save

public void save(java.io.OutputStream out,
                 java.lang.String header)
Overrides:
save in class java.util.Properties

store

public void store(java.io.OutputStream out,
                  java.lang.String header)
           throws java.io.IOException
Overrides:
store in class java.util.Properties