org.apache.commons.configuration
Class DefaultConfigurationBuilder.FileExtensionConfigurationProvider

java.lang.Object
  extended by org.apache.commons.configuration.beanutils.DefaultBeanFactory
      extended by org.apache.commons.configuration.DefaultConfigurationBuilder.ConfigurationProvider
          extended by org.apache.commons.configuration.DefaultConfigurationBuilder.FileConfigurationProvider
              extended by org.apache.commons.configuration.DefaultConfigurationBuilder.FileExtensionConfigurationProvider
All Implemented Interfaces:
BeanFactory
Enclosing class:
DefaultConfigurationBuilder

static class DefaultConfigurationBuilder.FileExtensionConfigurationProvider
extends DefaultConfigurationBuilder.FileConfigurationProvider

A specialized configuration provider for file based configurations that can handle configuration sources whose concrete type depends on the extension of the file to be loaded. One example is the properties tag: if the file ends with ".xml" a XMLPropertiesConfiguration object must be created, otherwise a PropertiesConfiguration object.


Field Summary
private  java.lang.Class defaultClass
          Stores the class to be created when the file extension does not match.
private  java.lang.String defaultClassName
          Stores the name of the class to be created when the file extension does not match.
private  java.lang.String fileExtension
          Stores the file extension to be checked against.
private  java.lang.Class matchingClass
          Stores the class to be created when the file extension matches.
private  java.lang.String matchingClassName
          Stores the name of the class to be created when the file extension matches.
 
Fields inherited from class org.apache.commons.configuration.beanutils.DefaultBeanFactory
INSTANCE
 
Constructor Summary
DefaultConfigurationBuilder.FileExtensionConfigurationProvider(java.lang.Class matchingClass, java.lang.Class defaultClass, java.lang.String extension)
          Creates a new instance of FileExtensionConfigurationProvider and initializes it.
DefaultConfigurationBuilder.FileExtensionConfigurationProvider(java.lang.String matchingClassName, java.lang.String defaultClassName, java.lang.String extension)
          Creates a new instance of FileExtensionConfigurationProvider and initializes it with the names of the classes to be created.
 
Method Summary
protected  java.lang.Object createBeanInstance(java.lang.Class beanClass, BeanDeclaration data)
          Creates the configuration object.
protected  java.lang.Class fetchDefaultClass()
          Returns the default class object, no matter whether it was defined as a class or as a class name.
protected  java.lang.Class fetchMatchingClass()
          Returns the matching class object, no matter whether it was defined as a class or as a class name.
 
Methods inherited from class org.apache.commons.configuration.DefaultConfigurationBuilder.FileConfigurationProvider
getConfiguration, getEmptyConfiguration, initBeanInstance
 
Methods inherited from class org.apache.commons.configuration.DefaultConfigurationBuilder.ConfigurationProvider
fetchConfigurationClass, getConfigurationClass, getConfigurationClassName, loadClass, setConfigurationClass, setConfigurationClassName
 
Methods inherited from class org.apache.commons.configuration.beanutils.DefaultBeanFactory
createBean, getDefaultBeanClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

matchingClass

private java.lang.Class matchingClass
Stores the class to be created when the file extension matches.


matchingClassName

private java.lang.String matchingClassName
Stores the name of the class to be created when the file extension matches.


defaultClass

private java.lang.Class defaultClass
Stores the class to be created when the file extension does not match.


defaultClassName

private java.lang.String defaultClassName
Stores the name of the class to be created when the file extension does not match.


fileExtension

private java.lang.String fileExtension
Stores the file extension to be checked against.

Constructor Detail

DefaultConfigurationBuilder.FileExtensionConfigurationProvider

public DefaultConfigurationBuilder.FileExtensionConfigurationProvider(java.lang.Class matchingClass,
                                                                      java.lang.Class defaultClass,
                                                                      java.lang.String extension)
Creates a new instance of FileExtensionConfigurationProvider and initializes it.

Parameters:
matchingClass - the class to be created when the file extension matches
defaultClass - the class to be created when the file extension does not match
extension - the file extension to be checked agains

DefaultConfigurationBuilder.FileExtensionConfigurationProvider

public DefaultConfigurationBuilder.FileExtensionConfigurationProvider(java.lang.String matchingClassName,
                                                                      java.lang.String defaultClassName,
                                                                      java.lang.String extension)
Creates a new instance of FileExtensionConfigurationProvider and initializes it with the names of the classes to be created.

Parameters:
matchingClassName - the name of the class to be created when the file extension matches
defaultClassName - the name of the class to be created when the file extension does not match
extension - the file extension to be checked agains
Since:
1.4
Method Detail

fetchMatchingClass

protected java.lang.Class fetchMatchingClass()
                                      throws java.lang.Exception
Returns the matching class object, no matter whether it was defined as a class or as a class name.

Returns:
the matching class object
Throws:
java.lang.Exception - if an error occurs
Since:
1.4

fetchDefaultClass

protected java.lang.Class fetchDefaultClass()
                                     throws java.lang.Exception
Returns the default class object, no matter whether it was defined as a class or as a class name.

Returns:
the default class object
Throws:
java.lang.Exception - if an error occurs
Since:
1.4

createBeanInstance

protected java.lang.Object createBeanInstance(java.lang.Class beanClass,
                                              BeanDeclaration data)
                                       throws java.lang.Exception
Creates the configuration object. The class is determined by the file name's extension.

Overrides:
createBeanInstance in class DefaultBeanFactory
Parameters:
beanClass - the class
data - the bean declaration
Returns:
the new bean
Throws:
java.lang.Exception - if an error occurs