org.apache.commons.configuration
Class ClassPropertiesConfiguration

java.lang.Object
  extended byorg.apache.commons.configuration.AbstractConfiguration
      extended byorg.apache.commons.configuration.BaseConfiguration
          extended byorg.apache.commons.configuration.BasePathConfiguration
              extended byorg.apache.commons.configuration.BasePropertiesConfiguration
                  extended byorg.apache.commons.configuration.ClassPropertiesConfiguration
All Implemented Interfaces:
BasePathLoader, Configuration

public class ClassPropertiesConfiguration
extends BasePropertiesConfiguration
implements Configuration

Loads the configuration from the classpath utilizing a specified class to get the classloader from. The properties file will be attempted to be loaded first from the classes package directory and then from the class path in general.

This class does not support an empty constructor and saving of a synthesized properties file. Use PropertiesConfiguration for this.

Version:
$Id: ClassPropertiesConfiguration.java,v 1.1.1.1 2003/12/23 15:09:05 epugh Exp $
Author:
Henning P. Schmiedehausen
See Also:
BasePropertiesConfiguration

Nested Class Summary
 
Nested classes inherited from class org.apache.commons.configuration.BasePropertiesConfiguration
BasePropertiesConfiguration.PropertiesReader, BasePropertiesConfiguration.PropertiesWriter
 
Nested classes inherited from class org.apache.commons.configuration.AbstractConfiguration
AbstractConfiguration.Container, AbstractConfiguration.PropertiesTokenizer
 
Field Summary
private  java.lang.Class baseClass
          Base class, which is used to load all relative class references
private  java.lang.ClassLoader classLoader
          Class Loader which we will use to load the resources
 
Fields inherited from class org.apache.commons.configuration.BasePropertiesConfiguration
include
 
Fields inherited from class org.apache.commons.configuration.BasePathConfiguration
 
Fields inherited from class org.apache.commons.configuration.BaseConfiguration
 
Fields inherited from class org.apache.commons.configuration.AbstractConfiguration
defaults, END_TOKEN, START_TOKEN
 
Constructor Summary
ClassPropertiesConfiguration(java.lang.Class baseClass, java.lang.String resource)
          Creates and loads an extended properties file from the Class Resources.
ClassPropertiesConfiguration(java.lang.Class baseClass, java.lang.String resource, Configuration defaults)
          Creates and loads an extended properties file from the Class Resources.
ClassPropertiesConfiguration(java.lang.Class baseClass, java.lang.String resource, java.lang.String defaultFile)
          Creates and loads an extended properties file from the Class Resources.
 
Method Summary
 java.io.InputStream getPropertyStream(java.lang.String resourceName)
          Gets a resource relative to the supplied base class or from the class loader if it is not found from the supplied base class.
 
Methods inherited from class org.apache.commons.configuration.BasePropertiesConfiguration
getInclude, getIncludesAllowed, load, load, save, setInclude, setIncludesAllowed
 
Methods inherited from class org.apache.commons.configuration.BasePathConfiguration
getBasePath, setBasePath
 
Methods inherited from class org.apache.commons.configuration.BaseConfiguration
addPropertyDirect, clearProperty, containsKey, getKeys, getPropertyDirect, isEmpty
 
Methods inherited from class org.apache.commons.configuration.AbstractConfiguration
addProperty, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getList, getList, getLong, getLong, getLong, getProperties, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, interpolate, interpolateHelper, processString, setProperty, subset, testBoolean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.configuration.Configuration
addProperty, clearProperty, containsKey, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getKeys, getList, getList, getLong, getLong, getLong, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, isEmpty, setProperty, subset
 

Field Detail

baseClass

private java.lang.Class baseClass
Base class, which is used to load all relative class references


classLoader

private java.lang.ClassLoader classLoader
Class Loader which we will use to load the resources

Constructor Detail

ClassPropertiesConfiguration

public ClassPropertiesConfiguration(java.lang.Class baseClass,
                                    java.lang.String resource)
                             throws java.io.IOException
Creates and loads an extended properties file from the Class Resources. Uses the class loader.

Parameters:
baseClass - The class providing the FileStream.
resource - The name of the Resource.
Throws:
java.io.IOException - Error while loading the properties file

ClassPropertiesConfiguration

public ClassPropertiesConfiguration(java.lang.Class baseClass,
                                    java.lang.String resource,
                                    Configuration defaults)
                             throws java.io.IOException
Creates and loads an extended properties file from the Class Resources. Uses the class loader.

Parameters:
baseClass - The class providing the FileStream.
resource - The name of the Resource.
defaults - Configuration defaults to use if key not in file
Throws:
java.io.IOException - Error while loading the properties file

ClassPropertiesConfiguration

public ClassPropertiesConfiguration(java.lang.Class baseClass,
                                    java.lang.String resource,
                                    java.lang.String defaultFile)
                             throws java.io.IOException
Creates and loads an extended properties file from the Class Resources. Uses the class loader.

Parameters:
baseClass - The class providing the FileStream.
resource - The name of the Resource.
defaultFile - Configuration defaults to use if key not in file
Throws:
java.io.IOException - Error while loading the properties file
Method Detail

getPropertyStream

public java.io.InputStream getPropertyStream(java.lang.String resourceName)
                                      throws java.io.IOException
Gets a resource relative to the supplied base class or from the class loader if it is not found from the supplied base class.

Specified by:
getPropertyStream in class BasePropertiesConfiguration
Parameters:
resourceName - The resource Name
Returns:
An Input Stream
Throws:
java.io.IOException - Error while loading the properties file