planet.util
Class PropertiesWrapper

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended byjava.util.Properties
              extended byplanet.util.PropertiesWrapper
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class PropertiesWrapper
extends java.util.Properties

Author:
Jordi Pujol 05-jul-2005
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
PropertiesWrapper()
           
 
Method Summary
 boolean getPropertyAsBoolean(java.lang.String key)
          Gets the related value for the key key as a boolean value.
 java.lang.Class getPropertyAsClass(java.lang.String key)
          Gets the related value for the key key as a Class reference.
 double getPropertyAsDouble(java.lang.String key)
          Gets the related value for the key key as a double value.
 int getPropertyAsInt(java.lang.String key)
          Gets the related value for the key key as an int value.
static boolean getValueAsBoolean(java.lang.String value, java.lang.String propertyName)
          Gets the value as a boolean value.
static java.lang.Class getValueAsClass(java.lang.String value, java.lang.String propertyName)
          Obtain the Class reference from the related value.
static double getValueAsDouble(java.lang.String value, java.lang.String propertyName)
          Obtain the double value from the related value.
static int getValueAsInt(java.lang.String value, java.lang.String propertyName)
          Loads the value for the propertyName as an int value.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, propertyNames, save, setProperty, store
 
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

PropertiesWrapper

public PropertiesWrapper()
Method Detail

getPropertyAsBoolean

public boolean getPropertyAsBoolean(java.lang.String key)
Gets the related value for the key key as a boolean value.

Parameters:
key - Key to be found in this properties.
Returns:
The associated value for the key as a boolean value.

getPropertyAsClass

public java.lang.Class getPropertyAsClass(java.lang.String key)
                                   throws InitializationException
Gets the related value for the key key as a Class reference.

Parameters:
key - Key to be found in this properies.
Returns:
The associated value for the key as a Class reference.
Throws:
InitializationException - if occurs any error during the loading process.

getPropertyAsDouble

public double getPropertyAsDouble(java.lang.String key)
                           throws InitializationException
Gets the related value for the key key as a double value.

Parameters:
key - Key to be found in this properies.
Returns:
The associated value for the key as a double value.
Throws:
InitializationException - if occurs any error during the loading process.

getPropertyAsInt

public int getPropertyAsInt(java.lang.String key)
                     throws InitializationException
Gets the related value for the key key as an int value.

Parameters:
key - Key to be found in this properties.
Returns:
The associated value for the key as an int value.
Throws:
InitializationException - if occurs any error during the loading process.

getValueAsBoolean

public static boolean getValueAsBoolean(java.lang.String value,
                                        java.lang.String propertyName)
Gets the value as a boolean value. It uses the planet.util.Utilities.parseBoolean() method.

Parameters:
value - Value to be converted as a boolean.
propertyName - Name of the related property (for logging purposes).
Returns:
The boolean value for the value
See Also:
Utilities.parseBoolean(java.lang.String)

getValueAsClass

public static java.lang.Class getValueAsClass(java.lang.String value,
                                              java.lang.String propertyName)
                                       throws InitializationException
Obtain the Class reference from the related value.

Parameters:
value - Name of the class to get its reference.
propertyName - Name of the related property (for logging purposes).
Returns:
The Class reference for the value
Throws:
InitializationException - if any error has ocurred during the loading process.

getValueAsDouble

public static double getValueAsDouble(java.lang.String value,
                                      java.lang.String propertyName)
                               throws InitializationException
Obtain the double value from the related value.

Parameters:
value - A double value in string format.
propertyName - Name of the related property (for loggin purposes).
Returns:
The double value for the value.
Throws:
InitializationException - if any error occurs during the loading process.

getValueAsInt

public static int getValueAsInt(java.lang.String value,
                                java.lang.String propertyName)
                         throws InitializationException
Loads the value for the propertyName as an int value. It uses the java.lang.Integer.parseInt() method.

Parameters:
value - An int value in decimal format.
propertyName - Name of the related property (for logging purposes).
Returns:
The related int value.
Throws:
InitializationException - if appears a no numerical expression.
See Also:
Integer.parseInt(java.lang.String)