Oracle

com.compoze.util
Class ObjectProperties

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.compoze.util.ObjectProperties
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>
Direct Known Subclasses:
MutableProperties

public class ObjectProperties
extends java.util.Properties
implements java.io.Serializable

This class extends the Java Properties class to provide get methods for primitive types and objects to the properties file.

See Also:
Properties, Serialized Form

Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
ObjectProperties()
          Constructor.
ObjectProperties(java.util.Properties defaults)
          Constructor.
 
Method Summary
 boolean getBoolean(java.lang.String sKey)
          Get the property as a boolean.
 boolean getBoolean(java.lang.String sKey, boolean bDefault)
          Get the property as a boolean.
 byte getByte(java.lang.String sKey)
          Get the property as a byte.
 byte getByte(java.lang.String sKey, byte yDefault)
          Get the property as a byte.
 double getDouble(java.lang.String sKey)
          Get the property as a double.
 double getDouble(java.lang.String sKey, double dDefault)
          Get the property as a double.
 float getFloat(java.lang.String sKey)
          Get the property as a float.
 float getFloat(java.lang.String sKey, float fDefault)
          Get the property as a float.
 int getInt(java.lang.String sKey)
          Get the property as an int.
 int getInt(java.lang.String sKey, int iDefault)
          Get the property as an int.
 long getLong(java.lang.String sKey)
          Get the property as a long.
 long getLong(java.lang.String sKey, long lDefault)
          Get the property as a long.
 java.lang.String getProperty(java.lang.String sKey)
          Get a property, replacing keys inside ${} with other property values or system property values.
 java.lang.String getProperty(java.lang.String sKey, java.lang.String sDefault)
          Get a property, replacing keys inside ${} with other property values or system property values.
 short getShort(java.lang.String sKey)
          Get the property as a short.
 short getShort(java.lang.String sKey, short sDefault)
          Get the property as a short.
 java.lang.String getString(java.lang.String sKey)
          Get the property as a string.
 java.lang.String getString(java.lang.String sKey, java.lang.String sDefault)
          Get the property as a string.
 java.lang.String[] getStringArray(java.lang.String sKey)
          Get the property as a string array (elements of the array are tokenized values).
 java.lang.String[] getStringArray(java.lang.String sKey, java.lang.String sDelimiter)
          Get the property as a string array (elements of the array are tokenized values).
 java.lang.String[] getStringArray(java.lang.String sKey, java.lang.String sDelimiter, java.lang.String sDefault)
          Get the property as a string.
 java.lang.String replaceSubstitutions(java.lang.String sRawValue)
          Replace substitutions in a string with their substituted properties.
 
Methods inherited from class java.util.Properties
list, list, load, loadFromXML, propertyNames, save, setProperty, store, storeToXML, storeToXML
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, 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
 

Constructor Detail

ObjectProperties

public ObjectProperties()
Constructor.


ObjectProperties

public ObjectProperties(java.util.Properties defaults)
Constructor.

Parameters:
defaults - default properties
Method Detail

getBoolean

public boolean getBoolean(java.lang.String sKey)
Get the property as a boolean.

Parameters:
sKey - the property key
Returns:
the property as a boolean

getBoolean

public boolean getBoolean(java.lang.String sKey,
                          boolean bDefault)
Get the property as a boolean.

Parameters:
sKey - the property key
bDefault - the default value to return if key is not found
Returns:
the property as a boolean, or the default value

getByte

public byte getByte(java.lang.String sKey)
Get the property as a byte.

Parameters:
sKey - the property key
Returns:
the property as a byte
Throws:
java.lang.NumberFormatException - if the byte could not be parsed

getByte

public byte getByte(java.lang.String sKey,
                    byte yDefault)
Get the property as a byte.

Parameters:
sKey - the property key
yDefault - the default value to return if key is not found
Returns:
the property as a byte, or the default value
Throws:
java.lang.NumberFormatException - if the byte could not be parsed

getShort

public short getShort(java.lang.String sKey)
Get the property as a short.

Parameters:
sKey - the property key
Returns:
the property as a short
Throws:
java.lang.NumberFormatException - if the short could not be parsed

getShort

public short getShort(java.lang.String sKey,
                      short sDefault)
Get the property as a short.

