Class PluginRules
- java.lang.Object
-
- org.apache.commons.digester.plugins.PluginRules
-
- All Implemented Interfaces:
Rules
public class PluginRules extends java.lang.Object implements Rules
A custom digester Rules manager which must be used as the Rules object when using the plugins module functionality.During parsing, a linked list of PluginCreateRule instances develop, and this list also acts like a stack. The original instance that was set before the Digester started parsing is always at the tail of the list, and the Digester always holds a reference to the instance at the head of the list in the rules member. Initially, this list/stack holds just one instance, ie head and tail are the same object.
When the start of an xml element causes a PluginCreateRule to fire, a new PluginRules instance is created and inserted at the head of the list (ie pushed onto the stack of Rules objects). Digester.getRules() therefore returns this new Rules object, and any custom rules associated with that plugin are added to that instance.
When the end of the xml element is encountered (and therefore the PluginCreateRule end method fires), the stack of Rules objects is popped, so that Digester.getRules returns the previous Rules object.
- Since:
- 1.6
-
-
Constructor Summary
Constructors Constructor Description PluginRules()
Constructor for top-level Rules objects.PluginRules(Rules decoratedRules)
Constructor for top-level Rules object which handles rule-matching using the specified implementation.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
add(java.lang.String pattern, Rule rule)
Register a new Rule instance matching the specified pattern.void
clear()
Clear all rules.Digester
getDigester()
Return the Digester instance with which this instance is associated.java.lang.String
getNamespaceURI()
Return the namespace URI that will be applied to all subsequently addedRule
objects.Rules
getParent()
Return the parent Rules object.java.lang.String
getPluginClassAttr()
java.lang.String
getPluginClassAttrNs()
java.lang.String
getPluginIdAttr()
java.lang.String
getPluginIdAttrNs()
PluginManager
getPluginManager()
Return the object which "knows" about all declared plugins.java.util.List<RuleFinder>
getRuleFinders()
RulesFactory
getRulesFactory()
Return the rules factory object (or null if one has not been specified).java.util.List<Rule>
match(java.lang.String path)
Deprecated.Call match(namespaceURI,pattern) instead.java.util.List<Rule>
match(java.lang.String namespaceURI, java.lang.String path)
Return a List of all registered Rule instances that match the specified nodepath, or a zero-length List if there are no matches.java.util.List<Rule>
rules()
Return the list of rules registered with this object, in the order they were registered with this object.void
setDigester(Digester digester)
Set the Digester instance with which this Rules instance is associated.void
setNamespaceURI(java.lang.String namespaceURI)
Set the namespace URI that will be applied to all subsequently addedRule
objects.void
setPluginClassAttribute(java.lang.String namespaceUri, java.lang.String attrName)
void
setPluginIdAttribute(java.lang.String namespaceUri, java.lang.String attrName)
void
setRuleFinders(java.util.List<RuleFinder> ruleFinders)
void
setRulesFactory(RulesFactory factory)
Set the object which is used to generate the new Rules instances created to hold and process the rules associated with each plugged-in class.
-
-
-
Constructor Detail
-
PluginRules
public PluginRules()
Constructor for top-level Rules objects. Exactly one of these must be created and installed into the Digester instance as the Rules object before parsing starts.
-
PluginRules
public PluginRules(Rules decoratedRules)
Constructor for top-level Rules object which handles rule-matching using the specified implementation.
-
-
Method Detail
-
getDigester
public Digester getDigester()
Return the Digester instance with which this instance is associated.- Specified by:
getDigester
in interfaceRules
-
setDigester
public void setDigester(Digester digester)
Set the Digester instance with which this Rules instance is associated.- Specified by:
setDigester
in interfaceRules
- Parameters:
digester
- The newly associated Digester instance
-
getNamespaceURI
public java.lang.String getNamespaceURI()
Return the namespace URI that will be applied to all subsequently addedRule
objects.- Specified by:
getNamespaceURI
in interfaceRules
-
setNamespaceURI
public void setNamespaceURI(java.lang.String namespaceURI)
Set the namespace URI that will be applied to all subsequently addedRule
objects.- Specified by:
setNamespaceURI
in interfaceRules
- Parameters:
namespaceURI
- Namespace URI that must match on all subsequently added rules, ornull
for matching regardless of the current namespace URI
-
getPluginManager
public PluginManager getPluginManager()
Return the object which "knows" about all declared plugins.- Returns:
- The pluginManager value
-
getRuleFinders
public java.util.List<RuleFinder> getRuleFinders()
-
setRuleFinders
public void setRuleFinders(java.util.List<RuleFinder> ruleFinders)
-
getRulesFactory
public RulesFactory getRulesFactory()
Return the rules factory object (or null if one has not been specified).
-
setRulesFactory
public void setRulesFactory(RulesFactory factory)
Set the object which is used to generate the new Rules instances created to hold and process the rules associated with each plugged-in class.
-
rules
public java.util.List<Rule> rules()
Return the list of rules registered with this object, in the order they were registered with this object.Note that Rule objects stored in parent Rules objects are not returned by this method.
-
add
public void add(java.lang.String pattern, Rule rule)
Register a new Rule instance matching the specified pattern.
-
match
@Deprecated public java.util.List<Rule> match(java.lang.String path)
Deprecated.Call match(namespaceURI,pattern) instead.Return a List of all registered Rule instances that match the specified nesting pattern, or a zero-length List if there are no matches. If more than one Rule instance matches, they must be returned in the order originally registered through theadd()
method.
-
match
public java.util.List<Rule> match(java.lang.String namespaceURI, java.lang.String path)
Return a List of all registered Rule instances that match the specified nodepath, or a zero-length List if there are no matches. If more than one Rule instance matches, they must be returned in the order originally registered through theadd()
method.
-
setPluginClassAttribute
public void setPluginClassAttribute(java.lang.String namespaceUri, java.lang.String attrName)
-
setPluginIdAttribute
public void setPluginIdAttribute(java.lang.String namespaceUri, java.lang.String attrName)
-
getPluginClassAttrNs
public java.lang.String getPluginClassAttrNs()
-
getPluginClassAttr
public java.lang.String getPluginClassAttr()
-
getPluginIdAttrNs
public java.lang.String getPluginIdAttrNs()
-
getPluginIdAttr
public java.lang.String getPluginIdAttr()
-
-