Package org.jibx.runtime
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionBuild current parse input position description.intGet the number of attributes of the current start tag.getAttributeName(int index) Get an attribute name from the current start tag.getAttributeNamespace(int index) Get an attribute namespace from the current start tag.getAttributePrefix(int index) Get an attribute prefix from the current start tag.getAttributeValue(int index) Get an attribute value from the current start tag.getAttributeValue(String ns, String name) Get an attribute value from the current start tag.intGet current source column number.Get document name.intGets the current parse event type, without changing the current parse state.Return the input encoding, if known.intGet current source line number.getName()Get element name from the current start or end tag.Get element namespace from the current start or end tag.getNamespace(String prefix) Get namespace URI associated with prefix.intgetNamespaceCount(int depth) Get number of namespace declarations active at depth.getNamespacePrefix(int index) Get namespace prefix.getNamespaceUri(int index) Get namespace URI.intGet current element nesting depth.Get element prefix from the current start or end tag.getText()Get current text.voidinit()Initialize reader.booleanReturn namespace processing flag.intnext()Advance to next binding component of input document.intAdvance to next parse event of input document.
-
Field Details
-
START_DOCUMENT
static final int START_DOCUMENT- See Also:
-
END_DOCUMENT
static final int END_DOCUMENT- See Also:
-
START_TAG
static final int START_TAG- See Also:
-
END_TAG
static final int END_TAG- See Also:
-
TEXT
static final int TEXT- See Also:
-
CDSECT
static final int CDSECT- See Also:
-
ENTITY_REF
static final int ENTITY_REF- See Also:
-
IGNORABLE_WHITESPACE
static final int IGNORABLE_WHITESPACE- See Also:
-
PROCESSING_INSTRUCTION
static final int PROCESSING_INSTRUCTION- See Also:
-
COMMENT
static final int COMMENT- See Also:
-
DOCDECL
static final int DOCDECL- See Also:
-
-
Method Details
-
init
Initialize reader.- Throws:
IOException
-
buildPositionString
String buildPositionString()Build current parse input position description.- Returns:
- text description of current parse position
-
nextToken
Advance to next parse event of input document.- Returns:
- parse event type code
- Throws:
JiBXException- if error reading or parsing document
-
next
Advance to next binding component of input document. This is a higher-level operation thannextToken(), 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
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 (
nullif 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
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
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
Get an attribute prefix from the current start tag.- Parameters:
index- attribute index- Returns:
- prefix for attribute (
nullif no prefix present) - Throws:
IllegalStateException- if not at a start tag or invalid index
-
getAttributeValue
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
Get an attribute value from the current start tag.- Parameters:
ns- namespace URI for expected attribute (may benullor the empty string for the empty namespace)name- attribute name expected- Returns:
- attribute value text, or
nullif 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
Get namespace URI.- Parameters:
index- declaration index- Returns:
- namespace URI
- Throws:
IllegalArgumentException- if invalid index
-
getNamespacePrefix
Get namespace prefix.- Parameters:
index- declaration index- Returns:
- namespace prefix,
nullif a default namespace - Throws:
IllegalArgumentException- if invalid index
-
getDocumentName
String getDocumentName()Get document name.- Returns:
- document name,
nullif not known
-
getLineNumber
int getLineNumber()Get current source line number.- Returns:
- line number from source document,
-1if line number information not available
-
getColumnNumber
int getColumnNumber()Get current source column number.- Returns:
- column number from source document,
-1if column number information not available
-
getNamespace
Get namespace URI associated with prefix.- Parameters:
prefix- namespace prefix to be matched (nullfor default namespace)- Returns:
- associated URI (
nullif 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 (
nullif unknown)
-
isNamespaceAware
boolean isNamespaceAware()Return namespace processing flag.- Returns:
- namespace processing flag (
trueif namespaces are processed by reader,falseif not)
-