Parameters:
sKey - the property key
sDefault - the default value to return if key is not found
Returns:
the property as a short, or the default value
Throws:
java.lang.NumberFormatException - if the short could not be parsed

getInt

public int getInt(java.lang.String sKey)
Get the property as an int.

Parameters:
sKey - the property key
Returns:
the property as an int
Throws:
java.lang.NumberFormatException - if the int could not be parsed

getInt

public int getInt(java.lang.String sKey,
                  int iDefault)
Get the property as an int.

Parameters:
sKey - the property key
iDefault - the default value to return if key is not found
Returns:
the property as an int, or the default value
Throws:
java.lang.NumberFormatException - if the int could not be parsed

getLong

public long getLong(java.lang.String sKey)
Get the property as a long.

Parameters:
sKey - the property key
Returns:
the property as a long
Throws:
java.lang.NumberFormatException - if the long could not be parsed

getLong

public long getLong(java.lang.String sKey,
                    long lDefault)
Get the property as a long.

Parameters:
sKey - the property key
lDefault - the default value to return if key is not found
Returns:
the property as a long, or the default value
Throws:
java.lang.NumberFormatException - if the long could not be parsed

getFloat

public float getFloat(java.lang.String sKey)
Get the property as a float.

Parameters:
sKey - the property key
Returns:
the property as a float
Throws:
java.lang.NumberFormatException - if the float could not be parsed

getFloat

public float getFloat(java.lang.String sKey,
                      float fDefault)
Get the property as a float.

Parameters:
sKey - the property key
fDefault - the default value to return if key is not found
Returns:
the property as a float, or the default value
Throws:
java.lang.NumberFormatException - if the float could not be parsed

getDouble

public double getDouble(java.lang.String sKey)
Get the property as a double.

Parameters:
sKey - the property key
Returns:
the property as a double
Throws:
java.lang.NumberFormatException - if the double could not be parsed

getDouble

public double getDouble(java.lang.String sKey,
                        double dDefault)
Get the property as a double.

Parameters:
sKey - the property key
dDefault - the default value to return if key is not found
Returns:
the property as a double, or the default value
Throws:
java.lang.NumberFormatException - if the double could not be parsed

getString

public java.lang.String getString(java.lang.String sKey)
Get the property as a string.

Parameters:
sKey - the property key
Returns:
the property as a string

getString

public java.lang.String getString(java.lang.String sKey,
                                  java.lang.String sDefault)
Get the property as a string.

Parameters:
sKey - the property key
sDefault - the default value to return if key is not found
Returns:
the property as a string, or the default value

getStringArray

public java.lang.String[] getStringArray(java.lang.String sKey)
Get the property as a string array (elements of the array are tokenized values). The comma character is used as the delimiter.

Parameters:
sKey - the property key
Returns:
the property or default value as a string array

getStringArray

public java.lang.String[] getStringArray(java.lang.String sKey,
                                         java.lang.String sDelimiter)
Get the property as a string array (elements of the array are tokenized values).

Parameters:
sKey - the property key
sDelimiter - the token delimiter
Returns:
the property or default value as a string array

getStringArray

public java.lang.String[] getStringArray(java.lang.String sKey,
                                         java.lang.String sDelimiter,
                                         java.lang.String sDefault)
Get the property as a string.

Parameters:
sKey - the property key
sDelimiter - the token delimiter
sDefault - the default value to use if key is not found
Returns:
the property or default value as a string array

getProperty

public java.lang.String getProperty(java.lang.String sKey)
Get a property, replacing keys inside ${} with other property values or system property values.

Overrides:
getProperty in class java.util.Properties
Parameters:
sKey - the property key to look for
Returns:
the property

getProperty

public java.lang.String getProperty(java.lang.String sKey,
                                    java.lang.String sDefault)
Get a property, replacing keys inside ${} with other property values or system property values.

Overrides:
getProperty in class java.util.Properties
Parameters:
sKey - the property key to look for
sDefault - the default value if the specified key was not found
Returns:
the property, or the default value

replaceSubstitutions

public java.lang.String replaceSubstitutions(java.lang.String sRawValue)
Replace substitutions in a string with their substituted properties.

Parameters:
sRawValue - the raw value
Returns:
the string with substitutions made

Oracle

Copyright ©1999-2008 Oracle All rights reserved.