org.jlf.util
Class AppProperties

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
                    |
                    +--org.jlf.util.AppProperties
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable
Direct Known Subclasses:
DataLocationProperties, VitalSignProperties, WorkflowProperties

public class AppProperties
extends java.util.Properties

AppProperties provides utilities to access property files. It is both a concrete class to retrieve property file settings from the main property file, but also an extensible class for getting settings from your own property file (subclass it, create your own singleton, and change the property file name).

See Also:
Properties, Serialized Form

Field Summary
protected static java.lang.String PROPERTY_FILE_COMPONENT_VERSION_PREFIX
          The prefix in the property file for all component versions.
protected  java.lang.String propertyFileName
          Holds the file name of the property file.
protected static AppProperties singleton
          Provides the class variable for the Singleton pattern, to keep track of the one and only instance of this class.
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
protected AppProperties()
          Protect the default constructor, this class uses a Singleton pattern.
  AppProperties(java.util.Properties properties)
          Constructor which populates the current object with the properties give.
  AppProperties(java.lang.String propertyFileName)
          Constructor which reads the property file with the file name given.
 
Method Summary
 boolean getBooleanProperty(java.lang.String propertyName, boolean defaultValue)
          Get value of a global property (inside system.properties) and return it as an boolean type.
 java.util.Properties getComponentsAndVersions()
          Returns a Hashtable containing all of the component names found in the property file (designated by a property file prefix in PROPERTY_FILE_COMPONENT_VERSION_PREFIX).
static AppProperties getInstance()
          Returns the singleton instance of this class.
 int getIntegerProperty(java.lang.String propertyName, int defaultValue)
          Get value of a property as an int type.
 long getLongProperty(java.lang.String propertyName, long defaultValue)
          Get value of a global property (inside system.properties) and return it as an int type.
 java.util.Properties getPropertiesForPrefix(java.lang.String prefix)
          Returns a Properties object containing all of the property names found in the property file (designated by a property file prefix taken from the prefix input variable).
 java.lang.String getStringProperty(java.lang.String propertyName, java.lang.String defaultValue)
          Get value of a global property (inside system.properties) and return it as a String type.
protected  boolean isRelativePathFileName(java.lang.String fileName)
          Helper method to find if a file name has slashes/backslashes in it.
protected  void load(java.lang.String fileName)
          This method loads properties from the file name given as input.
 
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
 

Field Detail

singleton

protected static AppProperties singleton
Provides the class variable for the Singleton pattern, to keep track of the one and only instance of this class.


PROPERTY_FILE_COMPONENT_VERSION_PREFIX

protected static final java.lang.String PROPERTY_FILE_COMPONENT_VERSION_PREFIX
The prefix in the property file for all component versions.

See Also:
Constant Field Values

propertyFileName

protected java.lang.String propertyFileName
Holds the file name of the property file.

Constructor Detail

AppProperties

protected AppProperties()
Protect the default constructor, this class uses a Singleton pattern. If you need to access the Singleton instance of the class, DON'T make this public, instead use the getInstance() method!


AppProperties

public AppProperties(java.lang.String propertyFileName)
Constructor which reads the property file with the file name given.


AppProperties

public AppProperties(java.util.Properties properties)
Constructor which populates the current object with the properties give. Does NOT call the superclass to load defaults, I don't like that behavior!!!

Method Detail

getInstance

public static AppProperties getInstance()
Returns the singleton instance of this class.


isRelativePathFileName

protected boolean isRelativePathFileName(java.lang.String fileName)
Helper method to find if a file name has slashes/backslashes in it.


load

protected void load(java.lang.String fileName)
This method loads properties from the file name given as input.


getIntegerProperty

public int getIntegerProperty(java.lang.String propertyName,
                              int defaultValue)
Get value of a property as an int type. If anything goes wrong, return the default value passed in the method call.

Parameters:
propertyName - The name of the property
defaultValue - If not found or cannot be decoded, return this value
Returns:
The value of the specific property

getLongProperty

public long getLongProperty(java.lang.String propertyName,
                            long defaultValue)
Get value of a global property (inside system.properties) and return it as an int type. If anything goes wrong, return the default value passed in the method call.

Parameters:
propertyName - The name of the property
defaultValue - If not found or cannot be decoded, return this value
Returns:
The value of the specific property

getBooleanProperty

public boolean getBooleanProperty(java.lang.String propertyName,
                                  boolean defaultValue)
Get value of a global property (inside system.properties) and return it as an boolean type. If anything goes wrong, return the default value passed in the method call.

Parameters:
propertyName - The name of the property
defaultValue - If not found or cannot be decoded, return this value
Returns:
The value of the specific property

getStringProperty

public java.lang.String getStringProperty(java.lang.String propertyName,
                                          java.lang.String defaultValue)
Get value of a global property (inside system.properties) and return it as a String type. If anything goes wrong, return the default value passed in the method call.

Parameters:
propertyName - The name of the property
defaultValue - If not found or cannot be decoded, return this value
Returns:
The value of the specific property

getPropertiesForPrefix

public java.util.Properties getPropertiesForPrefix(java.lang.String prefix)
Returns a Properties object containing all of the property names found in the property file (designated by a property file prefix taken from the prefix input variable). The key to the properties is the property name portion after the prefix and the value in the properties is its property file value.


getComponentsAndVersions

public java.util.Properties getComponentsAndVersions()
Returns a Hashtable containing all of the component names found in the property file (designated by a property file prefix in PROPERTY_FILE_COMPONENT_VERSION_PREFIX). The key to the Hashtable is the component name and the value is the revision level.