Class SaxRule

  • Direct Known Subclasses:
    OAIMetadataSaxRule

    public class SaxRule
    extends org.apache.commons.digester.Rule
    This class is used as a rule for included documents during Digester parsing. Whenever this element matches in Digester, begin/end will be called, that then puts all further SAX events to the specified SAX ContentHandler.
    Author:
    Uwe Schindler
    • Constructor Detail

      • SaxRule

        public SaxRule()
        Default constructor
    • Method Detail

      • emptyRule

        public static SaxRule emptyRule()
        Creates an empty "useless" SaxRule. The pupose is to not throw an exception on known but ignored elements (optional with contents).
        Returns:
        an instance that does nothing by feeding all SAX events to an SAX DefaultHandler
      • setDigester

        public void setDigester​(org.apache.commons.digester.Digester digester)
        Set the Digester with which this Rule is associated.
        Overrides:
        setDigester in class org.apache.commons.digester.Rule
        Throws:
        IllegalArgumentException - if digester is not an ExtendedDigester instance.
      • setContentHandler

        public void setContentHandler​(ContentHandler ch)
        Sets the SAX ContentHandler that gets all SAX Events after the startElement event.
      • getContentHandler

        public ContentHandler getContentHandler()
        return the current ContentHandler.
      • setExcludeNamespaces

        public void setExcludeNamespaces​(Set<String> excludeNamespaces)
        Sets a Set<String> containing all Namespace URIs that should not be feed to the target ContentHandler on match. Default (or setting to null) means no restriction: All namespace prefixes visible in the current context will be reported.
      • initDocument

        protected void initDocument()
                             throws SAXException
        Add some elements when document started. The default implementation does nothing. This method should be overwritten to feed some additional elements after the startDocument SAX event.
        Throws:
        SAXException
      • finishDocument

        protected void finishDocument()
                               throws SAXException
        Closes the elements created in initDocument(). The default implementation does nothing. This method should be overwritten to feed some ending elements before the endDocument SAX event.
        Throws:
        SAXException
      • end

        public void end​(String namespace,
                        String name)
                 throws Exception
        Overrides:
        end in class org.apache.commons.digester.Rule
        Throws:
        Exception