Class PluginCreateRule
- All Implemented Interfaces:
InitializableRule
- Since:
- 1.6
-
Field Summary
Fields inherited from class Rule
digester, namespaceURI -
Constructor Summary
ConstructorsConstructorDescriptionPluginCreateRule(Class<?> baseClass) Create a plugin rule where the user must specify a plugin-class or plugin-id.PluginCreateRule(Class<?> baseClass, Class<?> dfltPluginClass) Create a plugin rule where the user may specify a plugin.PluginCreateRule(Class<?> baseClass, Class<?> dfltPluginClass, RuleLoader dfltPluginRuleLoader) Create a plugin rule where the user may specify a plugin. -
Method Summary
Modifier and TypeMethodDescriptionvoidbegin(String namespace, String name, Attributes attributes) Invoked when the Digester matches this rule against an xml element.voidProcess the body text of this element.voidInvoked by the digester when the closing tag matching this Rule's pattern is encountered.voidfireBeginMethods(List<Rule> rules, String namespace, String name, Attributes list) Duplicate the processing that the Digester does when firing the begin methods of rules.voidfireEndMethods(List<Rule> rules, String namespaceURI, String name) Duplicate the processing that the Digester does when firing the end methods of rules.Return the pattern that this Rule is associated with.voidpostRegisterInit(String matchPattern) Invoked after this rule has been added to the set of digester rules, associated with the specified pattern.voidsetPluginClassAttribute(String namespaceUri, String attrName) Sets the xml attribute which the input xml uses to indicate to a PluginCreateRule which class should be instantiated.voidsetPluginIdAttribute(String namespaceUri, String attrName) Sets the xml attribute which the input xml uses to indicate to a PluginCreateRule which plugin declaration is being referenced.Methods inherited from class Rule
begin, body, end, finish, getDigester, getNamespaceURI, setDigester, setNamespaceURI
-
Constructor Details
-
PluginCreateRule
Create a plugin rule where the user must specify a plugin-class or plugin-id.- Parameters:
baseClass- is the class which any specified plugin must be descended from.
-
PluginCreateRule
Create a plugin rule where the user may specify a plugin. If the user doesn't specify a plugin, then the default class specified in this constructor is used.- Parameters:
baseClass- is the class which any specified plugin must be descended from.dfltPluginClass- is the class which will be used if the user doesn't specify any plugin-class or plugin-id. This class will have custom rules installed for it just like a declared plugin.
-
PluginCreateRule
public PluginCreateRule(Class<?> baseClass, Class<?> dfltPluginClass, RuleLoader dfltPluginRuleLoader) Create a plugin rule where the user may specify a plugin. If the user doesn't specify a plugin, then the default class specified in this constructor is used.- Parameters:
baseClass- is the class which any specified plugin must be descended from.dfltPluginClass- is the class which will be used if the user doesn't specify any plugin-class or plugin-id. This class will have custom rules installed for it just like a declared plugin.dfltPluginRuleLoader- is a RuleLoader instance which knows how to load the custom rules associated with this default plugin.
-
-
Method Details
-
setPluginClassAttribute
Sets the xml attribute which the input xml uses to indicate to a PluginCreateRule which class should be instantiated.See
PluginRules.setPluginClassAttribute(String, String)for more info. -
setPluginIdAttribute
Sets the xml attribute which the input xml uses to indicate to a PluginCreateRule which plugin declaration is being referenced.See
PluginRules.setPluginIdAttribute(String, String)for more info. -
postRegisterInit
Invoked after this rule has been added to the set of digester rules, associated with the specified pattern. Check all configuration data is valid and remember the pattern for later.- Specified by:
postRegisterInitin interfaceInitializableRule- Parameters:
matchPattern- is the digester match pattern that is associated with this rule instance, eg "root/widget".- Throws:
PluginConfigurationException
-
begin
Invoked when the Digester matches this rule against an xml element.A new instance of the target class is created, and pushed onto the stack. A new "private" PluginRules object is then created and set as the digester's default Rules object. Any custom rules associated with the plugin class are then loaded into that new Rules object. Finally, any custom rules that are associated with the current pattern (such as SetPropertiesRules) have their begin methods executed.
- Overrides:
beginin classRule- Parameters:
namespace-name-attributes-- Throws:
ClassNotFoundExceptionPluginInvalidInputExceptionPluginConfigurationExceptionException
-
body
Process the body text of this element.- Overrides:
bodyin classRule- Parameters:
namespace- the namespace URI of the matching element, or an empty string if the parser is not namespace aware or the element has no namespacename- the local name if the parser is namespace aware, or just the element name otherwisetext- The body text of this element- Throws:
Exception
-
end
Invoked by the digester when the closing tag matching this Rule's pattern is encountered. -
getPattern
Return the pattern that this Rule is associated with.In general, Rule instances can be associated with multiple patterns. A PluginCreateRule, however, will only function correctly when associated with a single pattern. It is possible to fix this, but I can't be bothered just now because this feature is unlikely to be used.
- Returns:
- The pattern value
-
fireBeginMethods
public void fireBeginMethods(List<Rule> rules, String namespace, String name, Attributes list) throws Exception Duplicate the processing that the Digester does when firing the begin methods of rules. It would be really nice if the Digester class provided a way for this functionality to just be invoked directly.- Throws:
Exception
-
fireEndMethods
Duplicate the processing that the Digester does when firing the end methods of rules. It would be really nice if the Digester class provided a way for this functionality to just be invoked directly.- Throws:
Exception
-