Arch4J 1.1

org.arch4j.property
Class PropertyManagerImpl

java.lang.Object
  |
  +--org.arch4j.property.PropertyManagerImpl
All Implemented Interfaces:
PropertyManager

public class PropertyManagerImpl
extends Object
implements PropertyManager

This class manages the reading and caching of property files. It takes * the name of a property domain and tries to find an associated * property file in the designated property file directory by appending * .properties to the domain. * *

For example, the property manager * will search for the properties in the "user" domain in user.properties. * If the special property key CACHE is found and the value is * Y, then the collection of properties will be cached and used on * future lookups. The cache can be cleared by calling clearCache(). * * @author Russ Brown * @author Ross E. Greinke * @version 2.0


Constructor Summary
PropertyManagerImpl()
          Constructs a PropertyManagerImpl, set to look for property * files in the current directory.
PropertyManagerImpl(File directoryFile)
          Constructs a PropertyManagerImpl, set to look for property * files in the given directory.
PropertyManagerImpl(String directoryName)
          Constructs a PropertyManagerImpl, set to look for property * files in the given directory.
 
Method Summary
static void clearCache()
          Clears the property cache.
 Properties getProperties(String forDomain)
          Returns all the Properties associated with a given domain.
 String getProperty(String forDomain, String propertyName)
          Searches for the property with the specified property name within the * given domain.
 String getProperty(String forDomain, String propertyName, String defaultValue)
          Searches for the property with the specified property name within the * given domain.
 File getPropertyDirectory()
          Returns the property directory where property files are stored.
 void setProperty(String forDomain, String propertyName, String propertyValue)
          This method changes a given property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyManagerImpl

public PropertyManagerImpl()
Constructs a PropertyManagerImpl, set to look for property * files in the current directory.


PropertyManagerImpl

public PropertyManagerImpl(String directoryName)
Constructs a PropertyManagerImpl, set to look for property * files in the given directory. * @param directoryName The directory in which to look for property files.


PropertyManagerImpl

public PropertyManagerImpl(File directoryFile)
Constructs a PropertyManagerImpl, set to look for property * files in the given directory. * @param directoryFile The directory file in which to look for property files.

Method Detail

getPropertyDirectory

public File getPropertyDirectory()
Returns the property directory where property files are stored. * @return The property directory as a File.

Specified by:
getPropertyDirectory in interface PropertyManager
Returns:
The property directory as a File.

getProperties

public Properties getProperties(String forDomain)
Returns all the Properties associated with a given domain. * @param forDomain The domain name. * @return The properties associated with domain. * @exception EnvironmentalException If the file doesn't exist or cannot be parsed.

Specified by:
getProperties in interface PropertyManager
Parameters:
forDomain - The domain name.
Returns:
The properties associated with domain.

getProperty

public String getProperty(String forDomain,
                          String propertyName)
Searches for the property with the specified property name within the * given domain. The method returns null if the * property is not found. * @param forDomain The domain name. * @param propertyName The key to search for. * @return The property value for the property name (key) or null.

Specified by:
getProperty in interface PropertyManager
Parameters:
forDomain - The domain name.
propertyName - The key to search for.
Returns:
The property value for the property name (key) or null.

getProperty

public String getProperty(String forDomain,
                          String propertyName,
                          String defaultValue)
Searches for the property with the specified property name within the * given domain. The method returns the default value if the * property is not found. * @param forDomain The domain name. * @param propertyName The key to search for. * @param defaultValue The value to return if the property key is not found. * @return The property value for the property name (key) or the default value.

Specified by:
getProperty in interface PropertyManager
Parameters:
forDomain - The domain name.
propertyName - The key to search for.
defaultValue - The value to return if the property key is not found.
Returns:
The property value for the property name (key) or the default value.

setProperty

public void setProperty(String forDomain,
                        String propertyName,
                        String propertyValue)
This method changes a given property. If it is a new property it is added as a * new entry. If caching is set to true the cache is refreshed, *

Specified by:
setProperty in interface PropertyManager
Parameters:
forDomain - The domain name.
propertyName - The key to search for.
propertyValue - The new value for the property name (key) or null.

clearCache

public static void clearCache()
Clears the property cache.


Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.