public class StAXReaderWrapper extends java.lang.Object implements IXMLReader
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
m_accumulatedText
Accumulated text for return.
|
private java.lang.String |
m_docName
Document name.
|
private java.lang.String |
m_encoding
Document encoding (apparently cannot be read after parse done).
|
private IntStack |
m_inScopeCounts
Namespace definitions in scope at each nesting depth.
|
private GrowableStringArray |
m_inScopePrefixes
Namespace prefixes in scope.
|
private GrowableStringArray |
m_inScopeUris
Namespace URIs in scope.
|
(package private) boolean |
m_isNamespaceAware
Parser processing namespaces flag.
|
private boolean |
m_isProcessingInstruction
Accumulated text is processing instruction flag (otherwise content)
|
(package private) int |
m_nestingDepth
Current element nesting depth.
|
private javax.xml.stream.XMLStreamReader |
m_parser
Actual parser.
|
(package private) static byte[] |
s_eventTranslations
Event type code translation array.
|
CDSECT, COMMENT, DOCDECL, END_DOCUMENT, END_TAG, ENTITY_REF, IGNORABLE_WHITESPACE, PROCESSING_INSTRUCTION, START_DOCUMENT, START_TAG, TEXT
Constructor and Description |
---|
StAXReaderWrapper(javax.xml.stream.XMLStreamReader rdr,
java.lang.String name,
boolean nsa)
Constructor used by factory.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
buildPositionString()
Build current parse input position description.
|
private void |
endTag()
Handle end tag.
|
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.
|
private void |
startTag()
Handle start tag.
|
static final byte[] s_eventTranslations
private final javax.xml.stream.XMLStreamReader m_parser
final boolean m_isNamespaceAware
private final java.lang.String m_docName
int m_nestingDepth
private IntStack m_inScopeCounts
private GrowableStringArray m_inScopeUris
private GrowableStringArray m_inScopePrefixes
private java.lang.String m_accumulatedText
private boolean m_isProcessingInstruction
private java.lang.String m_encoding
public StAXReaderWrapper(javax.xml.stream.XMLStreamReader rdr, java.lang.String name, boolean nsa)
rdr
- event readername
- document namensa
- namespace aware flagpublic void init()
init
in interface IXMLReader
public java.lang.String buildPositionString()
buildPositionString
in interface IXMLReader
private void startTag()
private void endTag()
public int nextToken() throws JiBXException
IXMLReader
nextToken
in interface IXMLReader
JiBXException
- if error reading or parsing documentpublic int next() throws JiBXException
IXMLReader
IXMLReader.nextToken()
, which consolidates text
content and ignores parse events for components such as comments and PIs.next
in interface IXMLReader
JiBXException
- if error reading or parsing documentpublic int getEventType() throws JiBXException
IXMLReader
getEventType
in interface IXMLReader
JiBXException
- if error parsing documentpublic java.lang.String getName()
IXMLReader
getName
in interface IXMLReader
public java.lang.String getNamespace()
IXMLReader
getNamespace
in interface IXMLReader
public java.lang.String getPrefix()
IXMLReader
getPrefix
in interface IXMLReader
null
if no prefix)public int getAttributeCount()
IXMLReader
getAttributeCount
in interface IXMLReader
public java.lang.String getAttributeName(int index)
IXMLReader
getAttributeName
in interface IXMLReader
index
- attribute indexpublic java.lang.String getAttributeNamespace(int index)
IXMLReader
getAttributeNamespace
in interface IXMLReader
index
- attribute indexpublic java.lang.String getAttributePrefix(int index)
IXMLReader
getAttributePrefix
in interface IXMLReader
index
- attribute indexnull
if no prefix present)public java.lang.String getAttributeValue(int index)
IXMLReader
getAttributeValue
in interface IXMLReader
index
- attribute indexpublic java.lang.String getAttributeValue(java.lang.String ns, java.lang.String name)
IXMLReader
getAttributeValue
in interface IXMLReader
ns
- namespace URI for expected attribute (may be null
or the empty string for the empty namespace)name
- attribute name expectednull
if missingpublic java.lang.String getText()
IXMLReader
getText
in interface IXMLReader
public int getNestingDepth()
IXMLReader
getNestingDepth
in interface IXMLReader
public int getNamespaceCount(int depth)
IXMLReader
getNamespaceCount
in interface IXMLReader
depth
- element nesting depthpublic java.lang.String getNamespaceUri(int index)
IXMLReader
getNamespaceUri
in interface IXMLReader
index
- declaration indexpublic java.lang.String getNamespacePrefix(int index)
IXMLReader
getNamespacePrefix
in interface IXMLReader
index
- declaration indexnull
if a default namespacepublic java.lang.String getDocumentName()
IXMLReader
getDocumentName
in interface IXMLReader
null
if not knownpublic int getLineNumber()
IXMLReader
getLineNumber
in interface IXMLReader
-1
if line number
information not availablepublic int getColumnNumber()
IXMLReader
getColumnNumber
in interface IXMLReader
-1
if column
number information not availablepublic java.lang.String getNamespace(java.lang.String prefix)
IXMLReader
getNamespace
in interface IXMLReader
prefix
- namespace prefix to be matched (null
for
default namespace)null
if prefix not defined)public java.lang.String getInputEncoding()
IXMLReader
getInputEncoding
in interface IXMLReader
null
if unknown)public boolean isNamespaceAware()
IXMLReader
isNamespaceAware
in interface IXMLReader
true
if namespaces are
processed by reader, false
if not)