Package org.jibx.runtime
Interface IXMLReader
-
- All Known Implementing Classes:
StAXReaderWrapper
public interface IXMLReaderXML 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
Fields Modifier and Type Field Description static intCDSECTstatic intCOMMENTstatic intDOCDECLstatic intEND_DOCUMENTstatic intEND_TAGstatic intENTITY_REFstatic intIGNORABLE_WHITESPACEstatic intPROCESSING_INSTRUCTIONstatic intSTART_DOCUMENTstatic intSTART_TAGstatic intTEXT
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringbuildPositionString()Build current parse input position description.intgetAttributeCount()Get the number of attributes of the current start tag.StringgetAttributeName(int index)Get an attribute name from the current start tag.StringgetAttributeNamespace(int index)Get an attribute namespace from the current start tag.StringgetAttributePrefix(int index)Get an attribute prefix from the current start tag.StringgetAttributeValue(int index)Get an attribute value from the current start tag.StringgetAttributeValue(String ns, String name)Get an attribute value from the current start tag.intgetColumnNumber()Get current source column number.StringgetDocumentName()Get document name.intgetEventType()Gets the current parse event type, without changing the current parse state.StringgetInputEncoding()Return the input encoding, if known.intgetLineNumber()Get current source line number.StringgetName()Get element name from the current start or end tag.StringgetNamespace()Get element namespace from the current start or end tag.StringgetNamespace(String prefix)Get namespace URI associated with prefix.intgetNamespaceCount(int depth)Get number of namespace declarations active at depth.StringgetNamespacePrefix(int index)Get namespace prefix.StringgetNamespaceUri(int index)Get namespace URI.intgetNestingDepth()Get current element nesting depth.StringgetPrefix()Get element prefix from the current start or end tag.StringgetText()Get current text.voidinit()Initialize reader.booleanisNamespaceAware()Return namespace processing flag.intnext()Advance to next binding component of input document.intnextToken()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 IOException
Initialize reader.- Throws:
IOException- If I/O error
-
buildPositionString
String buildPositionString()
Build current parse input position description.- Returns:
- text description of current parse position
-
nextToken
int nextToken() throws JiBXExceptionAdvance 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 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
int getEventType() throws JiBXExceptionGets 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
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 (
nullif 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 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
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,
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
String getNamespace(String prefix)
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)
-
-