org.jibx.runtime
Interface IXMLReader

All Known Implementing Classes:
StAXReaderWrapper

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 Summary
static int CDSECT
           
static int COMMENT
           
static int DOCDECL
           
static int END_DOCUMENT
           
static int END_TAG
           
static int ENTITY_REF
           
static int IGNORABLE_WHITESPACE
           
static int PROCESSING_INSTRUCTION
           
static int START_DOCUMENT
           
static int START_TAG
           
static int TEXT
           
 
Method Summary
 java.lang.String buildPositionString()
          Build current parse input position description.
 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.
 

Field Detail

START_DOCUMENT

static final int START_DOCUMENT
See Also:
Constant Field Values

END_DOCUMENT

static final int END_DOCUMENT
See Also:
Constant Field Values

START_TAG

static final int START_TAG
See Also:
Constant Field Values

END_TAG

static final int END_TAG
See Also:
Constant Field Values

TEXT

static final int TEXT
See Also:
Constant Field Values

CDSECT

static final int CDSECT
See Also:
Constant Field Values

ENTITY_REF

static final int ENTITY_REF
See Also:
Constant Field Values

IGNORABLE_WHITESPACE

static final int IGNORABLE_WHITESPACE
See Also:
Constant Field Values

PROCESSING_INSTRUCTION

static final int PROCESSING_INSTRUCTION
See Also:
Constant Field Values

COMMENT

static final int COMMENT
See Also:
Constant Field Values

DOCDECL

static final int DOCDECL
See Also:
Constant Field Values
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)


Project Web Site