com.jfw.util
Class PropertiesManager

java.lang.Object
  extended by com.jfw.util.PropertiesManager
All Implemented Interfaces:
java.util.Observer

public class PropertiesManager
extends java.lang.Object
implements java.util.Observer

Manage the data of a properties file.
The instance is returned by PropertiesProxy.getProperties(java.lang.String, java.lang.String).
Is an observer of UpdateObservable.

The properties files of JFW is managed by an instance of this class.
You can see an example of the jfw.properties here.


Constructor Summary
PropertiesManager(java.lang.String propertiesName, java.lang.String language)
          Create an instance.
 
Method Summary
protected  void addObserver(java.lang.Object object, java.lang.String description)
          Add this instance as observer of UpdateObservable.
 java.lang.String getLanguage()
          Get attribute language.
 java.util.Properties getProperties()
          Get the Propeties object.
 java.lang.String getPropertiesName()
          Get attribute propertiesName.
 java.lang.Float readFloatParameter(java.lang.String key)
          Get the value from the properties file.
 java.lang.Float readFloatParameter(java.lang.String key, float defaultValue)
          Get the value from the properties file.
 java.lang.Integer readIntParameter(java.lang.String key)
          Get the value from the properties file.
 java.lang.Integer readIntParameter(java.lang.String key, int defaultValue)
          Get the value from the properties file.
 java.lang.String readParameter(java.lang.String key)
          Get the value from the properties file.
 java.lang.String readParameter(java.lang.String key, java.lang.String defaultValue)
          Get the value from the properties file.
protected  void readProperties()
          Use method PropertiesReader.readProperties(java.lang.String, java.lang.String, java.util.Properties) for read the properties file.
 java.lang.String toString()
          Return data relative of this object.
 void update(java.util.Observable observable, java.lang.Object obj)
          Called by UpdateObservable.update().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropertiesManager

public PropertiesManager(java.lang.String propertiesName,
                         java.lang.String language)
                  throws JFWGenericException
Create an instance.

Parameters:
propertiesName - the name the properties file.
language - the language of the prorties file. If null the default language will be used.
Throws:
JFWGenericException
Method Detail

readProperties

protected void readProperties()
                       throws JFWGenericException
Use method PropertiesReader.readProperties(java.lang.String, java.lang.String, java.util.Properties) for read the properties file.

Throws:
JFWGenericException

addObserver

protected void addObserver(java.lang.Object object,
                           java.lang.String description)
Add this instance as observer of UpdateObservable.

Parameters:
object - this instance.
description - description of this instance.

getPropertiesName

public java.lang.String getPropertiesName()
Get attribute propertiesName.

Returns:
attribute propertiesName.

getLanguage

public java.lang.String getLanguage()
Get attribute language.

Returns:
attribute language.

getProperties

public java.util.Properties getProperties()
Get the Propeties object.

Returns:
attribute properties.

readParameter

public java.lang.String readParameter(java.lang.String key)
Get the value from the properties file.

Parameters:
key - the key to read.
Returns:
the value of the key.

readParameter

public java.lang.String readParameter(java.lang.String key,
                                      java.lang.String defaultValue)
Get the value from the properties file.

Parameters:
key - the key to read.
defaultValue - if key is not found this value is returned.
Returns:
the value of the key.

readIntParameter

public java.lang.Integer readIntParameter(java.lang.String key)
Get the value from the properties file.

Parameters:
key - the key to read.
Returns:
the value of the key.

readIntParameter

public java.lang.Integer readIntParameter(java.lang.String key,
                                          int defaultValue)
Get the value from the properties file.

Parameters:
key - the key to read.
defaultValue - if key is not found this value is returned.
Returns:
the value of the key.

readFloatParameter

public java.lang.Float readFloatParameter(java.lang.String key)
Get the value from the properties file.

Parameters:
key - the key to read.
Returns:
the value of the key.

readFloatParameter

public java.lang.Float readFloatParameter(java.lang.String key,
                                          float defaultValue)
Get the value from the properties file.

Parameters:
key - the key to read.
defaultValue - if key is not found this value is returned.
Returns:
the value of the key.

update

public void update(java.util.Observable observable,
                   java.lang.Object obj)
Called by UpdateObservable.update().

Specified by:
update in interface java.util.Observer
Parameters:
observable - the observable object.
obj - the update object.

toString

public java.lang.String toString()
Return data relative of this object.

Overrides:
toString in class java.lang.Object