DLESE Tools
v1.2

org.dlese.dpc.propertiesmgr
Class PropertiesManager

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended byjava.util.Properties
              extended byorg.dlese.dpc.propertiesmgr.PropertiesManager
All Implemented Interfaces:
Cloneable, Map, Serializable

public class PropertiesManager
extends Properties

DESCRIPTION

Author:
John Weatherley
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
PropertiesManager()
          Create an unloaded Properties object.
PropertiesManager(String propsFileName)
          Create and load this Properties hash map from the given Properties file or properties reaource located in the jar
 
Method Summary
 String getProp(String property, String defaultValue)
          Retrieves the property value from this object's property file.
 boolean getPropAsBoolean(String property, String defaultValue)
          Same as the getProp(String,String) method only it returns it's parameter as a boolean.
 int getPropAsInt(String property, String defaultValue)
          Same as the getProp(String,String) method only it returns it's parameter as an integer.
 void writePropsFile()
          Writes the properties to the same file that was used to read them, preserving any comments in the file.
 void writePropsFile(String propsFilePath)
          Writes the properties to the given file path.
 
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

PropertiesManager

public PropertiesManager()
Create an unloaded Properties object. Same as Properties().


PropertiesManager

public PropertiesManager(String propsFileName)
                  throws IOException
Create and load this Properties hash map from the given Properties file or properties reaource located in the jar

Parameters:
propsFileName - The name of the Properties file to load or URL to the properties location inside a jar
Throws:
IOException - If unable to load the properties.
Method Detail

writePropsFile

public void writePropsFile()
                    throws IOException
Writes the properties to the same file that was used to read them, preserving any comments in the file. If the original file was contained in a jar then an I/O excetion is thrown.

Throws:
IOException - If error in input/output

writePropsFile

public void writePropsFile(String propsFilePath)
                    throws IOException
Writes the properties to the given file path. If the file path is the same as the one used to upen this file, then all comments in the file are preserved.

Parameters:
propsFilePath - The full path to the props file to be written.
Throws:
IOException - If error in input/output

getProp

public String getProp(String property,
                      String defaultValue)
               throws Exception
Retrieves the property value from this object's property file. If the property does not exist and a default value is specified, the default is set in the Properties and is returned.

Parameters:
property - The property sting to retrieve
defaultValue - The default value for this property, if none is found
Returns:
The prop value
Throws:
Exception - DESCRIPTION

getPropAsInt

public int getPropAsInt(String property,
                        String defaultValue)
                 throws Exception
Same as the getProp(String,String) method only it returns it's parameter as an integer.

Parameters:
property - DESCRIPTION
defaultValue - DESCRIPTION
Returns:
The propAsInt value
Throws:
Exception - DESCRIPTION

getPropAsBoolean

public boolean getPropAsBoolean(String property,
                                String defaultValue)
                         throws Exception
Same as the getProp(String,String) method only it returns it's parameter as a boolean. Possible inputs are [yes|no|true|false|on|off|enabled|disabled].

Parameters:
property - DESCRIPTION
defaultValue - DESCRIPTION
Returns:
The propAsBoolean value
Throws:
Exception - DESCRIPTION

DLESE Tools
v1.2