Luky Library - 4.1.1 (20061117-1148)

luky.util
Class PropertyManager

java.lang.Object
  extended by luky.util.PropertyManager

public class PropertyManager
extends Object

The property manager manages properties. It is actually a wrapper class around the java.util.propery object which can be used to interface with it.
Major enhancement is the read file and write file function which are used to read and write propery settings from a standarized file.
The file may have empty lines and comments starting with "#". The other lines must be in the format :

The properyManager uses the Log class.

Version:
1.00
Author:
Chris Lukassen
 

Constructor Summary
PropertyManager()
          default constructor, allocates an empty propertyManager
PropertyManager(Properties properties)
          pre loaded constructor, allocates a propertyManager with pre loaded properties
 
Method Summary
 int getIntProperty(String name)
          gets the property specified by the parameter as an int
 Properties getProperties()
          gets the properties with which the propertyManager is filed
 String getProperty(String name)
          gets the property specified by the parameter
 int readFile(String fileName)
          gets the properties from the file specified by fileName
 int setProperties(Properties newProps)
          sets the properties to the property object passed to the property manager all previous settings are lost
 int setProperty(String name, String value)
          sets the property specified by the parameter name to the value specified by the parameter value
 int writeFile(String fileName)
          writes the properties to the file specified by fileName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyManager

public PropertyManager()
default constructor, allocates an empty propertyManager


PropertyManager

public PropertyManager(Properties properties)
pre loaded constructor, allocates a propertyManager with pre loaded properties

Parameters:
properties - the properties with which the propertyManager is created
Method Detail

setProperties

public int setProperties(Properties newProps)
sets the properties to the property object passed to the property manager all previous settings are lost

Parameters:
newProps - the properties with which the propertyManager is filled
Returns:
OK

getProperties

public Properties getProperties()
gets the properties with which the propertyManager is filed

Returns:
the properties

getProperty

public String getProperty(String name)
gets the property specified by the parameter

Parameters:
name - property label name
Returns:
the value of the property or null if it was not known

getIntProperty

public int getIntProperty(String name)
                   throws NumberFormatException
gets the property specified by the parameter as an int

Throws:
NumberFormatException
Parameters:
name - property label name
Returns:
the value of the property or trows exception

setProperty

public int setProperty(String name,
                       String value)
sets the property specified by the parameter name to the value specified by the parameter value

Parameters:
name - property label name
value - the value of this label
Returns:
OK

readFile

public int readFile(String fileName)
gets the properties from the file specified by fileName

Parameters:
fileName - the name of the file from which the settings are read
Returns:
OK or NOK

writeFile

public int writeFile(String fileName)
writes the properties to the file specified by fileName

Parameters:
fileName - the name of the file from to which the settings are written
Returns:
OK or NOK

Luky Library - 4.1.1 (20061117-1148)