uk.me.parabola.util
Class EnhancedProperties

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 uk.me.parabola.util.EnhancedProperties
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class EnhancedProperties
extends java.util.Properties

Wrapper that behaves as an enhanced properties class that has getProperty calls for different data types.

Author:
Steve Ratcliffe
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
EnhancedProperties()
           
EnhancedProperties(java.util.Properties defaults)
           
 
Method Summary
 boolean getProperty(java.lang.String key, boolean def)
          Get a property as a boolean value.
 double getProperty(java.lang.String key, double def)
          Return a property as a double value.
 int getProperty(java.lang.String key, int def)
          Get a property as an integer value.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
 
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

EnhancedProperties

public EnhancedProperties()

EnhancedProperties

public EnhancedProperties(java.util.Properties defaults)
Method Detail

getProperty

public int getProperty(java.lang.String key,
                       int def)
Get a property as an integer value. If the property does not exist or the value is not a valid integer, then the default value is returned instead.

Parameters:
key - The property name to retrieve.
def - The Default value to use if the property does not exist or if the value is not a valid integer.
Returns:
The value of the property as an integer, or the default value.

getProperty

public boolean getProperty(java.lang.String key,
                           boolean def)
Get a property as a boolean value. If the value of the property begins with a '1', a 'y' or a 't' (for 1, yes, true) then true is returned. If the property does not exist then the given default value is returned.

Parameters:
key - The property name to get.
def - The default value that is returned if property does not exist.
Returns:
The value of the property as a boolean. If the property does not exist then the value of 'def'.

getProperty

public double getProperty(java.lang.String key,
                          double def)
Return a property as a double value. If the property does not exist or is not a valid double, then the given default value is returned instead.

Parameters:
key - The property name.
def - The default value to return if no valid value.
Returns:
The value of the property as a double.