Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.dataformat.xml.deser

public Class FromXmlParser

extends ParserMinimalBase
implements ElementWrappable
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.dataformat.xml.deser.ElementWrappable
Imports
java.io.IOException, .UncheckedIOException, .Writer, java.math.BigDecimal, .BigInteger, java.util.Set, javax.xml.stream.XMLStreamException, .XMLStreamReader, .XMLStreamWriter, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.base.ParserMinimalBase, com.fasterxml.jackson.core.exc.StreamConstraintsException, com.fasterxml.jackson.core.io.IOContext, .NumberInput, com.fasterxml.jackson.core.util.ByteArrayBuilder, .JacksonFeatureSet, com.fasterxml.jackson.dataformat.xml.PackageVersion, .XmlMapper, .XmlNameProcessor, com.fasterxml.jackson.dataformat.xml.util.CaseInsensitiveNameSet, .StaxUtil

JsonParser implementation that exposes XML structure as set of JSON events that can be used for data binding.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
FromXmlParser.Feature

Enumeration that defines all togglable features for XML parsers.

Field Summary

Modifier and TypeField and Description
protected byte[]
_binaryValue

We will hold on to decoded binary data, for duration of current event, so that multiple calls to getBinaryValue will not need to decode data more than once.

protected ByteArrayBuilder
_byteArrayBuilder

ByteArrayBuilder is needed if 'getBinaryValue' is called.

protected String
_cfgNameForTextElement

In cases where a start element has both attributes and non-empty textual value, we have to create a bogus property; we will use this as the property name.

protected boolean
_closed

Flag that indicates whether parser is closed or not.

protected String
protected int
_formatFeatures

Bit flag composed of bits that indicate which FromXmlParser.Features are enabled.

protected final IOContext
protected boolean
_mayBeLeaf

We need special handling to keep track of whether a value may be exposed as simple leaf value.

protected boolean
_nextIsLeadingMixed

Additional flag that is strictly needed when exposing "mixed" leading String value as "anonymous" property/string pair.

protected JsonToken
protected BigInteger
protected int
protected long
protected int
_numTypesValid

Bitfield that indicates which numeric representations have been calculated for the current type

protected ObjectCodec
protected XmlReadContext
_parsingContext

Information about parser context, context in which the next token is to be parsed (root, array, object).

protected final StreamReadConstraints
protected final XmlTokenStream
public static final String
DEFAULT_UNNAMED_TEXT_PROPERTY

The default name placeholder for XML text segments is empty String ("").

protected static final JacksonFeatureSet<StreamReadCapability>
XML_READ_CAPABILITIES

XML format has some peculiarities, indicated via new (2.12) capability system.

Inherited from com.fasterxml.jackson.core.base.ParserMinimalBase:
_currToken_lastClearedTokenBD_MAX_INTBD_MAX_LONGBD_MIN_INTBD_MIN_LONGBI_MAX_INTBI_MAX_LONGBI_MIN_INTBI_MIN_LONGCHAR_NULLINT_0INT_9INT_APOSINT_ASTERISKINT_BACKSLASHINT_COLONINT_COMMAINT_CRINT_eINT_EINT_HASHINT_LBRACKETINT_LCURLYINT_LFINT_MINUSINT_PERIODINT_PLUSINT_QUOTEINT_RBRACKETINT_RCURLYINT_SLASHINT_SPACEINT_TABMAX_ERROR_TOKEN_LENGTHMAX_INT_DMAX_INT_LMAX_LONG_DMIN_INT_DMIN_INT_LMIN_LONG_DNO_BYTESNO_INTSNR_BIGDECIMALNR_BIGINTNR_DOUBLENR_FLOATNR_INTNR_LONGNR_UNKNOWN

Constructor Summary

AccessConstructor and Description
public
FromXmlParser(IOContext ctxt, int genericParserFeatures, int xmlFeatures, ObjectCodec codec, XMLStreamReader xmlReader, XmlNameProcessor tagProcessor)

Method Summary

Modifier and TypeMethod and Description
protected final void
_checkNumericValue(int expType)

protected BigDecimal
protected void
protected double
protected float
protected void
protected void
protected byte[]
protected ByteArrayBuilder
protected void
_handleEOF()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase._handleEOF.

Method called when an EOF is encountered between tokens.
private <T> T
protected final int
protected int
protected void
_releaseBuffers()

Method called to release internal buffers owned by the base parser.

protected void
private void
public void
addVirtualWrapping(Set<String> namesToWrap0, boolean caseInsensitive)

Implements com.fasterxml.jackson.dataformat.xml.deser.ElementWrappable.addVirtualWrapping.

