Class DigesterRuleParser.IncludeRule
java.lang.Object
org.apache.commons.digester.Rule
org.apache.commons.digester.xmlrules.DigesterRuleParser.IncludeRule
- Enclosing class:
DigesterRuleParser
A rule for including one rules XML file within another. Included files
behave as if they are 'macro-expanded' within the includer. This means
that the values of the pattern stack are prefixed to every pattern
in the included rules.
This rule will detect 'circular' includes, which would result in infinite recursion. It throws a CircularIncludeException when a cycle is detected, which will terminate the parse.
- Since:
- 1.2
-
Field Summary
Fields inherited from class Rule
digester, namespaceURI -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbegin(Attributes attributes) To include a rules xml file, we instantiate another Digester, and another DigesterRulesRuleSet.private voidincludeProgrammaticRules(String className) Creates an instance of the indicated class.private voidincludeXMLRules(String fileName) Creates another DigesterRuleParser, and uses it to extract the rules out of the give XML file.Methods inherited from class Rule
begin, body, body, end, end, finish, getDigester, getNamespaceURI, setDigester, setNamespaceURI
-
Constructor Details
-
IncludeRule
public IncludeRule()
-
-
Method Details
-
begin
To include a rules xml file, we instantiate another Digester, and another DigesterRulesRuleSet. We pass the pattern stack and the target Digester to the new rule set, and tell the Digester to parse the file. -
includeXMLRules
private void includeXMLRules(String fileName) throws IOException, SAXException, CircularIncludeException Creates another DigesterRuleParser, and uses it to extract the rules out of the give XML file. The contents of the current pattern stack will be prepended to all of the pattern strings parsed from the file. -
includeProgrammaticRules
private void includeProgrammaticRules(String className) throws ClassNotFoundException, ClassCastException, InstantiationException, IllegalAccessException Creates an instance of the indicated class. The class must implement the DigesterRulesSource interface. Passes the target digester to that instance. The DigesterRulesSource instance is supposed to add rules into the digester. The contents of the current pattern stack will be automatically prepended to all of the pattern strings added by the DigesterRulesSource instance.
-