Class PluginRules
- All Implemented Interfaces:
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.
- Since:
- 1.6
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for top-level Rules objects.PluginRules(Rules decoratedRules) Constructor for top-level Rules object which handles rule-matching using the specified implementation. -
Method Summary
Modifier and TypeMethodDescriptionvoidRegister a new Rule instance matching the specified pattern.voidclear()Clear all rules.Return the Digester instance with which this instance is associated.Return the namespace URI that will be applied to all subsequently addedRuleobjects.Return the parent Rules object.Return the object which "knows" about all declared plugins.Return the rules factory object (or null if one has not been specified).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.rules()Return the list of rules registered with this object, in the order they were registered with this object.voidsetDigester(Digester digester) Set the Digester instance with which this Rules instance is associated.voidsetNamespaceURI(String namespaceURI) Set the namespace URI that will be applied to all subsequently addedRuleobjects.voidsetPluginClassAttribute(String namespaceUri, String attrName) voidsetPluginIdAttribute(String namespaceUri, String attrName) voidsetRuleFinders(List<RuleFinder> ruleFinders) voidsetRulesFactory(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.
-
Field Details
-
digester
-
-
Constructor Details
-
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
Constructor for top-level Rules object which handles rule-matching using the specified implementation.- Parameters:
decoratedRules- The top-level Rules object which handles rule-matching using the specified implementation.
-
-
Method Details
-
getParent
-
getDigester
Return the Digester instance with which this instance is associated.- Specified by:
getDigesterin interfaceRules- Returns:
- the Digester instance with which this instance is associated.
-
setDigester
Set the Digester instance with which this Rules instance is associated.- Specified by:
setDigesterin interfaceRules- Parameters:
digester- The newly associated Digester instance
-
getNamespaceURI
Return the namespace URI that will be applied to all subsequently addedRuleobjects.- Specified by:
getNamespaceURIin interfaceRules- Returns:
- the namespace URI that will be applied to all subsequently added
Ruleobjects.
-
setNamespaceURI
Set the namespace URI that will be applied to all subsequently addedRuleobjects.- Specified by:
setNamespaceURIin interfaceRules- Parameters:
namespaceURI- Namespace URI that must match on all subsequently added rules, ornullfor matching regardless of the current namespace URI
-
getPluginManager
Return the object which "knows" about all declared plugins.- Returns:
- The pluginManager value
-
getRuleFinders
- Returns:
- the list of RuleFinder objects
-
setRuleFinders
- Parameters:
ruleFinders- the list of RuleFinder objects
-
getRulesFactory
Return the rules factory object (or null if one has not been specified).- Returns:
- the rules factory object.
-
setRulesFactory
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.- Parameters:
factory- the rules factory object
-
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
Register a new Rule instance matching the specified pattern. -
clear
-
match
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.- Specified by:
matchin interfaceRules- Parameters:
namespaceURI- Namespace URI for which to select matching rules, ornullto 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 element- Returns:
- a List of all registered Rule instances that match the specified nesting pattern
-
setPluginClassAttribute
- Parameters:
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.
-
setPluginIdAttribute
- Parameters:
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.
-
getPluginClassAttrNs
- Returns:
- the namespace for the xml attribute which indicates which class is to be plugged in.
-
getPluginClassAttr
- Returns:
- the namespace for the xml attribute which indicates which class is to be plugged in.
-
getPluginIdAttrNs
- Returns:
- the namespace for the xml attribute which indicates which previous plugin declaration should be used.
-
getPluginIdAttr
- Returns:
- the namespace for the xml attribute which indicates which previous plugin declaration should be used.
-