Package org.jibx.runtime.impl
Class XMLPullReaderFactory.XMLPullReader
- java.lang.Object
-
- org.jibx.runtime.impl.XMLPullReaderFactory.XMLPullReader
-
- All Implemented Interfaces:
IXMLReader
- Enclosing class:
- XMLPullReaderFactory
private static class XMLPullReaderFactory.XMLPullReader extends java.lang.Object implements IXMLReader
Wrapper for an XMLPull parser implementation. Since the internal parser API was originally based on XMLPull, this basically just delegates all the calls with minimal processing.
-
-
Field Summary
Fields Modifier and Type Field Description private InByteBufferm_byteBufferByte buffer used when stream set directly (lazy create,nullif not used).private java.lang.Stringm_docNameDocument name.private java.lang.Stringm_encodingInput document character encoding (nullif unknown)private XmlPullParserm_parserActual parser.private InputStreamWrapperm_streamWrapperWrapper for supplied input stream (lazy create,nullif not used).-
Fields inherited from interface org.jibx.runtime.IXMLReader
CDSECT, COMMENT, DOCDECL, END_DOCUMENT, END_TAG, ENTITY_REF, IGNORABLE_WHITESPACE, PROCESSING_INSTRUCTION, START_DOCUMENT, START_TAG, TEXT
-
-
Constructor Summary
Constructors Modifier Constructor Description privateXMLPullReader(XmlPullParser parser)Constructor used by factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringbuildPositionString()Build current parse input position description.private java.lang.StringdescribeException(java.lang.Exception e)Format error message from exception.intgetAttributeCount()Get the number of attributes of the current start tag.java.lang.StringgetAttributeName(int index)Get an attribute name from the current start tag.java.lang.StringgetAttributeNamespace(int index)Get an attribute namespace from the current start tag.java.lang.StringgetAttributePrefix(int index)Get an attribute prefix from the current start tag.java.lang.StringgetAttributeValue(int index)Get an attribute value from the current start tag.java.lang.StringgetAttributeValue(java.lang.String ns, java.lang.String name)Get an attribute value from the current start tag.intgetColumnNumber()Get current source column number.java.lang.StringgetDocumentName()Get document name.intgetEventType()Gets the current parse event type, without changing the current parse state.java.lang.StringgetInputEncoding()Return the input encoding, if known.intgetLineNumber()Get current source line number.java.lang.StringgetName()Get element name from the current start or end tag.java.lang.StringgetNamespace()Get element namespace from the current start or end tag.java.lang.StringgetNamespace(java.lang.String prefix)Get namespace URI associated with prefix.intgetNamespaceCount(int depth)Get number of namespace declarations active at depth.java.lang.StringgetNamespacePrefix(int index)Get namespace prefix.java.lang.StringgetNamespaceUri(int index)Get namespace URI.intgetNestingDepth()Get current element nesting depth.java.lang.StringgetPrefix()Get element prefix from the current start or end tag.java.lang.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.private voidsetDocument(java.io.InputStream is, java.lang.String name, java.lang.String enc)Set document to be parsed from input stream.private voidsetDocument(java.io.Reader rdr, java.lang.String name)Set document to be parsed from reader.
-
-
-
Field Detail
-
m_parser
private final XmlPullParser m_parser
Actual parser.
-
m_docName
private java.lang.String m_docName
Document name.
-
m_byteBuffer
private InByteBuffer m_byteBuffer
Byte buffer used when stream set directly (lazy create,nullif not used).
-
m_streamWrapper
private InputStreamWrapper m_streamWrapper
Wrapper for supplied input stream (lazy create,nullif not used).
-
m_encoding
private java.lang.String m_encoding
Input document character encoding (nullif unknown)
-
-
Method Detail
-
setDocument
private void setDocument(java.io.InputStream is, java.lang.String name, java.lang.String enc) throws JiBXExceptionSet document to be parsed from input stream.- Parameters:
is- document input streamname- document name (nullif unknown)enc- document character encoding (nullif unknown)- Throws:
JiBXException- on parser configuration error
-
setDocument
private void setDocument(java.io.Reader rdr, java.lang.String name) throws JiBXExceptionSet document to be parsed from reader.- Parameters:
rdr- document readername- document name (nullif unknown)- Throws:
JiBXException- on parser configuration error
-
describeException
private java.lang.String describeException(java.lang.Exception e)
Format error message from exception.- Parameters:
e- root cause exception
-
init
public void init()
Description copied from interface:IXMLReaderInitialize reader.- Specified by:
initin interfaceIXMLReader
-
buildPositionString
public java.lang.String buildPositionString()
Description copied from interface:IXMLReaderBuild current parse input position description.- Specified by:
buildPositionStringin interfaceIXMLReader- Returns:
- text description of current parse position
-
nextToken
public int nextToken() throws JiBXExceptionDescription copied from interface:IXMLReaderAdvance to next parse event of input document.- Specified by:
nextTokenin interfaceIXMLReader- Returns:
- parse event type code
- Throws:
JiBXException- if error reading or parsing document
-
next
public int next() throws JiBXExceptionDescription copied from interface:IXMLReaderAdvance to next binding component of input document. This is a higher-level operation thanIXMLReader.nextToken(), which consolidates text content and ignores parse events for components such as comments and PIs.- Specified by:
nextin interfaceIXMLReader- Returns:
- parse event type code
- Throws:
JiBXException- if error reading or parsing document
-
getEventType
public int getEventType() throws JiBXExceptionDescription copied from interface:IXMLReaderGets the current parse event type, without changing the current parse state.- Specified by:
getEventTypein interfaceIXMLReader- Returns:
- parse event type code
- Throws:
JiBXException- if error parsing document
-
getName
public java.lang.String getName()
Description copied from interface:IXMLReaderGet element name from the current start or end tag.- Specified by:
getNamein interfaceIXMLReader- Returns:
- local name if namespace handling enabled, full name if namespace handling disabled
-
getNamespace
public java.lang.String getNamespace()
Description copied from interface:IXMLReaderGet element namespace from the current start or end tag.- Specified by:
getNamespacein interfaceIXMLReader- Returns:
- namespace URI if namespace handling enabled and element is in a namespace, empty string otherwise
-
getPrefix
public java.lang.String getPrefix()
Description copied from interface:IXMLReaderGet element prefix from the current start or end tag.- Specified by:
getPrefixin interfaceIXMLReader- Returns:
- prefix text (
nullif no prefix)
-
getAttributeCount
public int getAttributeCount()
Description copied from interface:IXMLReaderGet the number of attributes of the current start tag.- Specified by:
getAttributeCountin interfaceIXMLReader- Returns:
- number of attributes
-
getAttributeName
public java.lang.String getAttributeName(int index)
Description copied from interface:IXMLReaderGet an attribute name from the current start tag.- Specified by:
getAttributeNamein interfaceIXMLReader- Parameters:
index- attribute index- Returns:
- local name if namespace handling enabled, full name if namespace handling disabled
-
getAttributeNamespace
public java.lang.String getAttributeNamespace(int index)
Description copied from interface:IXMLReaderGet an attribute namespace from the current start tag.- Specified by:
getAttributeNamespacein interfaceIXMLReader- Parameters:
index- attribute index- Returns:
- namespace URI if namespace handling enabled and attribute is in a namespace, empty string otherwise
-
getAttributePrefix
public java.lang.String getAttributePrefix(int index)
Description copied from interface:IXMLReaderGet an attribute prefix from the current start tag.- Specified by:
getAttributePrefixin interfaceIXMLReader- Parameters:
index- attribute index- Returns:
- prefix for attribute (
nullif no prefix present)
-
getAttributeValue
public java.lang.String getAttributeValue(int index)
Description copied from interface:IXMLReaderGet an attribute value from the current start tag.- Specified by:
getAttributeValuein interfaceIXMLReader- Parameters:
index- attribute index- Returns:
- value text
-
getAttributeValue
public java.lang.String getAttributeValue(java.lang.String ns, java.lang.String name)Description copied from interface:IXMLReaderGet an attribute value from the current start tag.- Specified by:
getAttributeValuein interfaceIXMLReader- 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
-
getText
public java.lang.String getText()
Description copied from interface:IXMLReaderGet 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.- Specified by:
getTextin interfaceIXMLReader- Returns:
- text for current event
-
getNestingDepth
public int getNestingDepth()
Description copied from interface:IXMLReaderGet current element nesting depth. The returned depth always includes the current start or end tag (if positioned on a start or end tag).- Specified by:
getNestingDepthin interfaceIXMLReader- Returns:
- element nesting depth
-
getNamespaceCount
public int getNamespaceCount(int depth)
Description copied from interface:IXMLReaderGet number of namespace declarations active at depth.- Specified by:
getNamespaceCountin interfaceIXMLReader- Parameters:
depth- element nesting depth- Returns:
- number of namespaces active at depth
-
getNamespaceUri
public java.lang.String getNamespaceUri(int index)
Description copied from interface:IXMLReaderGet namespace URI.- Specified by:
getNamespaceUriin interfaceIXMLReader- Parameters:
index- declaration index- Returns:
- namespace URI
-
getNamespacePrefix
public java.lang.String getNamespacePrefix(int index)
Description copied from interface:IXMLReaderGet namespace prefix.- Specified by:
getNamespacePrefixin interfaceIXMLReader- Parameters:
index- declaration index- Returns:
- namespace prefix,
nullif a default namespace
-
getDocumentName
public java.lang.String getDocumentName()
Description copied from interface:IXMLReaderGet document name.- Specified by:
getDocumentNamein interfaceIXMLReader- Returns:
- document name,
nullif not known
-
getLineNumber
public int getLineNumber()
Description copied from interface:IXMLReaderGet current source line number.- Specified by:
getLineNumberin interfaceIXMLReader- Returns:
- line number from source document,
-1if line number information not available
-
getColumnNumber
public int getColumnNumber()
Description copied from interface:IXMLReaderGet current source column number.- Specified by:
getColumnNumberin interfaceIXMLReader- Returns:
- column number from source document,
-1if column number information not available
-
getNamespace
public java.lang.String getNamespace(java.lang.String prefix)
Description copied from interface:IXMLReaderGet namespace URI associated with prefix.- Specified by:
getNamespacein interfaceIXMLReader- Parameters:
prefix- namespace prefix to be matched (nullfor default namespace)- Returns:
- associated URI (
nullif prefix not defined)
-
getInputEncoding
public java.lang.String getInputEncoding()
Description copied from interface:IXMLReaderReturn the input encoding, if known. This is only valid after parsing of a document has been started.- Specified by:
getInputEncodingin interfaceIXMLReader- Returns:
- input encoding (
nullif unknown)
-
isNamespaceAware
public boolean isNamespaceAware()
Description copied from interface:IXMLReaderReturn namespace processing flag.- Specified by:
isNamespaceAwarein interfaceIXMLReader- Returns:
- namespace processing flag (
trueif namespaces are processed by reader,falseif not)
-
-