org.apache.commons.digester.xmlrules
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.

Author:
David H. Martin - Initial Contribution, Scott Sanders - Added ASL, removed external dependencies, Bradley M. Handy - Bean Property Setter Rule addition

Nested Class Summary
private  class DigesterRuleParser.BeanPropertySetterRuleFactory
          Factory for creating a BeanPropertySetterRule.
protected  class DigesterRuleParser.CallMethodRuleFactory
          Factory for creating a CallMethodRule.
protected  class DigesterRuleParser.CallParamRuleFactory
          Factory for creating a CallParamRule.
protected  class DigesterRuleParser.FactoryCreateRuleFactory
          Factory for creating a FactoryCreateRule
private  class DigesterRuleParser.IncludeRule
          A rule for including one rules XML file within another.
protected  class DigesterRuleParser.ObjectCreateRuleFactory
          Factory for creating a ObjectCreateRule
private  class DigesterRuleParser.PatternRule
          A rule for extracting the pattern matching strings from the rules XML.
protected  class DigesterRuleParser.PatternStack
          A stack whose toString method returns a '/'-separated concatenation of all the elements in the stack.
private  class DigesterRuleParser.RulesPrefixAdapter
          Wraps a Rules object.
protected  class DigesterRuleParser.SetNextRuleFactory
          Factory for creating a SetNextRuleFactory
protected  class DigesterRuleParser.SetPropertiesAliasRule
          A rule for adding a attribute-property alias to the custom alias mappings of the containing SetPropertiesRule rule.
protected  class DigesterRuleParser.SetPropertiesRuleFactory
          Factory for creating a SetPropertiesRule
protected  class DigesterRuleParser.SetPropertyRuleFactory
          Factory for creating a SetPropertyRule
protected  class DigesterRuleParser.SetTopRuleFactory
          Factory for creating a SetTopRuleFactory
 
Field Summary
static java.lang.String DIGESTER_PUBLIC_ID
           
private  java.lang.String digesterDtdUrl
          path to the DTD
private  java.util.Set includedFiles
          Used to detect circular includes
protected  DigesterRuleParser.PatternStack patternStack
          A stack used to maintain the current pattern.
protected  Digester targetDigester
          This 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
  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
private DigesterRuleParser(Digester targetDigester, DigesterRuleParser.PatternStack stack, java.util.Set includedFiles)
          Constructs a rule set for parsing an XML digester rule file that has been included within an outer XML digester rule file.
 
Method Summary
 void add(Rule rule)
          Adds a rule the the target digester.
 void addRuleInstances(Digester digester)
          Add to the given digester the set of Rule instances used to parse an XML document defining Digester rules.
protected  java.lang.String getDigesterRulesDTD()
          Returns the location of the DTD used to validate the digester rules XML document.
 void setDigesterRulesDTD(java.lang.String dtdURL)
          Sets the location of the digester rules DTD.
 void setTarget(Digester d)
          Sets the digester into which to add the parsed rules
 
Methods inherited from class org.apache.commons.digester.RuleSetBase
getNamespaceURI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIGESTER_PUBLIC_ID

public static final java.lang.String DIGESTER_PUBLIC_ID
See Also:
Constant Field Values

digesterDtdUrl

private java.lang.String digesterDtdUrl
path to the DTD


targetDigester

protected Digester targetDigester
This is the digester to which we are adding the rules that we parse from the Rules XML document.


patternStack

protected DigesterRuleParser.PatternStack 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.


includedFiles

private java.util.Set includedFiles
Used to detect circular includes

Constructor Detail

DigesterRuleParser

public DigesterRuleParser()
Constructs a DigesterRuleParser. This object will be inoperable until the target digester is set, via setTarget(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

DigesterRuleParser

private DigesterRuleParser(Digester targetDigester,
                           DigesterRuleParser.PatternStack stack,
                           java.util.Set includedFiles)
Constructs a rule set for parsing an XML digester rule file that has been included within an outer XML digester rule file. In this case, we must pass the pattern stack and the target digester to the rule set, as well as the list of files that have already been included, for cycle detection.

Parameters:
targetDigester - the Digester to add the rules to
stack - Stack containing the prefix pattern string to be prepended to any pattern parsed by this rule set.
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

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:
addRuleInstances in interface RuleSet
Specified by:
addRuleInstances in class RuleSetBase
Parameters:
digester - Digester instance to which the new Rule instances should be added.


Copyright (c) 2001-2003 - Apache Software Foundation