jstorm.util
Class PropertyLoader

java.lang.Object
  |
  +--jstorm.util.PropertyLoader

public class PropertyLoader
extends java.lang.Object

Very useful class for loading and accessing application level properties.

PropertyLoader will load properties from a file in the CLASSPATH using a java.util.ResourceBundle. The name of the property file can be specified with a system property, for example:
java -D lante.properties.file=test ClassName

The '-D' flag loads a value into the System Properties, in this case the value test is being loaded with the key lante.properties.file.

In this example, PropertyLoader will look for a file called test.properties.


Field Summary
static java.util.ResourceBundle bundle
           
 
Constructor Summary
PropertyLoader()
           
 
Method Summary
static boolean getBooleanProperty(java.lang.String key, boolean defaultValue)
          Converts the String value into a boolean type.
static java.lang.Class getClassProperty(java.lang.String key, java.lang.Class defaultValue)
          Converts the String value into a Class using Class.forName().
static float getFloatProperty(java.lang.String key, float defaultValue)
          Convert the string property value into a Float.
static int getIntProperty(java.lang.String key, int defaultValue)
          Convert the string property value into a int.
static long getLongProperty(java.lang.String key, long defaultValue)
          Convert the string property value into a long.
static java.lang.String getProperty(java.lang.String key)
          Get a property, returns null if the property is not found.
WARNING: Please use the methods with default values to ensure that a non null value is returned.
static java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Get a string property.
static java.util.Enumeration getPropertyNames()
          Returns an enumeration of all the key values in this ProperyLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bundle

public static java.util.ResourceBundle bundle
Constructor Detail

PropertyLoader

public PropertyLoader()
Method Detail

getBooleanProperty

public static boolean getBooleanProperty(java.lang.String key,
                                         boolean defaultValue)
Converts the String value into a boolean type. Returns default if the property does not exist.

getClassProperty

public static java.lang.Class getClassProperty(java.lang.String key,
                                               java.lang.Class defaultValue)
Converts the String value into a Class using Class.forName(). Returns the defualt value if the property can't be found or the value can't be converted into a Class.

getFloatProperty

public static float getFloatProperty(java.lang.String key,
                                     float defaultValue)
Convert the string property value into a Float. Returns the default value if the property is not found or if there is a problem converting the value to a Float.

getIntProperty

public static int getIntProperty(java.lang.String key,
                                 int defaultValue)
Convert the string property value into a int. Returns the default value if the property is not found or if there is a problem converting the value to a int.

getLongProperty

public static long getLongProperty(java.lang.String key,
                                   long defaultValue)
Convert the string property value into a long. Returns the default value if the property is not found or if there is a problem converting the value to a long.

getProperty

public static java.lang.String getProperty(java.lang.String key)
Get a property, returns null if the property is not found.
WARNING: Please use the methods with default values to ensure that a non null value is returned.

getProperty

public static java.lang.String getProperty(java.lang.String key,
                                           java.lang.String defaultValue)
Get a string property.

getPropertyNames

public static java.util.Enumeration getPropertyNames()
Returns an enumeration of all the key values in this ProperyLoader