org.apache.commons.digester.xmlrules

Class DigesterRuleParser.IncludeRule

Enclosing Class:
DigesterRuleParser

private class DigesterRuleParser.IncludeRule
extends Rule

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.

Field Summary

Fields inherited from class org.apache.commons.digester.Rule

digester, namespaceURI

Constructor Summary

IncludeRule()

Method Summary

void
begin(Attributes attributes)
To include a rules xml file, we instantiate another Digester, and another DigesterRulesRuleSet.
private void
includeProgrammaticRules(String className)
Creates an instance of the indicated class.
private void
includeXMLRules(String fileName)
Creates another DigesterRuleParser, and uses it to extract the rules out of the give XML file.

Methods inherited from class org.apache.commons.digester.Rule

begin, begin, body, body, end, end, finish, getDigester, getNamespaceURI, setDigester, setNamespaceURI

Constructor Details

IncludeRule

public IncludeRule()

Method Details

begin

public void begin(Attributes attributes)
            throws Exception
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.
Overrides:
begin in interface Rule


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.


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.


Copyright 2001-2005 The Apache Software Foundation.