Class ExtendedDigester

  • All Implemented Interfaces:
    ContentHandler, DTDHandler, EntityResolver, ErrorHandler

    public class ExtendedDigester
    extends org.apache.commons.digester.Digester
    Extension of the Commons Digester Class, that works around some limitations/bugs. It is especially important for SaxRule, as it supports a stack/list of namespace-prefix assignments, and contains a integrated error handler. It also gives the possibility to not allow invalid element names.
    Author:
    Uwe Schindler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected HashMap<String,​LinkedList<String>> currentNamespaceMap  
      protected ContentHandler custContentHandler  
      • Fields inherited from class org.apache.commons.digester.Digester

        bodyText, bodyTexts, classLoader, configured, entityResolver, entityValidator, errorHandler, factory, inputSources, JAXP_SCHEMA_LANGUAGE, locator, log, match, matches, namespaceAware, namespaces, params, parser, publicId, reader, root, rules, saxLog, schema, schemaLanguage, schemaLocation, stack, substitutor, useContextClassLoader, validating, W3C_XML_SCHEMA, xincludeAware
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addDoNothing​(String pattern)
      Adds a dummy rule for element paths, that are allowed, but not parsed.
      void characters​(char[] ch, int start, int length)  
      void clear()  
      void endElement​(String uri, String localName, String qName)  
      void endPrefixMapping​(String prefix)  
      void error​(SAXParseException ex)
      Just throws ex.
      void fatalError​(SAXParseException ex)
      Just throws ex.
      Set<String> getCurrentAssignedPrefixes()
      Returns all current namespace prefix that are assigned.
      NamespaceContext getCurrentNamespaceContext​(boolean strict, boolean reDefineDefaultPrefix)
      Returns the current NamespaceContext for compiling XPath expressions.
      String getCurrentNamespaceForPrefix​(String prefix)
      Returns the current namespace URI for the given prefix.
      Map<String,​String> getCurrentNamespaceMap()
      Returns the current namespace prefix mappings as modifiable Map containing the prefix and the current namespace assignment (it is just a copy of the internal representation's current mapping).
      ContentHandler getCustomContentHandler()
      Gets the custom event handler.
      ErrorHandler getErrorHandler()
      Not supported, always returns null
      void ignorableWhitespace​(char[] ch, int start, int length)  
      void processingInstruction​(String target, String data)  
      void replayEndPrefixMappings​(ContentHandler handler, Set<String> excludeNamespaces)
      Replays all current prefix mappings for another ContentHandler (end mapping).
      void replayStartPrefixMappings​(ContentHandler handler, Set<String> excludeNamespaces)
      Replays all current prefix mappings for another ContentHandler (start mapping).
      void setCustomContentHandler​(ContentHandler c)
      Sets a custom ContentHandler, that receives all SAX events until disabled (null).
      void setErrorHandler​(ErrorHandler err)
      Not suppoted, always throws IllegalArgumentException if not null.
      void setRulesWithInvalidElementCheck​(org.apache.commons.digester.Rules rules)
      Adds a default Rule for not allowing invalid (not registered) event paths.
      void skippedEntity​(String name)  
      void startDocument()  
      void startElement​(String uri, String localName, String qName, Attributes atts)  
      void startPrefixMapping​(String prefix, String uri)  
      void warning​(SAXParseException ex)
      Logs the SAX exception as warning (with location).
      • Methods inherited from class org.apache.commons.digester.Digester

        addBeanPropertySetter, addBeanPropertySetter, addCallMethod, addCallMethod, addCallMethod, addCallMethod, addCallParam, addCallParam, addCallParam, addCallParam, addCallParamPath, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addObjectCreate, addObjectCreate, addObjectCreate, addObjectCreate, addObjectParam, addRule, addRuleSet, addSetNestedProperties, addSetNestedProperties, addSetNestedProperties, addSetNext, addSetNext, addSetProperties, addSetProperties, addSetProperties, addSetProperty, addSetRoot, addSetRoot, addSetTop, addSetTop, cleanup, configure, createInputSourceFromURL, createInputSourceFromURL, createSAXException, createSAXException, createSAXException, endDocument, findNamespaceURI, getClassLoader, getCount, getCurrentElementName, getCurrentNamespaces, getDebug, getDocumentLocator, getEntityResolver, getFactory, getFeature, getLogger, getMatch, getNamespaceAware, getParser, getProperty, getPublicId, getReader, getRoot, getRuleNamespaceURI, getRules, getSAXLogger, getSchema, getSchemaLanguage, getStackAction, getSubstitutor, getUseContextClassLoader, getValidating, getXIncludeAware, getXMLReader, getXMLSchema, initialize, isEmpty, log, log, notationDecl, parse, parse, parse, parse, parse, parse, peek, peek, peek, peek, peekParams, peekParams, pop, pop, popParams, push, push, pushParams, register, register, resetRoot, resolveEntity, setClassLoader, setDebug, setDocumentLocator, setEntityResolver, setFeature, setLogger, setNamespaceAware, setProperty, setPublicId, setRuleNamespaceURI, setRules, setSAXLogger, setSchema, setSchemaLanguage, setStackAction, setSubstitutor, setUseContextClassLoader, setValidating, setXIncludeAware, setXMLSchema, unparsedEntityDecl
    • Constructor Detail

      • ExtendedDigester

        public ExtendedDigester()
    • Method Detail

      • setCustomContentHandler

        public void setCustomContentHandler​(ContentHandler c)
        Sets a custom ContentHandler, that receives all SAX events until disabled (null).
        Overrides:
        setCustomContentHandler in class org.apache.commons.digester.Digester
      • getCustomContentHandler

        public ContentHandler getCustomContentHandler()
        Gets the custom event handler.
        Overrides:
        getCustomContentHandler in class org.apache.commons.digester.Digester
      • setErrorHandler

        public void setErrorHandler​(ErrorHandler err)
        Not suppoted, always throws IllegalArgumentException if not null.
        Overrides:
        setErrorHandler in class org.apache.commons.digester.Digester
      • getErrorHandler

        public ErrorHandler getErrorHandler()
        Not supported, always returns null
        Overrides:
        getErrorHandler in class org.apache.commons.digester.Digester
      • addDoNothing

        public void addDoNothing​(String pattern)
        Adds a dummy rule for element paths, that are allowed, but not parsed.
      • setRulesWithInvalidElementCheck

        public void setRulesWithInvalidElementCheck​(org.apache.commons.digester.Rules rules)
        Adds a default Rule for not allowing invalid (not registered) event paths. The given Rules object is wrapped and set using setRules(Rules rules).
      • clear

        public void clear()
        Overrides:
        clear in class org.apache.commons.digester.Digester
      • characters

        public void characters​(char[] ch,
                               int start,
                               int length)
                        throws SAXException
        Specified by:
        characters in interface ContentHandler
        Overrides:
        characters in class org.apache.commons.digester.Digester
        Throws:
        SAXException
      • getCurrentAssignedPrefixes

        public Set<String> getCurrentAssignedPrefixes()
        Returns all current namespace prefix that are assigned.
      • getCurrentNamespaceForPrefix

        public String getCurrentNamespaceForPrefix​(String prefix)
        Returns the current namespace URI for the given prefix.
      • getCurrentNamespaceMap

        public Map<String,​String> getCurrentNamespaceMap()
        Returns the current namespace prefix mappings as modifiable Map containing the prefix and the current namespace assignment (it is just a copy of the internal representation's current mapping).
      • getCurrentNamespaceContext

        public NamespaceContext getCurrentNamespaceContext​(boolean strict,
                                                           boolean reDefineDefaultPrefix)
        Returns the current NamespaceContext for compiling XPath expressions.
        Parameters:
        strict - denotes, that undeclared prefixes throw an IllegalArgumentException, like XSLT does it.
        reDefineDefaultPrefix - denotes, that the default "xmlns" is reassigned. This conforms to XSLT.