Package org.dom4j.io

Class DOMSAXContentHandler

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler

    public class DOMSAXContentHandler
    extends org.xml.sax.helpers.DefaultHandler
    implements org.xml.sax.ext.LexicalHandler

    SAXContentHandler builds W3C DOM object via SAX events.

    • Constructor Detail

      • DOMSAXContentHandler

        public DOMSAXContentHandler()
    • Method Detail

      • getDocument

        public org.w3c.dom.Document getDocument()
        Retrieves w3c document object built via generated sax events.
        Returns:
        the document that has been or is being built
      • setDocumentLocator

        public void setDocumentLocator(org.xml.sax.Locator documentLocator)
        Specified by:
        setDocumentLocator in interface org.xml.sax.ContentHandler
        Overrides:
        setDocumentLocator in class org.xml.sax.helpers.DefaultHandler
      • processingInstruction

        public void processingInstruction(java.lang.String target,
                                          java.lang.String data)
                                   throws org.xml.sax.SAXException
        Specified by:
        processingInstruction in interface org.xml.sax.ContentHandler
        Overrides:
        processingInstruction in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • startPrefixMapping

        public void startPrefixMapping(java.lang.String prefix,
                                       java.lang.String uri)
                                throws org.xml.sax.SAXException
        Specified by:
        startPrefixMapping in interface org.xml.sax.ContentHandler
        Overrides:
        startPrefixMapping in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • endPrefixMapping

        public void endPrefixMapping(java.lang.String prefix)
                              throws org.xml.sax.SAXException
        Specified by:
        endPrefixMapping in interface org.xml.sax.ContentHandler
        Overrides:
        endPrefixMapping in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • startDocument

        public void startDocument()
                           throws org.xml.sax.SAXException
        Specified by:
        startDocument in interface org.xml.sax.ContentHandler
        Overrides:
        startDocument in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • endDocument

        public void endDocument()
                         throws org.xml.sax.SAXException
        Specified by:
        endDocument in interface org.xml.sax.ContentHandler
        Overrides:
        endDocument in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • startElement

        public void startElement(java.lang.String namespaceURI,
                                 java.lang.String localName,
                                 java.lang.String qualifiedName,
                                 org.xml.sax.Attributes attributes)
                          throws org.xml.sax.SAXException
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • endElement

        public void endElement(java.lang.String namespaceURI,
                               java.lang.String localName,
                               java.lang.String qName)
                        throws org.xml.sax.SAXException
        Specified by:
        endElement in interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • characters

        public void characters(char[] ch,
                               int start,
                               int end)
                        throws org.xml.sax.SAXException
        Specified by:
        characters in interface org.xml.sax.ContentHandler
        Overrides:
        characters in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • warning

        public void warning(org.xml.sax.SAXParseException exception)
                     throws org.xml.sax.SAXException
        This method is called when a warning occurs during the parsing of the document. This method does nothing.
        Specified by:
        warning in interface org.xml.sax.ErrorHandler
        Overrides:
        warning in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        exception - DOCUMENT ME!
        Throws:
        org.xml.sax.SAXException - DOCUMENT ME!
      • error

        public void error(org.xml.sax.SAXParseException exception)
                   throws org.xml.sax.SAXException
        This method is called when an error is detected during parsing such as a validation error. This method rethrows the exception
        Specified by:
        error in interface org.xml.sax.ErrorHandler
        Overrides:
        error in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        exception - DOCUMENT ME!
        Throws:
        org.xml.sax.SAXException - DOCUMENT ME!
      • fatalError

        public void fatalError(org.xml.sax.SAXParseException exception)
                        throws org.xml.sax.SAXException
        This method is called when a fatal error occurs during parsing. This method rethrows the exception
        Specified by:
        fatalError in interface org.xml.sax.ErrorHandler
        Overrides:
        fatalError in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        exception - DOCUMENT ME!
        Throws:
        org.xml.sax.SAXException - DOCUMENT ME!
      • startDTD

        public void startDTD(java.lang.String name,
                             java.lang.String publicId,
                             java.lang.String systemId)
                      throws org.xml.sax.SAXException
        Specified by:
        startDTD in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • endDTD

        public void endDTD()
                    throws org.xml.sax.SAXException
        Specified by:
        endDTD in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • startEntity

        public void startEntity(java.lang.String name)
                         throws org.xml.sax.SAXException
        Specified by:
        startEntity in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • endEntity

        public void endEntity(java.lang.String name)
                       throws org.xml.sax.SAXException
        Specified by:
        endEntity in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • startCDATA

        public void startCDATA()
                        throws org.xml.sax.SAXException
        Specified by:
        startCDATA in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • endCDATA

        public void endCDATA()
                      throws org.xml.sax.SAXException
        Specified by:
        endCDATA in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • comment

        public void comment(char[] ch,
                            int start,
                            int end)
                     throws org.xml.sax.SAXException
        Specified by:
        comment in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • getElementStack

        public org.dom4j.io.ElementStack getElementStack()
      • setElementStack

        public void setElementStack(org.dom4j.io.ElementStack elementStack)
      • getEntityResolver

        public org.xml.sax.EntityResolver getEntityResolver()
      • setEntityResolver

        public void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
      • getInputSource

        public org.xml.sax.InputSource getInputSource()
      • setInputSource

        public void setInputSource(org.xml.sax.InputSource inputSource)
      • isMergeAdjacentText

        public boolean isMergeAdjacentText()
        Returns whether adjacent text nodes should be merged together.
        Returns:
        Value of property mergeAdjacentText.
      • setMergeAdjacentText

        public void setMergeAdjacentText(boolean mergeAdjacentText)
        Sets whether or not adjacent text nodes should be merged together when parsing.
        Parameters:
        mergeAdjacentText - New value of property mergeAdjacentText.
      • isStripWhitespaceText

        public boolean isStripWhitespaceText()
        Sets whether whitespace between element start and end tags should be ignored
        Returns:
        Value of property stripWhitespaceText.
      • setStripWhitespaceText

        public void setStripWhitespaceText(boolean stripWhitespaceText)
        Sets whether whitespace between element start and end tags should be ignored.
        Parameters:
        stripWhitespaceText - New value of property stripWhitespaceText.
      • isIgnoreComments

        public boolean isIgnoreComments()
        Returns whether we should ignore comments or not.
        Returns:
        boolean
      • setIgnoreComments

        public void setIgnoreComments(boolean ignoreComments)
        Sets whether we should ignore comments or not.
        Parameters:
        ignoreComments - whether we should ignore comments or not.
      • completeCurrentTextNode

        protected void completeCurrentTextNode()
      • createDocument

        protected Document createDocument()
      • addDeclaredNamespaces

        protected void addDeclaredNamespaces(Element element)
      • addAttributes

        protected void addAttributes(Element element,
                                     org.xml.sax.Attributes attributes)
      • createElementStack

        protected org.dom4j.io.ElementStack createElementStack()
      • attributeNameForNamespace

        protected java.lang.String attributeNameForNamespace(Namespace namespace)