com.townleyenterprises.common
Class ConfigLoader

java.lang.Object
  extended bycom.townleyenterprises.common.ConfigLoader

public class ConfigLoader
extends java.lang.Object

This class provides the main mechanism of loading configuration files so that I don't have to have the exact same code in more than one place.

Version:
$Id: ConfigLoader.java,v 1.5 2004/07/29 18:34:07 atownley Exp $
Author:
Andrew S. Townley

Constructor Summary
ConfigLoader(java.lang.Class cls, java.lang.String primaryloc, java.lang.String secondaryloc)
          The constructor takes the primary and secondary locations of the properties to be loaded.
 
Method Summary
 boolean equals(java.lang.Object o)
          Checks for equality based on the values of the constructor attributes.
 java.util.Properties getProperties()
          This method allows access to all of the property values so that external code can be configured from the unified properties.
 java.lang.String getProperty(java.lang.String name)
          This method returns the appropriate property value.
 java.lang.String getProperty(java.lang.String prefix, java.lang.String name)
          Alternative method that provides a prefix in addition to the specific parameter to retrieve.
 java.lang.String toString()
          This method prints information about this configuration loader instance.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConfigLoader

public ConfigLoader(java.lang.Class cls,
                    java.lang.String primaryloc,
                    java.lang.String secondaryloc)
             throws java.io.IOException
The constructor takes the primary and secondary locations of the properties to be loaded. Properties located in the secondary location will override properties in the primary location.

Parameters:
primaryloc - the primary location (usually, just the name of the properties file)
secondaryloc - the secondary location (usually, the same name prefixed with a '/' so that it can be placed in the classes directory of the servlet container)
Throws:
java.io.IOException - if there was a problem accessing the properties
Method Detail

getProperty

public java.lang.String getProperty(java.lang.String name)
This method returns the appropriate property value.

Parameters:
name - the parameter key
Returns:
the property value

getProperty

public java.lang.String getProperty(java.lang.String prefix,
                                    java.lang.String name)
Alternative method that provides a prefix in addition to the specific parameter to retrieve.

Parameters:
prefix - the prefix
name - the actual param name
Returns:
the parameter value

getProperties

public java.util.Properties getProperties()
This method allows access to all of the property values so that external code can be configured from the unified properties.

Returns:
a copy of the properties

toString

public java.lang.String toString()
This method prints information about this configuration loader instance.


equals

public boolean equals(java.lang.Object o)
Checks for equality based on the values of the constructor attributes.



Copyright © 2002-2004, Andrew S. Townley and Townley Enterprises. All Rights Reserved.
This project is hosted on http://te-code.sourceforge.net.