Class SAXParserImpl

  • All Implemented Interfaces:
    org.xml.sax.Attributes, org.xml.sax.ext.Attributes2, org.xml.sax.ext.Locator2, org.xml.sax.Locator, org.xml.sax.Parser, org.xml.sax.XMLReader

    class SAXParserImpl
    extends javax.xml.parsers.SAXParser
    implements org.xml.sax.Parser, org.xml.sax.XMLReader, org.xml.sax.ext.Attributes2, org.xml.sax.ext.Locator2
    • Field Detail

      • _scanner

        protected XmlScanner _scanner
        Since the stream reader would mostly be just a wrapper around the underlying scanner (its main job is to implement Stax interface), we can and should just use the scanner. In effect, this class is then a replacement of StreamReaderImpl, when using SAX interfaces.
      • _contentHandler

        protected org.xml.sax.ContentHandler _contentHandler
      • _dtdHandler

        protected org.xml.sax.DTDHandler _dtdHandler
      • _entityResolver

        private org.xml.sax.EntityResolver _entityResolver
      • _errorHandler

        private org.xml.sax.ErrorHandler _errorHandler
      • _lexicalHandler

        private org.xml.sax.ext.LexicalHandler _lexicalHandler
      • _declHandler

        private org.xml.sax.ext.DeclHandler _declHandler
      • _attrCount

        private int _attrCount
    • Method Detail

      • getParser

        public final org.xml.sax.Parser getParser()
        Specified by:
        getParser in class javax.xml.parsers.SAXParser
      • getXMLReader

        public final org.xml.sax.XMLReader getXMLReader()
        Specified by:
        getXMLReader in class javax.xml.parsers.SAXParser
      • isNamespaceAware

        public boolean isNamespaceAware()
        Specified by:
        isNamespaceAware in class javax.xml.parsers.SAXParser
      • isValidating

        public boolean isValidating()
        Specified by:
        isValidating in class javax.xml.parsers.SAXParser
      • getProperty

        public java.lang.Object getProperty​(java.lang.String name)
                                     throws org.xml.sax.SAXNotRecognizedException,
                                            org.xml.sax.SAXNotSupportedException
        Specified by:
        getProperty in interface org.xml.sax.XMLReader
        Specified by:
        getProperty in class javax.xml.parsers.SAXParser
        Throws:
        org.xml.sax.SAXNotRecognizedException
        org.xml.sax.SAXNotSupportedException
      • setProperty

        public void setProperty​(java.lang.String name,
                                java.lang.Object value)
                         throws org.xml.sax.SAXNotRecognizedException,
                                org.xml.sax.SAXNotSupportedException
        Specified by:
        setProperty in interface org.xml.sax.XMLReader
        Specified by:
        setProperty in class javax.xml.parsers.SAXParser
        Throws:
        org.xml.sax.SAXNotRecognizedException
        org.xml.sax.SAXNotSupportedException
      • parse

        public void parse​(org.xml.sax.InputSource is,
                          org.xml.sax.HandlerBase hb)
                   throws org.xml.sax.SAXException,
                          java.io.IOException
        Overrides:
        parse in class javax.xml.parsers.SAXParser
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • parse

        public void parse​(org.xml.sax.InputSource is,
                          org.xml.sax.helpers.DefaultHandler dh)
                   throws org.xml.sax.SAXException,
                          java.io.IOException
        Overrides:
        parse in class javax.xml.parsers.SAXParser
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • getContentHandler

        public org.xml.sax.ContentHandler getContentHandler()
        Specified by:
        getContentHandler in interface org.xml.sax.XMLReader
      • getDTDHandler

        public org.xml.sax.DTDHandler getDTDHandler()
        Specified by:
        getDTDHandler in interface org.xml.sax.XMLReader
      • getEntityResolver

        public org.xml.sax.EntityResolver getEntityResolver()
        Specified by:
        getEntityResolver in interface org.xml.sax.XMLReader
      • getErrorHandler

        public org.xml.sax.ErrorHandler getErrorHandler()
        Specified by:
        getErrorHandler in interface org.xml.sax.XMLReader
      • getFeature

        public boolean getFeature​(java.lang.String name)
                           throws org.xml.sax.SAXNotRecognizedException
        Specified by:
        getFeature in interface org.xml.sax.XMLReader
        Throws:
        org.xml.sax.SAXNotRecognizedException
      • setContentHandler

        public void setContentHandler​(org.xml.sax.ContentHandler handler)
        Specified by:
        setContentHandler in interface org.xml.sax.XMLReader
      • setDTDHandler

        public void setDTDHandler​(org.xml.sax.DTDHandler handler)
        Specified by:
        setDTDHandler in interface org.xml.sax.Parser
        Specified by:
        setDTDHandler in interface org.xml.sax.XMLReader
      • setEntityResolver

        public void setEntityResolver​(org.xml.sax.EntityResolver resolver)
        Specified by:
        setEntityResolver in interface org.xml.sax.Parser
        Specified by:
        setEntityResolver in interface org.xml.sax.XMLReader
      • setErrorHandler

        public void setErrorHandler​(org.xml.sax.ErrorHandler handler)
        Specified by:
        setErrorHandler in interface org.xml.sax.Parser
        Specified by:
        setErrorHandler in interface org.xml.sax.XMLReader
      • setFeature

        public void setFeature​(java.lang.String name,
                               boolean value)
                        throws org.xml.sax.SAXNotRecognizedException
        Specified by:
        setFeature in interface org.xml.sax.XMLReader
        Throws:
        org.xml.sax.SAXNotRecognizedException
      • parse

        public void parse​(org.xml.sax.InputSource input)
                   throws org.xml.sax.SAXException
        Specified by:
        parse in interface org.xml.sax.Parser
        Specified by:
        parse in interface org.xml.sax.XMLReader
        Throws:
        org.xml.sax.SAXException
      • parse

        public void parse​(java.lang.String systemId)
                   throws org.xml.sax.SAXException
        Specified by:
        parse in interface org.xml.sax.Parser
        Specified by:
        parse in interface org.xml.sax.XMLReader
        Throws:
        org.xml.sax.SAXException
      • fireEvents

        private final void fireEvents()
                               throws org.xml.sax.SAXException,
                                      javax.xml.stream.XMLStreamException
        This is the actual "tight event loop" that will send all events between start and end document events. Although we could use the stream reader here, there's not much as it mostly just forwards requests to the scanner: and so we can as well just copy the little code stream reader's next() method has.
        Throws:
        org.xml.sax.SAXException
        javax.xml.stream.XMLStreamException
      • fireAuxEvent

        private final void fireAuxEvent​(int type,
                                        boolean inTree)
                                 throws org.xml.sax.SAXException,
                                        javax.xml.stream.XMLStreamException
        Throws:
        org.xml.sax.SAXException
        javax.xml.stream.XMLStreamException
      • fireStartTag

        private final void fireStartTag()
                                 throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • fireEndTag

        private final void fireEndTag()
                               throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • setDocumentHandler

        public void setDocumentHandler​(org.xml.sax.DocumentHandler handler)
        Specified by:
        setDocumentHandler in interface org.xml.sax.Parser
      • setLocale

        public void setLocale​(java.util.Locale locale)
        Specified by:
        setLocale in interface org.xml.sax.Parser
      • getIndex

        public int getIndex​(java.lang.String qName)
        Specified by:
        getIndex in interface org.xml.sax.Attributes
      • getIndex

        public int getIndex​(java.lang.String uri,
                            java.lang.String localName)
        Specified by:
        getIndex in interface org.xml.sax.Attributes
      • getLength

        public int getLength()
        Specified by:
        getLength in interface org.xml.sax.Attributes
      • getLocalName

        public java.lang.String getLocalName​(int index)
        Specified by:
        getLocalName in interface org.xml.sax.Attributes
      • getQName

        public java.lang.String getQName​(int index)
        Specified by:
        getQName in interface org.xml.sax.Attributes
      • getType

        public java.lang.String getType​(int index)
        Specified by:
        getType in interface org.xml.sax.Attributes
      • getType

        public java.lang.String getType​(java.lang.String qName)
        Specified by:
        getType in interface org.xml.sax.Attributes
      • getType

        public java.lang.String getType​(java.lang.String uri,
                                        java.lang.String localName)
        Specified by:
        getType in interface org.xml.sax.Attributes
      • getURI

        public java.lang.String getURI​(int index)
        Specified by:
        getURI in interface org.xml.sax.Attributes
      • getValue

        public java.lang.String getValue​(int index)
        Specified by:
        getValue in interface org.xml.sax.Attributes
      • getValue

        public java.lang.String getValue​(java.lang.String qName)
        Specified by:
        getValue in interface org.xml.sax.Attributes
      • getValue

        public java.lang.String getValue​(java.lang.String uri,
                                         java.lang.String localName)
        Specified by:
        getValue in interface org.xml.sax.Attributes
      • isDeclared

        public boolean isDeclared​(int index)
        Specified by:
        isDeclared in interface org.xml.sax.ext.Attributes2
      • isDeclared

        public boolean isDeclared​(java.lang.String qName)
        Specified by:
        isDeclared in interface org.xml.sax.ext.Attributes2
      • isDeclared

        public boolean isDeclared​(java.lang.String uri,
                                  java.lang.String localName)
        Specified by:
        isDeclared in interface org.xml.sax.ext.Attributes2
      • isSpecified

        public boolean isSpecified​(int index)
        Specified by:
        isSpecified in interface org.xml.sax.ext.Attributes2
      • isSpecified

        public boolean isSpecified​(java.lang.String qName)
        Specified by:
        isSpecified in interface org.xml.sax.ext.Attributes2
      • isSpecified

        public boolean isSpecified​(java.lang.String uri,
                                   java.lang.String localName)
        Specified by:
        isSpecified in interface org.xml.sax.ext.Attributes2
      • getColumnNumber

        public int getColumnNumber()
        Specified by:
        getColumnNumber in interface org.xml.sax.Locator
      • getLineNumber

        public int getLineNumber()
        Specified by:
        getLineNumber in interface org.xml.sax.Locator
      • getPublicId

        public java.lang.String getPublicId()
        Specified by:
        getPublicId in interface org.xml.sax.Locator
      • getSystemId

        public java.lang.String getSystemId()
        Specified by:
        getSystemId in interface org.xml.sax.Locator
      • getEncoding

        public java.lang.String getEncoding()
        Specified by:
        getEncoding in interface org.xml.sax.ext.Locator2
      • getXMLVersion

        public java.lang.String getXMLVersion()
        Specified by:
        getXMLVersion in interface org.xml.sax.ext.Locator2
      • throwSaxException

        private void throwSaxException​(java.lang.Exception e)
                                throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • throwSaxException

        private void throwSaxException​(java.lang.String msg)
                                throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException