Class DigesterRuleParser
- java.lang.Object
-
- org.apache.commons.digester.RuleSetBase
-
- org.apache.commons.digester.xmlrules.DigesterRuleParser
-
- All Implemented Interfaces:
RuleSet
public class DigesterRuleParser extends RuleSetBase
This is a RuleSet that parses XML into Digester rules, and then adds those rules to a 'target' Digester.- Since:
- 1.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classDigesterRuleParser.CallMethodRuleFactoryFactory for creating a CallMethodRule.protected classDigesterRuleParser.CallParamRuleFactoryFactory for creating a CallParamRule.protected classDigesterRuleParser.FactoryCreateRuleFactoryFactory for creating a FactoryCreateRuleprotected classDigesterRuleParser.NodeCreateRuleFactoryFactory for creating a NodeCreateRuleprotected classDigesterRuleParser.ObjectCreateRuleFactoryFactory for creating a ObjectCreateRuleprotected classDigesterRuleParser.ObjectParamRuleFactoryFactory for creating a ObjectParamRuleprotected classDigesterRuleParser.PatternStack<E>A stack whose toString method returns a '/'-separated concatenation of all the elements in the stack.protected classDigesterRuleParser.SetNestedPropertiesAliasRuleA rule for adding a attribute-property alias to the custom alias mappings of the containing SetNestedPropertiesRule rule.protected classDigesterRuleParser.SetNestedPropertiesRuleFactoryFactory for creating a SetNestedPropertiesRuleprotected classDigesterRuleParser.SetNextRuleFactoryFactory for creating a SetNextRuleFactoryprotected classDigesterRuleParser.SetPropertiesAliasRuleA rule for adding a attribute-property alias to the custom alias mappings of the containing SetPropertiesRule rule.protected classDigesterRuleParser.SetPropertiesRuleFactoryFactory for creating a SetPropertiesRuleprotected classDigesterRuleParser.SetPropertyRuleFactoryFactory for creating a SetPropertyRuleprotected classDigesterRuleParser.SetRootRuleFactoryFactory for creating a SetRootRuleFactoryprotected classDigesterRuleParser.SetTopRuleFactoryFactory for creating a SetTopRuleFactory
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringbasePathstatic java.lang.StringDIGESTER_PUBLIC_IDprotected DigesterRuleParser.PatternStack<java.lang.String>patternStackA stack used to maintain the current pattern.protected DigestertargetDigesterThis is the digester to which we are adding the rules that we parse from the Rules XML document.-
Fields inherited from class org.apache.commons.digester.RuleSetBase
namespaceURI
-
-
Constructor Summary
Constructors Constructor Description DigesterRuleParser()Constructs a DigesterRuleParser.DigesterRuleParser(Digester targetDigester)Constructs a rule set for converting XML digester rule descriptions into Rule objects, and adding them to the given Digester
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Rule rule)Adds a rule the the target digester.voidaddRuleInstances(Digester digester)Add to the given digester the set of Rule instances used to parse an XML document defining Digester rules.protected java.lang.StringgetDigesterRulesDTD()Returns the location of the DTD used to validate the digester rules XML document.voidsetBasePath(java.lang.String path)Set a base pattern beneath which all the rules loaded by this object will be registered.voidsetDigesterRulesDTD(java.lang.String dtdURL)Sets the location of the digester rules DTD.voidsetTarget(Digester d)Sets the digester into which to add the parsed rules-
Methods inherited from class org.apache.commons.digester.RuleSetBase
getNamespaceURI
-
-
-
-
Field Detail
-
DIGESTER_PUBLIC_ID
public static final java.lang.String DIGESTER_PUBLIC_ID
- See Also:
- Constant Field Values
-
targetDigester
protected Digester targetDigester
This is the digester to which we are adding the rules that we parse from the Rules XML document.
-
basePath
protected java.lang.String basePath
-
patternStack
protected DigesterRuleParser.PatternStack<java.lang.String> patternStack
A stack used to maintain the current pattern. The Rules XML document type allows nesting of patterns. If an element defines a matching pattern, the resulting pattern is a concatenation of that pattern with all the ancestor elements' patterns. Hence the need for a stack.
-
-
Constructor Detail
-
DigesterRuleParser
public DigesterRuleParser()
Constructs a DigesterRuleParser. This object will be inoperable until the target digester is set, viasetTarget(Digester)
-
DigesterRuleParser
public DigesterRuleParser(Digester targetDigester)
Constructs a rule set for converting XML digester rule descriptions into Rule objects, and adding them to the given Digester- Parameters:
targetDigester- the Digester to add the rules to
-
-
Method Detail
-
setTarget
public void setTarget(Digester d)
Sets the digester into which to add the parsed rules- Parameters:
d- the Digester to add the rules to
-
setBasePath
public void setBasePath(java.lang.String path)
Set a base pattern beneath which all the rules loaded by this object will be registered. If this string is not empty, and does not end in a "/", then one will be added.- Since:
- 1.6
-
setDigesterRulesDTD
public void setDigesterRulesDTD(java.lang.String dtdURL)
Sets the location of the digester rules DTD. This is the DTD used to validate the rules XML file.
-
getDigesterRulesDTD
protected java.lang.String getDigesterRulesDTD()
Returns the location of the DTD used to validate the digester rules XML document.
-
add
public void add(Rule rule)
Adds a rule the the target digester. After a rule has been created by parsing the XML, it is added to the digester by calling this method. Typically, this method is called via reflection, when executing a SetNextRule, from the Digester that is parsing the rules XML.- Parameters:
rule- a Rule to add to the target digester.
-
addRuleInstances
public void addRuleInstances(Digester digester)
Add to the given digester the set of Rule instances used to parse an XML document defining Digester rules. When the digester parses an XML file, it will add the resulting rules & patterns to the 'target digester' that was passed in this RuleSet's constructor.If you extend this class to support additional rules, your implementation should of this method should call this implementation first: i.e.
super.addRuleInstances(digester);- Specified by:
addRuleInstancesin interfaceRuleSet- Specified by:
addRuleInstancesin classRuleSetBase- Parameters:
digester- Digester instance to which the new Rule instances should be added.
-
-