java.lang.Object
tools.jackson.dataformat.xml.deser.XmlTokenStream
Simple helper class used on top of STAX
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected final booleanprotected final booleanprotected intprotected tools.jackson.dataformat.xml.deser.ElementWrapperWrapping state, if any active (null if none)protected final intBit flag composed of bits that indicate whichXmlReadFeatures are enabled.protected Stringprotected XmlNameProcessorprotected Stringprotected XmlNameProcessor.XmlNameReusable internal value objectprotected intIndex of the next attribute of the current START_ELEMENT to return (as property name and value pair), if any; -1 when no attributes to returnprotected StringIn 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 Stringprotected booleanMarker flag set if caller wants to "push back" current token so that next call tonext()should simply be given what was already read.protected intFlag used to indicate that given element should be "replayed".protected final tools.jackson.core.io.ContentReferenceprotected booleanFlag set true if current event isXML_TEXTand there is START_ELEMENTprotected StringCurrent text value for TEXT_VALUE returnedprotected final org.codehaus.stax2.XMLStreamReader2protected booleanMarker used to indicate presence of `xsi:nil="true"' in current START_ELEMENT.static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionXmlTokenStream(XMLStreamReader xmlReader, tools.jackson.core.io.ContentReference sourceRef, int formatFeatures, XmlNameProcessor nameProcessor) -
Method Summary
Modifier and TypeMethodDescriptionprotected static booleanprotected Stringprotected void_decodeAttributeName(String namespaceURI, String localName) protected void_decodeElementName(String namespaceURI, String localName) protected intMethod called to handle details of repeating "virtual" start/end elements, needed for handling 'unwrapped' lists.protected String_stateDesc(int state) voidclose()voidtools.jackson.core.TokenStreamLocationintAccessor for local name of current named event (that is,XML_START_ELEMENTorXML_ATTRIBUTE_NAME).getText()tools.jackson.core.TokenStreamLocationorg.codehaus.stax2.XMLStreamReader2booleanintSecond part of initialization, to be called immediately after constructionprotected voidMethod that can be called to mark stream as having reached end of stream.intnext()protected voidMethod that can be called to ask stream to literally just return current token with the next call tonext(), without more work.protected voidMethod used to add virtual wrapping, which just duplicates START_ELEMENT stream points to, and its matching closing element.protected voidMethod called to skip any attributes current START_ELEMENT may have, so that they are not returned as token.void
-
Field Details
-
XML_START_ELEMENT
public static final int XML_START_ELEMENT- See Also:
-
XML_END_ELEMENT
public static final int XML_END_ELEMENT- See Also:
-
XML_ATTRIBUTE_NAME
public static final int XML_ATTRIBUTE_NAME- See Also:
-
XML_ATTRIBUTE_VALUE
public static final int XML_ATTRIBUTE_VALUE- See Also:
-
XML_TEXT
public static final int XML_TEXT- See Also:
-
XML_ROOT_TEXT
public static final int XML_ROOT_TEXT- See Also:
-
XML_END
public static final int XML_END- See Also:
-
_xmlReader
protected final org.codehaus.stax2.XMLStreamReader2 _xmlReader -
_sourceReference
protected final tools.jackson.core.io.ContentReference _sourceReference -
_formatFeatures
protected final int _formatFeaturesBit flag composed of bits that indicate whichXmlReadFeatures are enabled. -
_cfgProcessXsiNil
protected final boolean _cfgProcessXsiNil -
_cfgProcessXsiType
protected final boolean _cfgProcessXsiType -
_nameProcessor
-
_currentState
protected int _currentState -
_attributeCount
protected int _attributeCount -
_xsiNilFound
protected boolean _xsiNilFoundMarker used to indicate presence of `xsi:nil="true"' in current START_ELEMENT.- Since:
- 2.10
-
_startElementAfterText
protected boolean _startElementAfterTextFlag set true if current event isXML_TEXTand there is START_ELEMENT- Since:
- 2.12
-
_nextAttributeIndex
protected int _nextAttributeIndexIndex of the next attribute of the current START_ELEMENT to return (as property name and value pair), if any; -1 when no attributes to return -
_localName
-
_namespaceURI
-
_textValue
Current text value for TEXT_VALUE returned -
_repeatCurrentToken
protected boolean _repeatCurrentTokenMarker flag set if caller wants to "push back" current token so that next call tonext()should simply be given what was already read.- Since:
- 2.12
-
_nameToDecode
Reusable internal value object- Since:
- 2.14
-
_repeatElement
protected int _repeatElementFlag used to indicate that given element should be "replayed". -
_currentWrapper
protected tools.jackson.dataformat.xml.deser.ElementWrapper _currentWrapperWrapping state, if any active (null if none) -
_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. -
_nextNamespaceURI
-
-
Constructor Details
-
XmlTokenStream
public XmlTokenStream(XMLStreamReader xmlReader, tools.jackson.core.io.ContentReference sourceRef, int formatFeatures, XmlNameProcessor nameProcessor)
-
-
Method Details
-
initialize
Second part of initialization, to be called immediately after construction- Throws:
XMLStreamException- Since:
- 2.12
-
getXmlReader
public org.codehaus.stax2.XMLStreamReader2 getXmlReader() -
next
- Throws:
XMLStreamException
-
skipEndElement
- Throws:
IOExceptionXMLStreamException
-
getCurrentToken
public int getCurrentToken() -
getText
-
getLocalName
Accessor for local name of current named event (that is,XML_START_ELEMENTorXML_ATTRIBUTE_NAME).NOTE: name NOT accessible on
XML_END_ELEMENT -
getNamespaceURI
-
hasXsiNil
public boolean hasXsiNil() -
closeCompletely
- Throws:
XMLStreamException
-
close
- Throws:
XMLStreamException
-
getCurrentLocation
public tools.jackson.core.TokenStreamLocation getCurrentLocation() -
getTokenLocation
public tools.jackson.core.TokenStreamLocation getTokenLocation() -
repeatStartElement
protected void repeatStartElement()Method used to add virtual wrapping, which just duplicates START_ELEMENT stream points to, and its matching closing element. -
pushbackCurrentToken
protected void pushbackCurrentToken()Method that can be called to ask stream to literally just return current token with the next call tonext(), without more work.- Since:
- 2.12
-
markAsStreamEnd
protected void markAsStreamEnd()Method that can be called to mark stream as having reached end of stream.- Since:
- 2.19
-
skipAttributes
protected void skipAttributes()Method called to skip any attributes current START_ELEMENT may have, so that they are not returned as token.- Since:
- 2.1
-
_decodeElementName
- Since:
- 2.14
-
_decodeAttributeName
- Since:
- 2.14
-
_handleRepeatElement
Method called to handle details of repeating "virtual" start/end elements, needed for handling 'unwrapped' lists.- Throws:
XMLStreamException
-
_allWs
-
_currentStateDesc
-
_stateDesc
-