org.apache.commons.configuration

Class DefaultConfigurationBuilder.FileExtensionConfigurationProvider

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
ClassdefaultClass
Stores the class to be created when the file extension does not match.
StringdefaultClassName
Stores the name of the class to be created when the file extension does not match.
StringfileExtension
Stores the file extension to be checked against.
ClassmatchingClass
Stores the class to be created when the file extension matches.
StringmatchingClassName
Stores the name of the class to be created when the file extension matches.
Constructor Summary
FileExtensionConfigurationProvider(Class matchingClass, Class defaultClass, String extension)
Creates a new instance of FileExtensionConfigurationProvider and initializes it.
FileExtensionConfigurationProvider(String matchingClassName, String defaultClassName, String extension)
Creates a new instance of FileExtensionConfigurationProvider and initializes it with the names of the classes to be created.
Method Summary
protected ObjectcreateBeanInstance(Class beanClass, BeanDeclaration data)
Creates the configuration object.
protected ClassfetchDefaultClass()
Returns the default class object, no matter whether it was defined as a class or as a class name.
protected ClassfetchMatchingClass()
Returns the matching class object, no matter whether it was defined as a class or as a class name.

Field Detail

defaultClass

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

defaultClassName

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

fileExtension

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

matchingClass

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

matchingClassName

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

Constructor Detail

FileExtensionConfigurationProvider

public FileExtensionConfigurationProvider(Class matchingClass, Class defaultClass, 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

FileExtensionConfigurationProvider

public FileExtensionConfigurationProvider(String matchingClassName, String defaultClassName, 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

createBeanInstance

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

Parameters: beanClass the class data the bean declaration

Returns: the new bean

Throws: Exception if an error occurs

fetchDefaultClass

protected Class fetchDefaultClass()
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: Exception if an error occurs

Since: 1.4

fetchMatchingClass

protected Class fetchMatchingClass()
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: Exception if an error occurs

Since: 1.4