org.apache.commons.digester.plugins

Class Declaration

public class Declaration extends Object

Represents a Class that can be instantiated by a PluginCreateRule, plus info on how to load custom digester rules for mapping xml into that plugged-in class.

Since: 1.6

Field Summary
Stringid
booleaninitialized
ClasspluginClass
The class of the object to be instantiated.
StringpluginClassName
The name of the class of the object to be instantiated.
Propertiesproperties
RuleLoaderruleLoader
Class which is responsible for dynamically loading this plugin's rules on demand.
Constructor Summary
Declaration(String pluginClassName)
Constructor.
Declaration(Class pluginClass)
Constructor.
Declaration(Class pluginClass, RuleLoader ruleLoader)
Create an instance where a fully-initialised ruleLoader instance is provided by the caller instead of having the PluginManager "discover" an appropriate one.
Method Summary
voidconfigure(Digester digester, String pattern)
Attempt to load custom rules for the target class at the specified pattern.
StringgetId()
Return the id associated with this declaration.
ClassgetPluginClass()
Return plugin class associated with this declaration.
voidinit(Digester digester, PluginManager pm)
Must be called exactly once, and must be called before any call to the configure method.
voidsetId(String id)
The id that the user associated with a particular plugin declaration in the input xml.
voidsetProperties(Properties p)
Copy all (key,value) pairs in the param into the properties member of this object.

Field Detail

id

private String id
See Declaration.

initialized

private boolean initialized
See Declaration.

pluginClass

private Class pluginClass
The class of the object to be instantiated.

pluginClassName

private String pluginClassName
The name of the class of the object to be instantiated.

properties

private Properties properties
See Declaration.

ruleLoader

private RuleLoader ruleLoader
Class which is responsible for dynamically loading this plugin's rules on demand.

Constructor Detail

Declaration

public Declaration(String pluginClassName)
Constructor.

Declaration

public Declaration(Class pluginClass)
Constructor.

Declaration

public Declaration(Class pluginClass, RuleLoader ruleLoader)
Create an instance where a fully-initialised ruleLoader instance is provided by the caller instead of having the PluginManager "discover" an appropriate one.

Method Detail

configure

public void configure(Digester digester, String pattern)
Attempt to load custom rules for the target class at the specified pattern.

On return, any custom rules associated with the plugin class have been loaded into the Rules object currently associated with the specified digester object.

getId

public String getId()
Return the id associated with this declaration. For plugins declared "inline", null will be returned.

Returns: The id value. May be null.

getPluginClass

public Class getPluginClass()
Return plugin class associated with this declaration.

Returns: The pluginClass.

init

public void init(Digester digester, PluginManager pm)
Must be called exactly once, and must be called before any call to the configure method.

setId

public void setId(String id)
The id that the user associated with a particular plugin declaration in the input xml. This id is later used in the input xml to refer back to the original declaration.

For plugins declared "in-line", the id is null.

setProperties

public void setProperties(Properties p)
Copy all (key,value) pairs in the param into the properties member of this object.

The declaration properties cannot be explicit member variables, because the set of useful properties a user can provide on a declaration depends on what RuleFinder classes are available - and extra RuleFinders can be added by the user. So here we keep a map of the settings, and let the RuleFinder objects look for whatever properties they consider significant.

The "id" and "class" properties are treated differently.

Copyright 2001-2005 The Apache Software Foundation.