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.

    • Constructor Summary

      Constructors 
      Constructor Description
      IncludeRule()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void begin​(org.xml.sax.Attributes attributes)
      To include a rules xml file, we instantiate another Digester, and another DigesterRulesRuleSet.
      private void includeProgrammaticRules​(java.lang.String className)
      Creates an instance of the indicated class.
      private void includeXMLRules​(java.lang.String fileName)
      Creates another DigesterRuleParser, and uses it to extract the rules out of the give XML file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IncludeRule

        public IncludeRule()
    • Method Detail

      • begin

        public void begin​(org.xml.sax.Attributes attributes)
                   throws java.lang.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 class Rule
        Parameters:
        attributes - The attribute list of this element
        Throws:
        java.lang.Exception
      • includeXMLRules

        private void includeXMLRules​(java.lang.String fileName)
                              throws java.io.IOException,
                                     org.xml.sax.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.
        Throws:
        java.io.IOException
        org.xml.sax.SAXException
        CircularIncludeException
      • includeProgrammaticRules

        private void includeProgrammaticRules​(java.lang.String className)
                                       throws java.lang.ClassNotFoundException,
                                              java.lang.ClassCastException,
                                              java.lang.InstantiationException,
                                              java.lang.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.
        Throws:
        java.lang.ClassNotFoundException
        java.lang.ClassCastException
        java.lang.InstantiationException
        java.lang.IllegalAccessException