public class XmlTokenStream extends Object
XMLStreamReader
to further
abstract out all irrelevant details, and to expose equivalent of flat token
stream with no "fluff" tokens (comments, processing instructions, mixed
content) all of which is just to simplify
actual higher-level conversion to JSON tokens.
Beyond initial idea there are also couple of other detours like ability to "replay" some tokens, add virtual wrappers (ironically to support "unwrapped" array values), and to unroll "Objects" into String values in some cases.
Modifier and Type | Field and Description |
---|---|
protected int |
_attributeCount |
protected boolean |
_cfgProcessXsiNil |
protected int |
_currentState |
protected com.fasterxml.jackson.dataformat.xml.deser.ElementWrapper |
_currentWrapper
Wrapping state, if any active (null if none)
|
protected int |
_formatFeatures
Bit flag composed of bits that indicate which
FromXmlParser.Feature s
are enabled. |
protected String |
_localName |
protected XmlNameProcessor |
_nameProcessor |
protected String |
_namespaceURI |
protected XmlNameProcessor.XmlName |
_nameToDecode
Reusable internal value object
|
protected int |
_nextAttributeIndex
Index of the next attribute of the current START_ELEMENT
to return (as field name and value pair), if any; -1
when no attributes to return
|
protected String |
_nextLocalName
In cases where we need to 'inject' a virtual END_ELEMENT, we may also
need to restore START_ELEMENT afterwards; if so, this is where names
are held.
|
protected String |
_nextNamespaceURI |
protected boolean |
_repeatCurrentToken
Marker flag set if caller wants to "push back" current token so
that next call to
next() should simply be given what was
already read. |
protected int |
_repeatElement
Flag used to indicate that given element should be "replayed".
|
protected com.fasterxml.jackson.core.io.ContentReference |
_sourceReference |
protected boolean |
_startElementAfterText
Flag set true if current event is
XML_TEXT and there is START_ELEMENT |
protected String |
_textValue
Current text value for TEXT_VALUE returned
|
protected org.codehaus.stax2.XMLStreamReader2 |
_xmlReader |
protected boolean |
_xsiNilFound
Marker used to indicate presence of `xsi:nil="true"' in current START_ELEMENT.
|
static int |
XML_ATTRIBUTE_NAME |
static int |
XML_ATTRIBUTE_VALUE |
static int |
XML_END |
static int |
XML_END_ELEMENT |
static int |
XML_ROOT_TEXT |
static int |
XML_START_ELEMENT |
static int |
XML_TEXT |
Constructor and Description |
---|
XmlTokenStream(XMLStreamReader xmlReader,
com.fasterxml.jackson.core.io.ContentReference sourceRef,
int formatFeatures,
XmlNameProcessor nameProcessor) |
Modifier and Type | Method and Description |
---|---|
protected static boolean |
_allWs(String str) |
protected String |
_currentStateDesc() |
protected void |
_decodeAttributeName(String namespaceURI,
String localName) |
protected void |
_decodeElementName(String namespaceURI,
String localName) |
protected int |
_handleRepeatElement()
Method called to handle details of repeating "virtual"
start/end elements, needed for handling 'unwrapped' lists.
|
protected String |
_stateDesc(int state) |
void |
close() |
void |
closeCompletely() |
com.fasterxml.jackson.core.JsonLocation |
getCurrentLocation() |
int |
getCurrentToken() |
String |
getLocalName()
Accessor for local name of current named event (that is,
XML_START_ELEMENT or XML_ATTRIBUTE_NAME ). |
String |
getNamespaceURI() |
String |
getText() |
com.fasterxml.jackson.core.JsonLocation |
getTokenLocation() |
org.codehaus.stax2.XMLStreamReader2 |
getXmlReader() |
boolean |
hasXsiNil() |
int |
initialize()
Second part of initialization, to be called immediately after construction
|
int |
next() |
protected void |
pushbackCurrentToken()
Method that can be called to ask stream to literally just return current token
with the next call to
next() , without more work. |
protected void |
repeatStartElement()
Method used to add virtual wrapping, which just duplicates START_ELEMENT
stream points to, and its matching closing element.
|
protected void |
setFormatFeatures(int f) |
protected void |
skipAttributes()
Method called to skip any attributes current START_ELEMENT may have,
so that they are not returned as token.
|
void |
skipEndElement() |
public static final int XML_START_ELEMENT
public static final int XML_END_ELEMENT
public static final int XML_ATTRIBUTE_NAME
public static final int XML_ATTRIBUTE_VALUE
public static final int XML_TEXT
public static final int XML_ROOT_TEXT
public static final int XML_END
protected final org.codehaus.stax2.XMLStreamReader2 _xmlReader
protected final com.fasterxml.jackson.core.io.ContentReference _sourceReference
protected int _formatFeatures
FromXmlParser.Feature
s
are enabled.protected boolean _cfgProcessXsiNil
protected XmlNameProcessor _nameProcessor
protected int _currentState
protected int _attributeCount
protected boolean _xsiNilFound
protected boolean _startElementAfterText
XML_TEXT
and there is START_ELEMENTprotected int _nextAttributeIndex
protected String _localName
protected String _namespaceURI
protected String _textValue
protected boolean _repeatCurrentToken
next()
should simply be given what was
already read.protected XmlNameProcessor.XmlName _nameToDecode
protected int _repeatElement
protected com.fasterxml.jackson.dataformat.xml.deser.ElementWrapper _currentWrapper
protected String _nextLocalName
protected String _nextNamespaceURI
public XmlTokenStream(XMLStreamReader xmlReader, com.fasterxml.jackson.core.io.ContentReference sourceRef, int formatFeatures, XmlNameProcessor nameProcessor)
public int initialize() throws XMLStreamException
XMLStreamException
public org.codehaus.stax2.XMLStreamReader2 getXmlReader()
protected void setFormatFeatures(int f)
public int next() throws XMLStreamException
XMLStreamException
public void skipEndElement() throws IOException, XMLStreamException
IOException
XMLStreamException
public int getCurrentToken()
public String getText()
public String getLocalName()
XML_START_ELEMENT
or XML_ATTRIBUTE_NAME
).
NOTE: name NOT accessible on XML_END_ELEMENT
public String getNamespaceURI()
public boolean hasXsiNil()
public void closeCompletely() throws XMLStreamException
XMLStreamException
public void close() throws XMLStreamException
XMLStreamException
public com.fasterxml.jackson.core.JsonLocation getCurrentLocation()
public com.fasterxml.jackson.core.JsonLocation getTokenLocation()
protected void repeatStartElement()
protected void pushbackCurrentToken()
next()
, without more work.protected void skipAttributes()
protected void _decodeElementName(String namespaceURI, String localName)
protected void _decodeAttributeName(String namespaceURI, String localName)
protected int _handleRepeatElement() throws XMLStreamException
XMLStreamException
protected static boolean _allWs(String str)
protected String _currentStateDesc()
protected String _stateDesc(int state)
Copyright © 2022 FasterXML. All rights reserved.