Interface IXMLReader

  • All Known Implementing Classes:
    StAXReaderWrapper, XMLPullReaderFactory.XMLPullReader

    public interface IXMLReader
    XML reader interface used for input of unmarshalled document. This interface allows easy substitution of different parsers or other input sources.
    Author:
    Dennis M. Sosnoski
    • Method Detail

      • init

        void init()
           throws java.io.IOException
        Initialize reader.
        Throws:
        java.io.IOException
      • buildPositionString

        java.lang.String buildPositionString()
        Build current parse input position description.
        Returns:
        text description of current parse position
      • nextToken

        int nextToken()
               throws JiBXException
        Advance to next parse event of input document.
        Returns:
        parse event type code
        Throws:
        JiBXException - if error reading or parsing document
      • next

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

        int getEventType()
                  throws JiBXException
        Gets the current parse event type, without changing the current parse state.
        Returns:
        parse event type code
        Throws:
        JiBXException - if error parsing document
      • getName

        java.lang.String getName()
        Get element name from the current start or end tag.
        Returns:
        local name if namespace handling enabled, full name if namespace handling disabled
        Throws:
        java.lang.IllegalStateException - if not at a start or end tag (optional)
      • getNamespace

        java.lang.String getNamespace()
        Get element namespace from the current start or end tag.
        Returns:
        namespace URI if namespace handling enabled and element is in a namespace, empty string otherwise
        Throws:
        java.lang.IllegalStateException - if not at a start or end tag (optional)
      • getPrefix

        java.lang.String getPrefix()
        Get element prefix from the current start or end tag.
        Returns:
        prefix text (null if no prefix)
        Throws:
        java.lang.IllegalStateException - if not at a start or end tag
      • getAttributeCount

        int getAttributeCount()
        Get the number of attributes of the current start tag.
        Returns:
        number of attributes
        Throws:
        java.lang.IllegalStateException - if not at a start tag (optional)
      • getAttributeName

        java.lang.String getAttributeName​(int index)
        Get an attribute name from the current start tag.
        Parameters:
        index - attribute index
        Returns:
        local name if namespace handling enabled, full name if namespace handling disabled
        Throws:
        java.lang.IllegalStateException - if not at a start tag or invalid index
      • getAttributeNamespace

        java.lang.String getAttributeNamespace​(int index)
        Get an attribute namespace from the current start tag.
        Parameters:
        index - attribute index
        Returns:
        namespace URI if namespace handling enabled and attribute is in a namespace, empty string otherwise
        Throws:
        java.lang.IllegalStateException - if not at a start tag or invalid index
      • getAttributePrefix

        java.lang.String getAttributePrefix​(int index)
        Get an attribute prefix from the current start tag.
        Parameters:
        index - attribute index
        Returns:
        prefix for attribute (null if no prefix present)
        Throws:
        java.lang.IllegalStateException - if not at a start tag or invalid index
      • getAttributeValue

        java.lang.String getAttributeValue​(int index)
        Get an attribute value from the current start tag.
        Parameters:
        index - attribute index
        Returns:
        value text
        Throws:
        java.lang.IllegalStateException - if not at a start tag or invalid index
      • getAttributeValue

        java.lang.String getAttributeValue​(java.lang.String ns,
                                           java.lang.String name)
        Get an attribute value from the current start tag.
        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
        Throws:
        java.lang.IllegalStateException - if not at a start tag
      • getText

        java.lang.String getText()
        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.
        Returns:
        text for current event
      • getNestingDepth

        int getNestingDepth()
        Get current element nesting depth. The returned depth always includes the current start or end tag (if positioned on a start or end tag).
        Returns:
        element nesting depth
      • getNamespaceCount

        int getNamespaceCount​(int depth)
        Get number of namespace declarations active at depth.
        Parameters:
        depth - element nesting depth
        Returns:
        number of namespaces active at depth
        Throws:
        java.lang.IllegalArgumentException - if invalid depth
      • getNamespaceUri

        java.lang.String getNamespaceUri​(int index)
        Get namespace URI.
        Parameters:
        index - declaration index
        Returns:
        namespace URI
        Throws:
        java.lang.IllegalArgumentException - if invalid index
      • getNamespacePrefix

        java.lang.String getNamespacePrefix​(int index)
        Get namespace prefix.
        Parameters:
        index - declaration index
        Returns:
        namespace prefix, null if a default namespace
        Throws:
        java.lang.IllegalArgumentException - if invalid index
      • getDocumentName

        java.lang.String getDocumentName()
        Get document name.
        Returns:
        document name, null if not known
      • getLineNumber

        int getLineNumber()
        Get current source line number.
        Returns:
        line number from source document, -1 if line number information not available
      • getColumnNumber

        int getColumnNumber()
        Get current source column number.
        Returns:
        column number from source document, -1 if column number information not available
      • getNamespace

        java.lang.String getNamespace​(java.lang.String prefix)
        Get namespace URI associated with prefix.
        Parameters:
        prefix - namespace prefix to be matched (null for default namespace)
        Returns:
        associated URI (null if prefix not defined)
      • getInputEncoding

        java.lang.String getInputEncoding()
        Return the input encoding, if known. This is only valid after parsing of a document has been started.
        Returns:
        input encoding (null if unknown)
      • isNamespaceAware

        boolean isNamespaceAware()
        Return namespace processing flag.
        Returns:
        namespace processing flag (true if namespaces are processed by reader, false if not)