Class StaxEventXMLReader

  • All Implemented Interfaces:
    org.xml.sax.XMLReader

    public class StaxEventXMLReader
    extends java.lang.Object
    SAX XMLReader that reads from a StAX XMLEventReader. Consumes XMLEvents from an XMLEventReader, and calls the corresponding methods on the SAX callback interfaces.
    • Constructor Summary

      Constructors 
      Constructor Description
      StaxEventXMLReader​(javax.xml.stream.XMLEventReader reader)
      Constructs a new instance of the StaxEventXmlReader that reads from the given XMLEventReader.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.xml.sax.ContentHandler getContentHandler()  
      org.xml.sax.DTDHandler getDTDHandler()  
      org.xml.sax.EntityResolver getEntityResolver()  
      org.xml.sax.ErrorHandler getErrorHandler()  
      boolean getFeature​(java.lang.String name)
      Throws a SAXNotRecognizedException exception.
      protected org.xml.sax.ext.LexicalHandler getLexicalHandler()  
      java.lang.Object getProperty​(java.lang.String name)
      Throws a SAXNotRecognizedException exception when the given property does not signify a lexical handler.
      protected boolean hasNamespacePrefixesFeature()
      Indicates whether the SAX feature http://xml.org/sax/features/namespaces-prefixes is turned on.
      protected boolean hasNamespacesFeature()
      Indicates whether the SAX feature http://xml.org/sax/features/namespaces is turned on.
      void parse​(java.lang.String ignored)
      Parse the StAX XML reader passed at construction-time.
      void parse​(org.xml.sax.InputSource ignored)
      Parse the StAX XML reader passed at construction-time.
      protected void parseInternal()
      Template-method that parses the StAX reader passed at construction-time.
      void setContentHandler​(org.xml.sax.ContentHandler contentHandler)  
      void setDTDHandler​(org.xml.sax.DTDHandler dtdHandler)  
      void setEntityResolver​(org.xml.sax.EntityResolver entityResolver)  
      void setErrorHandler​(org.xml.sax.ErrorHandler errorHandler)  
      void setFeature​(java.lang.String name, boolean value)
      Throws a SAXNotRecognizedException exception.
      protected void setLocator​(javax.xml.stream.Location location)
      Sett the SAX Locator based on the given StAX Location.
      void setProperty​(java.lang.String name, java.lang.Object value)
      Throws a SAXNotRecognizedException exception when the given property does not signify a lexical handler.
      protected void setStandalone​(boolean standalone)  
      protected java.lang.String toQualifiedName​(javax.xml.namespace.QName qName)
      Convert a QName to a qualified name, as used by DOM and SAX.
      • Methods inherited from class java.lang.Object

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

      • StaxEventXMLReader

        public StaxEventXMLReader​(javax.xml.stream.XMLEventReader reader)
        Constructs a new instance of the StaxEventXmlReader that reads from the given XMLEventReader. The supplied event reader must be in XMLStreamConstants.START_DOCUMENT or XMLStreamConstants.START_ELEMENT state.
        Parameters:
        reader - the XMLEventReader to read from
        Throws:
        java.lang.IllegalStateException - if the reader is not at the start of a document or element
    • Method Detail

      • parseInternal

        protected void parseInternal()
                              throws org.xml.sax.SAXException,
                                     javax.xml.stream.XMLStreamException
        Template-method that parses the StAX reader passed at construction-time.
        Throws:
        org.xml.sax.SAXException - A SAX exception, possibly wrapping a XMLStreamException
        javax.xml.stream.XMLStreamException - if XML stream can not be processed
      • getFeature

        public boolean getFeature​(java.lang.String name)
                           throws org.xml.sax.SAXNotRecognizedException,
                                  org.xml.sax.SAXNotSupportedException
        Throws a SAXNotRecognizedException exception.
        Specified by:
        getFeature in interface org.xml.sax.XMLReader
        Throws:
        org.xml.sax.SAXNotRecognizedException - always
        org.xml.sax.SAXNotSupportedException
      • setFeature

        public void setFeature​(java.lang.String name,
                               boolean value)
                        throws org.xml.sax.SAXNotRecognizedException,
                               org.xml.sax.SAXNotSupportedException
        Throws a SAXNotRecognizedException exception.
        Specified by:
        setFeature in interface org.xml.sax.XMLReader
        Throws:
        org.xml.sax.SAXNotRecognizedException - always
        org.xml.sax.SAXNotSupportedException
      • setStandalone

        protected void setStandalone​(boolean standalone)
      • hasNamespacesFeature

        protected boolean hasNamespacesFeature()
        Indicates whether the SAX feature http://xml.org/sax/features/namespaces is turned on.
        Returns:
        true if namespaces are featured
      • hasNamespacePrefixesFeature

        protected boolean hasNamespacePrefixesFeature()
        Indicates whether the SAX feature http://xml.org/sax/features/namespaces-prefixes is turned on.
        Returns:
        true if namespace prefixes are featured
      • setLocator

        protected void setLocator​(javax.xml.stream.Location location)
        Sett the SAX Locator based on the given StAX Location.
        Parameters:
        location - the location
        See Also:
        ContentHandler.setDocumentLocator(org.xml.sax.Locator)
      • toQualifiedName

        protected java.lang.String toQualifiedName​(javax.xml.namespace.QName qName)
        Convert a QName to a qualified name, as used by DOM and SAX. The returned string has a format of prefix:localName if the prefix is set, or just localName if not.
        Parameters:
        qName - the QName
        Returns:
        the qualified name
      • parse

        public final void parse​(org.xml.sax.InputSource ignored)
                         throws org.xml.sax.SAXException
        Parse the StAX XML reader passed at construction-time.

        NOTE:: The given InputSource is not read, but ignored.

        Parameters:
        ignored - is ignored
        Throws:
        org.xml.sax.SAXException - a SAX exception, possibly wrapping a XMLStreamException
      • parse

        public final void parse​(java.lang.String ignored)
                         throws org.xml.sax.SAXException
        Parse the StAX XML reader passed at construction-time.

        NOTE:: The given system identifier is not read, but ignored.

        Parameters:
        ignored - is ignored
        Throws:
        org.xml.sax.SAXException - A SAX exception, possibly wrapping a XMLStreamException
      • getContentHandler

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

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

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

        public void setDTDHandler​(org.xml.sax.DTDHandler dtdHandler)
        Specified by:
        setDTDHandler in interface org.xml.sax.XMLReader
      • getEntityResolver

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

        public void setEntityResolver​(org.xml.sax.EntityResolver entityResolver)
        Specified by:
        setEntityResolver in interface org.xml.sax.XMLReader
      • getErrorHandler

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

        public void setErrorHandler​(org.xml.sax.ErrorHandler errorHandler)
        Specified by:
        setErrorHandler in interface org.xml.sax.XMLReader
      • getLexicalHandler

        protected org.xml.sax.ext.LexicalHandler getLexicalHandler()
      • getProperty

        public java.lang.Object getProperty​(java.lang.String name)
                                     throws org.xml.sax.SAXNotRecognizedException,
                                            org.xml.sax.SAXNotSupportedException
        Throws a SAXNotRecognizedException exception when the given property does not signify a lexical handler. The property name for a lexical handler is http://xml.org/sax/properties/lexical-handler.
        Specified by:
        getProperty in interface org.xml.sax.XMLReader
        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
        Throws a SAXNotRecognizedException exception when the given property does not signify a lexical handler. The property name for a lexical handler is http://xml.org/sax/properties/lexical-handler.
        Specified by:
        setProperty in interface org.xml.sax.XMLReader
        Throws:
        org.xml.sax.SAXNotRecognizedException
        org.xml.sax.SAXNotSupportedException