com.tensegrity.generic.util
Class PropertiesFactory

java.lang.Object
  extended bycom.tensegrity.generic.util.PropertiesFactory

public final class PropertiesFactory
extends java.lang.Object

The PropertiesFactory is a factory implementation to obtain property files (*.properties) for an application. Users of this class must specify an application name by using the setApplicationName(String) method. Once the name is set, the property file will be of form

 applicationname + "." + properties

To obtain an instance of class PropertiesFile users call the getPropertiesFile(Object) method.

If you still want to benefit from this factory, but not use the PropertiesFile class you may invoke the getFile(String) method.

Version:
$Id: PropertiesFactory.java,v 1.9 2005/12/16 08:47:04 BurkhardWick Exp $
Author:
GillesIachelini

Field Summary
static java.lang.String KEY_PROPERTIES_HOME
          The KEY_PROPERTIES_HOME field contains the string representation for a system key, which specifies the home directory for property files created by this factory.
 
Method Summary
 java.io.File getFile(java.lang.String filename)
          For those components who need to maintain their own files, but still want to benefit from this factory, can obtain a File instance from this method which will ensure, that the file resides in the correct location.
static PropertiesFactory getInstance()
          Returns the instance of the Factory.
 PropertiesFile getPropertiesFile(java.lang.Object requiresProperties)
          This method returns the PropertiesFile instance for an instance which requires persistent properties.
static java.lang.String internalGetApplicationName()
          Internal getter method for the application name
static void setApplicationName(java.lang.String name)
          Sets the name of the current application this factory is used in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_PROPERTIES_HOME

public static final java.lang.String KEY_PROPERTIES_HOME
The KEY_PROPERTIES_HOME field contains the string representation for a system key, which specifies the home directory for property files created by this factory.

If a string is found in the system property to this key, it will be used as home directory for all the property files. Otherwise user home directory is used.

See Also:
Constant Field Values
Method Detail

getInstance

public static final PropertiesFactory getInstance()
Returns the instance of the Factory.

Returns:
an instance of the PropertiesFactory.

setApplicationName

public static final void setApplicationName(java.lang.String name)
Sets the name of the current application this factory is used in. Its optional. If you set such a name all requested property files will reside in a directory which is in the "{user.home}/<ApplicationName>"-directory. This method will convert the string to lower case and remove all the whitespace characters.

Parameters:
name - The name of the enclosing application as string. (optional)

getPropertiesFile

public final PropertiesFile getPropertiesFile(java.lang.Object requiresProperties)
                                       throws PropertiesFactoryException
This method returns the PropertiesFile instance for an instance which requires persistent properties. If this parameter is of type String, the String itself would be used as filename. Otherwise the package stripped class name is the filename.

Parameters:
requiresProperties - the object which requires Properties.
Returns:
a new instance of PropertiesFile, or the previously created one.
Throws:
PropertiesFactoryException - thrown if the file can't be created.

getFile

public final java.io.File getFile(java.lang.String filename)
                           throws PropertiesFactoryException
For those components who need to maintain their own files, but still want to benefit from this factory, can obtain a File instance from this method which will ensure, that the file resides in the correct location.

Parameters:
filename - the target file name.
Returns:
the File instance pointing to the right location.
Throws:
PropertiesFactoryException - thrown when the file creation fails.

internalGetApplicationName

public static java.lang.String internalGetApplicationName()
Internal getter method for the application name

Returns:
the application name that was last used in setApplicationName(String)


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.