java.lang.Objectorg.apache.commons.digester.Rule
Direct Known Subclasses:
SetNestedPropertiesRule, BeanPropertySetterRule, ObjectCreateRule, SetPropertiesRule, DumperRule, FactoryCreateRule, PluginDeclarationRule, NodeCreateRule, SetRootRule, SetPropertiesAliasRule, AnyChildRule, TestRule, ObjectParamRule, CallMethodRule, PathCallParamRule, SetTopRule, SetPropertyRule, IncludeRule, PluginCreateRule, SetNextRule, SetNestedPropertiesAliasRule, PatternRule, CallParamRule
Writing a custom Rule is considered perfectly normal when using Digester, and is encouraged whenever the default set of Rule classes don't meet your requirements; the digester framework can help process xml even when the built-in rules aren't quite what is needed. Creating a custom Rule is just as easy as subclassing javax.servlet.http.HttpServlet for webapps, or javax.swing.Action for GUI applications.
If a rule wishes to manipulate a digester stack (the default object stack, a named stack, or the parameter stack) then it should only ever push objects in the rule's begin method and always pop exactly the same number of objects off the stack during the rule's end method. Of course peeking at the objects on the stacks can be done from anywhere.
Rule objects should be stateless, ie they should not update any instance member during the parsing process. A rule instance that changes state will encounter problems if invoked in a "nested" manner; this can happen if the same instance is added to digester multiple times or if a wildcard pattern is used which can match both an element and a child of the same element. The digester object stack and named stacks should be used to store any state that a rule requires, making the rule class safe under all possible uses.
| Field Summary | ||
|---|---|---|
| protected Digester | digester | The Digester with which this Rule is associated. |
| protected String | namespaceURI | The namespace URI for which this Rule is relevant, if any. |
| Constructor: |
|---|
Base constructor. Now the digester will be set when the rule is added. |
|
| Method from org.apache.commons.digester.Rule Summary: |
|---|
| begin, begin, body, body, end, end, finish, getDigester, getNamespaceURI, setDigester, setNamespaceURI |
| Methods from java.lang.Object: |
|---|
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from org.apache.commons.digester.Rule Detail: |
|---|
Deprecated! Use - the begin
method with namespace and name
parameters instead.
|
namespace and name parameters, to retain
backwards compatibility. |
Deprecated! Use - the body method
with namespace and name parameters
instead.
|
The default implementation delegates to the deprecated method
body without the |
Deprecated! Use - the end method with
namespace and name parameters instead.
|
namespace and name parameters, to retain
backwards compatibility. |
|
|
|
Digester with which this Rule is associated. |
|