public class PluginRules extends Object implements Rules
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.
Modifier and Type | Field and Description |
---|---|
protected Digester |
digester
The Digester instance with which this Rules instance is associated.
|
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
void |
add(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.
|
String |
getNamespaceURI()
Return the namespace URI that will be applied to all subsequently added
Rule objects. |
Rules |
getParent()
Return the parent Rules object.
|
String |
getPluginClassAttr()
|
String |
getPluginClassAttrNs()
|
String |
getPluginIdAttr()
|
String |
getPluginIdAttrNs()
|
PluginManager |
getPluginManager()
Return the object which "knows" about all declared plugins.
|
List<RuleFinder> |
getRuleFinders()
|
RulesFactory |
getRulesFactory()
Return the rules factory object (or null if one has not been specified).
|
List<Rule> |
match(String namespaceURI,
String path,
String name,
Attributes attributes)
Return a List of all registered Rule instances that match the specified nesting pattern, or a zero-length List if
there are no matches.
|
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(String namespaceURI)
Set the namespace URI that will be applied to all subsequently added
Rule objects. |
void |
setPluginClassAttribute(String namespaceUri,
String attrName)
|
void |
setPluginIdAttribute(String namespaceUri,
String attrName)
|
void |
setRuleFinders(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.
|
public PluginRules()
public PluginRules(Rules decoratedRules)
decoratedRules
- The top-level Rules object which handles rule-matching using the specified implementation.public Digester getDigester()
getDigester
in interface Rules
public void setDigester(Digester digester)
setDigester
in interface Rules
digester
- The newly associated Digester instancepublic String getNamespaceURI()
Rule
objects.getNamespaceURI
in interface Rules
Rule
objects.public void setNamespaceURI(String namespaceURI)
Rule
objects.setNamespaceURI
in interface Rules
namespaceURI
- Namespace URI that must match on all subsequently added rules, or null
for
matching regardless of the current namespace URIpublic PluginManager getPluginManager()
public List<RuleFinder> getRuleFinders()
public void setRuleFinders(List<RuleFinder> ruleFinders)
ruleFinders
- the list of RuleFinder objectspublic RulesFactory getRulesFactory()
public void setRulesFactory(RulesFactory factory)
factory
- the rules factory objectpublic List<Rule> rules()
Note that Rule objects stored in parent Rules objects are not returned by this method.
public void add(String pattern, Rule rule)
public List<Rule> match(String namespaceURI, String path, String name, Attributes attributes)
add()
method.match
in interface Rules
namespaceURI
- Namespace URI for which to select matching rules, or null
to match regardless of
namespace URIpath
- Nesting pattern to be matchedname
- the local name if the parser is namespace aware, or just the element name otherwiseattributes
- The attribute list of the current matching elementpublic void setPluginClassAttribute(String namespaceUri, String attrName)
namespaceUri
- is the namespace uri that the specified attribute is in. If the attribute is in no namespace,
then this should be null. Note that if a namespace is used, the attrName value should not
contain any kind of namespace-prefix. Note also that if you are using a non-namespace-aware parser,
this parameter must be null.attrName
- is the attribute whose value contains the name of the class to be instantiated.public void setPluginIdAttribute(String namespaceUri, String attrName)
namespaceUri
- is the namespace uri that the specified attribute is in. If the attribute is in no namespace,
then this should be null. Note that if a namespace is used, the attrName value should not
contain any kind of namespace-prefix. Note also that if you are using a non-namespace-aware parser,
this parameter must be null.attrName
- is the attribute whose value contains the id of the plugin declaration to be used when
instantiating an object.public String getPluginClassAttrNs()
public String getPluginClassAttr()
public String getPluginIdAttrNs()
public String getPluginIdAttr()
Copyright © 2001-2013 The Apache Software Foundation. All Rights Reserved.