Method that may be called to indicate that specified names (only local parts retained currently: this may be changed in future) should be considered "auto-wrapping", meaning that they will be doubled to contain two opening elements, two matching closing elements.
public boolean
canReadObjectId()

Overrides com.fasterxml.jackson.core.JsonParser.canReadObjectId.

Introspection method that may be called to see if the underlying data format supports some kind of Object Ids natively (many do not; for example, JSON doesn't).
public boolean
canReadTypeId()

Overrides com.fasterxml.jackson.core.JsonParser.canReadTypeId.

Introspection method that may be called to see if the underlying data format supports some kind of Type Ids natively (many do not; for example, JSON doesn't).
public void
close()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.close.

Implements java.io.Closeable.close.

Closes the parser so that no further iteration or data access can be made; will also close the underlying input source if parser either owns the input source, or feature Feature#AUTO_CLOSE_SOURCE is enabled.
public FromXmlParser
configure(FromXmlParser.Feature f, boolean state)

public FromXmlParser
public FromXmlParser
public BigInteger
getBigIntegerValue()

Implements abstract com.fasterxml.jackson.core.JsonParser.getBigIntegerValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_INT and it can not be used as a Java long primitive type due to its magnitude.
public byte[]
getBinaryValue(Base64Variant
Expected variant of base64 encoded content (see Base64Variants for definitions of "standard" variants).
b64variant
)

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getBinaryValue.

Method that can be used to read (and consume -- results may not be accessible using other methods after the call) base64-encoded binary data included in the current textual JSON value.
public ObjectCodec
getCodec()

Implements abstract com.fasterxml.jackson.core.JsonParser.getCodec.

Accessor for ObjectCodec associated with this parser, if any.
public JsonLocation
getCurrentLocation()

Implements abstract com.fasterxml.jackson.core.JsonParser.getCurrentLocation.

Method that returns location of the last processed character; usually for error reporting purposes
public String
getCurrentName()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getCurrentName.

Method that can be called to get the name associated with the current event.
public BigDecimal
getDecimalValue()

Implements abstract com.fasterxml.jackson.core.JsonParser.getDecimalValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_FLOAT or JsonToken#VALUE_NUMBER_INT.
public double
getDoubleValue()

Implements abstract com.fasterxml.jackson.core.JsonParser.getDoubleValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_FLOAT and it can be expressed as a Java double primitive type.
public Object
getEmbeddedObject()

Overrides com.fasterxml.jackson.core.JsonParser.getEmbeddedObject.

Accessor that can be called if (and only if) the current token is JsonToken#VALUE_EMBEDDED_OBJECT.
public float
getFloatValue()

Implements abstract com.fasterxml.jackson.core.JsonParser.getFloatValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_FLOAT and it can be expressed as a Java float primitive type.
public int
getFormatFeatures()

Overrides com.fasterxml.jackson.core.JsonParser.getFormatFeatures.

Bulk access method for getting state of all FormatFeatures, format-specific on/off configuration settings.
public int
getIntValue()

Implements abstract com.fasterxml.jackson.core.JsonParser.getIntValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_INT and it can be expressed as a value of Java int primitive type.
public long
getLongValue()

Implements abstract com.fasterxml.jackson.core.JsonParser.getLongValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_INT and it can be expressed as a Java long primitive type.
public JsonParser.NumberType
getNumberType()

Implements abstract com.fasterxml.jackson.core.JsonParser.getNumberType.

If current token is of type JsonToken#VALUE_NUMBER_INT or JsonToken#VALUE_NUMBER_FLOAT, returns one of NumberType constants; otherwise returns null.
public Number
getNumberValue()

Implements abstract com.fasterxml.jackson.core.JsonParser.getNumberValue.

Generic number value accessor method that will work for all kinds of numeric values.
public XmlReadContext
getParsingContext()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getParsingContext.

Method that can be used to access current parsing context reader is in. There are 3 different types: root, array and object contexts, with slightly different available information.
public JacksonFeatureSet<StreamReadCapability>
getReadCapabilities()

Overrides com.fasterxml.jackson.core.JsonParser.getReadCapabilities.

Accessor for getting metadata on capabilities of this parser, based on underlying data format being read (directly or indirectly).
public XMLStreamReader
getStaxReader()

Method that allows application direct access to underlying Stax XMLStreamWriter.

public String
getText()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getText.

Method for accessing textual representation of the current token; if no current token (before first call to nextToken, or after encountering end-of-input), returns null.
public int
getText(Writer
Writer to write textual content to
writer
)

Overrides com.fasterxml.jackson.core.JsonParser.getText.

Method to read the textual representation of the current token in chunks and pass it to the given Writer.
public char[]
getTextCharacters()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getTextCharacters.

Method similar to getText, but that will return underlying (unmodifiable) character array that contains textual value, instead of constructing a String object to contain this information.
public int
getTextLength()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getTextLength.

Accessor used with getTextCharacters, to know length of String stored in returned buffer.
public int
getTextOffset()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getTextOffset.

Accessor used with getTextCharacters, to know offset of the first text content character within buffer.
public JsonLocation
getTokenLocation()

Implements abstract com.fasterxml.jackson.core.JsonParser.getTokenLocation.

Method that return the starting location of the current token; that is, position of the first character from input that starts the current token.
public boolean
hasTextCharacters()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.hasTextCharacters.

XML input actually would offer access to character arrays; but since we must coalesce things it cannot really be exposed.
public boolean
isClosed()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.isClosed.

Method that can be called to determine whether this parser is closed or not.
public final boolean
public boolean
isExpectedNumberIntToken()

Overrides com.fasterxml.jackson.core.base.ParserMinimalBase.isExpectedNumberIntToken.

Since xml representation can not really distinguish between different scalar types (numbers, booleans) -- they are all just Character Data, without schema -- we can try to infer type from intent here.
public boolean
isExpectedStartArrayToken()

Overrides com.fasterxml.jackson.core.base.ParserMinimalBase.isExpectedStartArrayToken.

Since xml representation can not really distinguish between array and object starts (both are represented with elements), this method is overridden and taken to mean that expecation is that the current start element is to mean 'start array', instead of default of 'start object'.
public boolean
isNaN()

Overrides com.fasterxml.jackson.core.JsonParser.isNaN.

Access for checking whether current token is a numeric value token, but one that is of "not-a-number" (NaN) variety (including both "NaN" AND positive/negative infinity!): not supported by all formats, but often supported for JsonToken#VALUE_NUMBER_FLOAT.
public String
nextTextValue()

Overrides com.fasterxml.jackson.core.JsonParser.nextTextValue.

Method overridden to support more reliable deserialization of String collections.
public JsonToken
nextToken()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.nextToken.

Main iteration method, which will advance stream enough to determine type of the next token, if any.
public void
overrideCurrentName(String
Name to use as the current name; may be null.
name
)

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.overrideCurrentName.

Method that can be used to change what is considered to be the current (field) name.
public JsonParser
overrideFormatFeatures(int
Bit mask of set/clear state for features to change
values
,
int
Bit mask of features to change
mask
)

Overrides com.fasterxml.jackson.core.JsonParser.overrideFormatFeatures.

Bulk set method for (re)setting states of FormatFeatures, by specifying values (set / clear) along with a mask, to determine which features to change, if any.
public boolean

Returns:

True since XML format does require support from codec
requiresCustomCodec
()

Overrides com.fasterxml.jackson.core.JsonParser.requiresCustomCodec.

XML format does require support from custom ObjectCodec (that is, XmlMapper), so need to return true here.
public void
setCodec(ObjectCodec
Codec to assign, if any; null if none
c
)

Implements abstract com.fasterxml.jackson.core.JsonParser.setCodec.

Setter that allows defining ObjectCodec associated with this parser, if any.
public void
public StreamReadConstraints
streamReadConstraints()

Overrides com.fasterxml.jackson.core.JsonParser.streamReadConstraints.

Get the constraints to apply when performing streaming reads.
public Version
version()

Implements abstract com.fasterxml.jackson.core.JsonParser.version.

Implements com.fasterxml.jackson.core.Versioned.version.

Accessor for getting version of the core package, given a parser instance.
Inherited from com.fasterxml.jackson.core.base.ParserMinimalBase:
_ascii_asciiBytes_constructError_decodeBase64_getCharDesc_hasTextualNull_longIntegerDesc_longNumberDesc_reportError_reportError_reportError_reportInputCoercion_reportInvalidEOF_reportInvalidEOF_reportInvalidEOF_reportInvalidEOFInValue_reportInvalidEOFInValue_reportMissingRootWS_reportUnexpectedChar_reportUnexpectedNumberChar_throwInternal_throwInvalidSpace_wrapErrorclearCurrentTokencurrentTokencurrentTokenIdgetCurrentTokengetCurrentTokenIdgetLastClearedTokengetValueAsBooleangetValueAsDoublegetValueAsIntgetValueAsIntgetValueAsLonggetValueAsLonggetValueAsStringgetValueAsStringhasCurrentTokenhasTokenhasTokenIdisExpectedStartObjectTokennextValuereportInvalidNumberreportOverflowIntreportOverflowIntreportOverflowIntreportOverflowLongreportOverflowLongreportOverflowLongreportUnexpectedNumberCharskipChildren