Class XMLPullReaderFactory.XMLPullReader

  • All Implemented Interfaces:
    IXMLReader
    Enclosing class:
    XMLPullReaderFactory

    private static class XMLPullReaderFactory.XMLPullReader
    extends java.lang.Object
    implements IXMLReader
    Wrapper for an XMLPull parser implementation. Since the internal parser API was originally based on XMLPull, this basically just delegates all the calls with minimal processing.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private XMLPullReader​(XmlPullParser parser)
      Constructor used by factory.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String buildPositionString()
      Build current parse input position description.
      private java.lang.String describeException​(java.lang.Exception e)
      Format error message from exception.
      int getAttributeCount()
      Get the number of attributes of the current start tag.
      java.lang.String getAttributeName​(int index)
      Get an attribute name from the current start tag.
      java.lang.String getAttributeNamespace​(int index)
      Get an attribute namespace from the current start tag.
      java.lang.String getAttributePrefix​(int index)
      Get an attribute prefix from the current start tag.
      java.lang.String getAttributeValue​(int index)
      Get an attribute value from the current start tag.
      java.lang.String getAttributeValue​(java.lang.String ns, java.lang.String name)
      Get an attribute value from the current start tag.
      int getColumnNumber()
      Get current source column number.
      java.lang.String getDocumentName()
      Get document name.
      int getEventType()
      Gets the current parse event type, without changing the current parse state.
      java.lang.String getInputEncoding()
      Return the input encoding, if known.
      int getLineNumber()
      Get current source line number.
      java.lang.String getName()
      Get element name from the current start or end tag.
      java.lang.String getNamespace()
      Get element namespace from the current start or end tag.
      java.lang.String getNamespace​(java.lang.String prefix)
      Get namespace URI associated with prefix.
      int getNamespaceCount​(int depth)
      Get number of namespace declarations active at depth.
      java.lang.String getNamespacePrefix​(int index)
      Get namespace prefix.
      java.lang.String getNamespaceUri​(int index)
      Get namespace URI.
      int getNestingDepth()
      Get current element nesting depth.
      java.lang.String getPrefix()
      Get element prefix from the current start or end tag.
      java.lang.String getText()
      Get current text.
      void init()
      Initialize reader.
      boolean isNamespaceAware()
      Return namespace processing flag.
      int next()
      Advance to next binding component of input document.
      int nextToken()
      Advance to next parse event of input document.
      private void setDocument​(java.io.InputStream is, java.lang.String name, java.lang.String enc)
      Set document to be parsed from input stream.
      private void setDocument​(java.io.Reader rdr, java.lang.String name)
      Set document to be parsed from reader.
      • Methods inherited from class java.lang.Object

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

      • m_parser

        private final XmlPullParser m_parser
        Actual parser.
      • m_docName

        private java.lang.String m_docName
        Document name.
      • m_byteBuffer

        private InByteBuffer m_byteBuffer
        Byte buffer used when stream set directly (lazy create, null if not used).
      • m_streamWrapper

        private InputStreamWrapper m_streamWrapper
        Wrapper for supplied input stream (lazy create, null if not used).
      • m_encoding

        private java.lang.String m_encoding
        Input document character encoding (null if unknown)
    • Constructor Detail

      • XMLPullReader

        private XMLPullReader​(XmlPullParser parser)
        Constructor used by factory.
        Parameters:
        parser -
    • Method Detail

      • setDocument

        private void setDocument​(java.io.InputStream is,
                                 java.lang.String name,
                                 java.lang.String enc)
                          throws JiBXException
        Set document to be parsed from input stream.
        Parameters:
        is - document input stream
        name - document name (null if unknown)
        enc - document character encoding (null if unknown)
        Throws:
        JiBXException - on parser configuration error
      • setDocument

        private void setDocument​(java.io.Reader rdr,
                                 java.lang.String name)
                          throws JiBXException
        Set document to be parsed from reader.
        Parameters:
        rdr - document reader
        name - document name (null if unknown)
        Throws:
        JiBXException - on parser configuration error
      • describeException

        private java.lang.String describeException​(java.lang.Exception e)
        Format error message from exception.
        Parameters:
        e - root cause exception
      • init

        public void init()
        Description copied from interface: IXMLReader
        Initialize reader.
        Specified by:
        init in interface IXMLReader
      • buildPositionString

        public java.lang.String buildPositionString()
        Description copied from interface: IXMLReader
        Build current parse input position description.
        Specified by:
        buildPositionString in interface IXMLReader
        Returns:
        text description of current parse position
      • nextToken

        public int nextToken()
                      throws JiBXException
        Description copied from interface: IXMLReader
        Advance to next parse event of input document.
        Specified by:
        nextToken in interface IXMLReader
        Returns:
        parse event type code
        Throws:
        JiBXException - if error reading or parsing document
      • next

        public int next()
                 throws JiBXException
        Description copied from interface: IXMLReader
        Advance to next binding component of input document. This is a higher-level operation than IXMLReader.nextToken(), which consolidates text content and ignores parse events for components such as comments and PIs.
        Specified by:
        next in interface IXMLReader
        Returns:
        parse event type code
        Throws:
        JiBXException - if error reading or parsing document
      • getEventType

        public int getEventType()
                         throws JiBXException
        Description copied from interface: IXMLReader
        Gets the current parse event type, without changing the current parse state.
        Specified by:
        getEventType in interface IXMLReader
        Returns:
        parse event type code
        Throws:
        JiBXException - if error parsing document
      • getName

        public java.lang.String getName()
        Description copied from interface: IXMLReader
        Get element name from the current start or end tag.
        Specified by:
        getName in interface IXMLReader
        Returns:
        local name if namespace handling enabled, full name if namespace handling disabled
      • getNamespace

        public java.lang.String getNamespace()
        Description copied from interface: IXMLReader
        Get element namespace from the current start or end tag.
        Specified by:
        getNamespace in interface IXMLReader
        Returns:
        namespace URI if namespace handling enabled and element is in a namespace, empty string otherwise
      • getPrefix

        public java.lang.String getPrefix()
        Description copied from interface: IXMLReader
        Get element prefix from the current start or end tag.
        Specified by:
        getPrefix in interface IXMLReader
        Returns:
        prefix text (null if no prefix)
      • getAttributeCount

        public int getAttributeCount()
        Description copied from interface: IXMLReader
        Get the number of attributes of the current start tag.
        Specified by:
        getAttributeCount in interface IXMLReader
        Returns:
        number of attributes
      • getAttributeName

        public java.lang.String getAttributeName​(int index)
        Description copied from interface: IXMLReader
        Get an attribute name from the current start tag.
        Specified by:
        getAttributeName in interface IXMLReader
        Parameters:
        index - attribute index
        Returns:
        local name if namespace handling enabled, full name if namespace handling disabled
      • getAttributeNamespace

        public java.lang.String getAttributeNamespace​(int index)
        Description copied from interface: IXMLReader
        Get an attribute namespace from the current start tag.
        Specified by:
        getAttributeNamespace in interface IXMLReader
        Parameters:
        index - attribute index
        Returns:
        namespace URI if namespace handling enabled and attribute is in a namespace, empty string otherwise
      • getAttributePrefix

        public java.lang.String getAttributePrefix​(int index)
        Description copied from interface: IXMLReader
        Get an attribute prefix from the current start tag.
        Specified by:
        getAttributePrefix in interface IXMLReader
        Parameters:
        index - attribute index
        Returns:
        prefix for attribute (null if no prefix present)
      • getAttributeValue

        public java.lang.String getAttributeValue​(int index)
        Description copied from interface: IXMLReader
        Get an attribute value from the current start tag.
        Specified by:
        getAttributeValue in interface IXMLReader
        Parameters:
        index - attribute index
        Returns:
        value text
      • getAttributeValue

        public java.lang.String getAttributeValue​(java.lang.String ns,
                                                  java.lang.String name)
        Description copied from interface: IXMLReader
        Get an attribute value from the current start tag.
        Specified by:
        getAttributeValue in interface IXMLReader
        Parameters:
        ns - namespace URI for expected attribute (may be null or the empty string for the empty namespace)
        name - attribute name expected
        Returns:
        attribute value text, or null if missing
      • getText

        public java.lang.String getText()
        Description copied from interface: IXMLReader
        Get current text. When positioned on a TEXT event this returns the actual text; for CDSECT it returns the text inside the CDATA section; for COMMENT, DOCDECL, or PROCESSING_INSTRUCTION it returns the text inside the structure.
        Specified by:
        getText in interface IXMLReader
        Returns:
        text for current event
      • getNestingDepth

        public int getNestingDepth()
        Description copied from interface: IXMLReader
        Get current element nesting depth. The returned depth always includes the current start or end tag (if positioned on a start or end tag).
        Specified by:
        getNestingDepth in interface IXMLReader
        Returns:
        element nesting depth
      • getNamespaceCount

        public int getNamespaceCount​(int depth)
        Description copied from interface: IXMLReader
        Get number of namespace declarations active at depth.
        Specified by:
        getNamespaceCount in interface IXMLReader
        Parameters:
        depth - element nesting depth
        Returns:
        number of namespaces active at depth
      • getNamespaceUri

        public java.lang.String getNamespaceUri​(int index)
        Description copied from interface: IXMLReader
        Get namespace URI.
        Specified by:
        getNamespaceUri in interface IXMLReader
        Parameters:
        index - declaration index
        Returns:
        namespace URI
      • getNamespacePrefix

        public java.lang.String getNamespacePrefix​(int index)
        Description copied from interface: IXMLReader
        Get namespace prefix.
        Specified by:
        getNamespacePrefix in interface IXMLReader
        Parameters:
        index - declaration index
        Returns:
        namespace prefix, null if a default namespace
      • getDocumentName

        public java.lang.String getDocumentName()
        Description copied from interface: IXMLReader
        Get document name.
        Specified by:
        getDocumentName in interface IXMLReader
        Returns:
        document name, null if not known
      • getLineNumber

        public int getLineNumber()
        Description copied from interface: IXMLReader
        Get current source line number.
        Specified by:
        getLineNumber in interface IXMLReader
        Returns:
        line number from source document, -1 if line number information not available
      • getColumnNumber

        public int getColumnNumber()
        Description copied from interface: IXMLReader
        Get current source column number.
        Specified by:
        getColumnNumber in interface IXMLReader
        Returns:
        column number from source document, -1 if column number information not available
      • getNamespace

        public java.lang.String getNamespace​(java.lang.String prefix)
        Description copied from interface: IXMLReader
        Get namespace URI associated with prefix.
        Specified by:
        getNamespace in interface IXMLReader
        Parameters:
        prefix - namespace prefix to be matched (null for default namespace)
        Returns:
        associated URI (null if prefix not defined)
      • getInputEncoding

        public java.lang.String getInputEncoding()
        Description copied from interface: IXMLReader
        Return the input encoding, if known. This is only valid after parsing of a document has been started.
        Specified by:
        getInputEncoding in interface IXMLReader
        Returns:
        input encoding (null if unknown)
      • isNamespaceAware

        public boolean isNamespaceAware()
        Description copied from interface: IXMLReader
        Return namespace processing flag.
        Specified by:
        isNamespaceAware in interface IXMLReader
        Returns:
        namespace processing flag (true if namespaces are processed by reader, false if not)