|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.digester.plugins.PluginRules
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.
Field Summary | |
private Rules |
decoratedRules
The rules implementation that we are "enhancing" with plugins functionality, as per the Decorator pattern. |
protected Digester |
digester
The Digester instance with which this Rules instance is associated. |
private java.lang.String |
mountPoint
The path below which this rules object has responsibility. |
private PluginRules |
parent
The Rules object that holds rules applying "above" the mountpoint, ie the next Rules object down in the stack. |
private PluginContext |
pluginContext
A reference to the object that holds all data which should only exist once per digester instance. |
private PluginManager |
pluginManager
Object which contains information about all known plugins. |
Constructor Summary | |
|
PluginRules()
Constructor for top-level Rules objects. |
|
PluginRules(Rules decoratedRules)
Constructor for top-level Rules object which handles rule-matching using the specified implementation. |
(package private) |
PluginRules(java.lang.String mountPoint,
PluginRules parent)
Constructs a Rules instance which has a parent Rules object (which is different from having a delegate rules object). |
Method Summary | |
void |
add(java.lang.String pattern,
Rule rule)
Register a new Rule instance matching the specified pattern. |
void |
clear()
Clear all rules. |
(package private) Rules |
getDecoratedRules()
This package-scope method is used by the PluginCreateRule class to get direct access to the rules that were dynamically added by the plugin. |
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 added Rule objects. |
Rules |
getParent()
Return the parent Rules object. |
java.lang.String |
getPluginClassAttr()
See PluginContext.getPluginClassAttr() . |
java.lang.String |
getPluginClassAttrNs()
See PluginContext.getPluginClassAttrNs() . |
java.lang.String |
getPluginIdAttr()
See PluginContext.getPluginIdAttr() . |
java.lang.String |
getPluginIdAttrNs()
See PluginContext.getPluginIdAttrNs() . |
PluginManager |
getPluginManager()
Return the object which "knows" about all declared plugins. |
java.util.List |
getRuleFinders()
See PluginContext.getRuleFinders() . |
java.util.List |
match(java.lang.String path)
Deprecated. Call match(namespaceURI,pattern) instead. |
java.util.List |
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 |
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 added Rule objects. |
void |
setPluginClassAttribute(java.lang.String namespaceUri,
java.lang.String attrName)
See PluginContext.setPluginClassAttribute(java.lang.String, java.lang.String) . |
void |
setPluginIdAttribute(java.lang.String namespaceUri,
java.lang.String attrName)
See PluginContext.setPluginIdAttribute(java.lang.String, java.lang.String) . |
void |
setRuleFinders(java.util.List ruleFinders)
See PluginContext.setRuleFinders(java.util.List) . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Digester digester
private Rules decoratedRules
private PluginManager pluginManager
private java.lang.String mountPoint
private PluginRules parent
private PluginContext pluginContext
Constructor Detail |
public PluginRules()
public PluginRules(Rules decoratedRules)
PluginRules(java.lang.String mountPoint, PluginRules parent)
One of these is created each time a PluginCreateRule's begin method fires, in order to manage the custom rules associated with whatever concrete plugin class the user has specified.
mountPoint
- is the digester match path for the element
matching a PluginCreateRule which caused this "nested parsing scope"
to begin.parent
- must be non-null.Method Detail |
public Rules getParent()
public Digester getDigester()
getDigester
in interface Rules
public void setDigester(Digester digester)
setDigester
in interface Rules
digester
- The newly associated Digester instancepublic java.lang.String getNamespaceURI()
Rule
objects.
getNamespaceURI
in interface Rules
public void setNamespaceURI(java.lang.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 java.util.List getRuleFinders()
PluginContext.getRuleFinders()
.
public void setRuleFinders(java.util.List ruleFinders)
PluginContext.setRuleFinders(java.util.List)
.
Rules getDecoratedRules()
public java.util.List rules()
Note that Rule objects stored in parent Rules objects are not returned by this method.
rules
in interface Rules
public void add(java.lang.String pattern, Rule rule)
add
in interface Rules
pattern
- Nesting pattern to be matched for this Rule.
This parameter treats equally patterns that begin with and without
a leading slash ('/').rule
- Rule instance to be registeredpublic void clear()
clear
in interface Rules
public java.util.List match(java.lang.String path)
add()
method.
match
in interface Rules
path
- the path to the xml nodes to be matched.public java.util.List match(java.lang.String namespaceURI, java.lang.String path)
add()
method.
match
in interface Rules
namespaceURI
- Namespace URI for which to select matching rules,
or null
to match regardless of namespace URIpath
- the path to the xml nodes to be matched.public void setPluginClassAttribute(java.lang.String namespaceUri, java.lang.String attrName)
PluginContext.setPluginClassAttribute(java.lang.String, java.lang.String)
.
public void setPluginIdAttribute(java.lang.String namespaceUri, java.lang.String attrName)
PluginContext.setPluginIdAttribute(java.lang.String, java.lang.String)
.
public java.lang.String getPluginClassAttrNs()
PluginContext.getPluginClassAttrNs()
.
public java.lang.String getPluginClassAttr()
PluginContext.getPluginClassAttr()
.
public java.lang.String getPluginIdAttrNs()
PluginContext.getPluginIdAttrNs()
.
public java.lang.String getPluginIdAttr()
PluginContext.getPluginIdAttr()
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |