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
  • Field Details

  • Method Details

    • init

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

      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

      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:
      IllegalStateException - if not at a start or end tag (optional)
    • getNamespace

      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:
      IllegalStateException - if not at a start or end tag (optional)
    • getPrefix

      String getPrefix()
      Get element prefix from the current start or end tag.
      Returns:
      prefix text (null if no prefix)
      Throws:
      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:
      IllegalStateException - if not at a start tag (optional)
    • getAttributeName

      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:
      IllegalStateException - if not at a start tag or invalid index
    • getAttributeNamespace

      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:
      IllegalStateException - if not at a start tag or invalid index
    • getAttributePrefix

      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:
      IllegalStateException - if not at a start tag or invalid index
    • getAttributeValue

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

      String getAttributeValue(String ns, 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:
      IllegalStateException - if not at a start tag
    • getText

      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:
      IllegalArgumentException - if invalid depth
    • getNamespaceUri

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

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

      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

      String getNamespace(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

      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)