Top Description Fields Constructors Methods
tools.jackson.dataformat.xml.deser

public Class FromXmlParser

extends ParserMinimalBase
implements ElementWrappable
Class Inheritance
All Implemented Interfaces
tools.jackson.dataformat.xml.deser.ElementWrappable
Imports
java.io.IOException, .Writer, java.math.BigDecimal, .BigInteger, java.util.Objects, .Set, javax.xml.stream.XMLStreamException, .XMLStreamReader, .XMLStreamWriter, org.codehaus.stax2.XMLStreamReader2, tools.jackson.core.*, tools.jackson.core.base.ParserMinimalBase, tools.jackson.core.exc.StreamReadException, tools.jackson.core.io.IOContext, .NumberInput, tools.jackson.core.util.ByteArrayBuilder, .JacksonFeatureSet, tools.jackson.dataformat.xml.util.CaseInsensitiveNameSet, .StaxUtil, tools.jackson.dataformat.xml.PackageVersion, .XmlNameProcessor, .XmlReadFeature

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

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 final 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 String
protected final int
_formatFeatures

Bit flag composed of bits that indicate which XmlReadFeatures are enabled.

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

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

protected XmlReadContext
_streamReadContext

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

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 capability system.

Inherited from tools.jackson.core.base.ParserMinimalBase:
_closed_currToken_ioContext_lastClearedToken_objectReadContext_streamReadConstraints_streamReadFeatures_tokenCount_trackMaxTokenCountBD_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_RSINT_SLASHINT_SPACEINT_TABMAX_BYTE_IMAX_INT_DMAX_INT_LMAX_LONG_DMAX_SHORT_IMIN_BYTE_IMIN_INT_DMIN_INT_LMIN_LONG_DMIN_SHORT_INO_BYTESNO_INTSNR_BIGDECIMALNR_BIGINTNR_DOUBLENR_FLOATNR_INTNR_LONGNR_UNKNOWNSTREAM_READ_FEATURE_DEFAULTS

Constructor Summary

AccessConstructor and Description
public
FromXmlParser(ObjectReadContext readCtxt, IOContext ioCtxt, int parserFeatures, int xmlFeatures, XMLStreamReader xmlReader, XmlNameProcessor nameProcessor, String nameForTextElement)

public
FromXmlParser(ObjectReadContext readCtxt, IOContext ioCtxt, int parserFeatures, int xmlFeatures, XMLStreamReader xmlReader, XmlTokenStream tokenStream, XmlNameProcessor nameProcessor, String nameForTextElement)

Method Summary

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

protected void
_closeInput()

Implements abstract tools.jackson.core.base.ParserMinimalBase._closeInput.

Abstract method for sub-classes to implement; to be called by close() implementation here.

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

Implements abstract tools.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()

Implements abstract tools.jackson.core.base.ParserMinimalBase._releaseBuffers.

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

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

Implements tools.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 void
assignCurrentValue(Object v)

Implements abstract tools.jackson.core.JsonParser.assignCurrentValue.

Helper method, usually equivalent to: getParsingContext().assignCurrentValue(v);

public boolean
canReadObjectId()

Overrides tools.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 tools.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 TokenStreamLocation
currentLocation()

Implements abstract tools.jackson.core.JsonParser.currentLocation.

Method that returns location of the last processed character; usually for error reporting purposes

public String
currentName()

Implements abstract tools.jackson.core.JsonParser.currentName.

Method that can be called to get the name associated with the current event.

public TokenStreamLocation
currentTokenLocation()

Implements abstract tools.jackson.core.JsonParser.currentTokenLocation.

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 Object
currentValue()

Implements abstract tools.jackson.core.JsonParser.currentValue.

Helper method, usually equivalent to: getParsingContext().currentValue();

Note that "current value" is NOT populated (or used) by Streaming parser; it is only used by higher-level data-binding functionality.

public BigInteger
getBigIntegerValue()

Implements abstract tools.jackson.core.JsonParser.getBigIntegerValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_INT and it cannot be used as a Java long primitive type due to its magnitude.

public byte[]
getBinaryValue(Base64Variant b64variant)

Implements abstract tools.jackson.core.JsonParser.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 BigDecimal
getDecimalValue()

Implements abstract tools.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 tools.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 tools.jackson.core.base.ParserMinimalBase.getEmbeddedObject.

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

public float
getFloatValue()

Implements abstract tools.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
getIntValue()

Implements abstract tools.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 tools.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 tools.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 tools.jackson.core.JsonParser.getNumberValue.

Generic number value accessor method that will work for all kinds of numeric values.

public XMLStreamReader
getStaxReader()

Method that allows application direct access to underlying Stax XMLStreamWriter.

public String
getString()

Implements abstract tools.jackson.core.JsonParser.getString.

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
getString(Writer writer)

Overrides tools.jackson.core.base.ParserMinimalBase.getString.

Method to read the textual representation of the current token in chunks and pass it to the given Writer.

public char[]
getStringCharacters()

Implements abstract tools.jackson.core.JsonParser.getStringCharacters.

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

public int
getStringLength()

Implements abstract tools.jackson.core.JsonParser.getStringLength.

Accessor used with getStringCharacters, to know length of String stored in returned buffer.

public int
getStringOffset()

Implements abstract tools.jackson.core.JsonParser.getStringOffset.

Accessor used with getStringCharacters, to know offset of the first text content character within buffer.

public boolean
hasStringCharacters()

Implements abstract tools.jackson.core.JsonParser.hasStringCharacters.

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

public final boolean
public boolean
isExpectedNumberIntToken()

Overrides tools.jackson.core.base.ParserMinimalBase.isExpectedNumberIntToken.

Since xml representation cannot 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 tools.jackson.core.base.ParserMinimalBase.isExpectedStartArrayToken.

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

public boolean
isNaN()

Implements abstract tools.jackson.core.JsonParser.isNaN.

Accessor for checking whether current token is a special "not-a-number" (NaN) token (including both "NaN" AND positive/negative infinity!).

public String
nextStringValue()

Overrides tools.jackson.core.JsonParser.nextStringValue.

Method overridden to support more reliable deserialization of String collections.

public JsonToken
nextToken()

Implements abstract tools.jackson.core.JsonParser.nextToken.

Main iteration method, which will advance stream enough to determine type of the next token, if any.

public JacksonFeatureSet<StreamReadCapability>
streamReadCapabilities()

Overrides tools.jackson.core.base.ParserMinimalBase.streamReadCapabilities.

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

public TokenStreamContext
streamReadContext()

Implements abstract tools.jackson.core.JsonParser.streamReadContext.

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 XMLStreamReader2
streamReadInputSource()

Implements abstract tools.jackson.core.JsonParser.streamReadInputSource.

Method that can be used to get access to object that is used to access input being parsed; this is usually either InputStream or Reader, depending on what parser was constructed with.

public Version
version()

Implements abstract tools.jackson.core.JsonParser.version.

Implements tools.jackson.core.Versioned.version.

Accessor for getting version of the core package, given a parser instance.

Inherited from tools.jackson.core.base.ParserMinimalBase:
_constructInputCoercion_constructNotNumericType_currentLocationMinusOne_decodeBase64_getCharDesc_hasTextualNull_longIntegerDesc_longNumberDesc_nullSafeUpdateToken_reportBadInputStream_reportBadReader_reportError_reportError_reportError_reportError_reportInvalidEOF_reportInvalidEOF_reportInvalidEOFInValue_reportInvalidNumber_reportInvalidSpace_reportMissingRootWS_reportOverflowByte_reportOverflowInt_reportOverflowInt_reportOverflowInt_reportOverflowLong_reportOverflowLong_reportOverflowLong_reportOverflowShort_reportUnexpectedChar_reportUnexpectedNumberChar_throwInternal_updateToken_updateTokenToNA_updateTokenToNull_wrapIOFailureclearCurrentTokenclosecurrentNameMatchcurrentTokencurrentTokenCountcurrentTokenIdfinishTokengetBooleanValuegetByteValuegetLastClearedTokengetNumberTypeFPgetNumberValueDeferredgetNumberValueExactgetShortValuegetValueAsBooleangetValueAsDoublegetValueAsIntgetValueAsIntgetValueAsLonggetValueAsLonggetValueAsStringgetValueAsStringhasCurrentTokenhasTokenhasTokenIdisClosedisEnabledisExpectedStartObjectTokennextNamenextNamenextNameMatchnextValueobjectReadContextreadValueAsreadValueAsreadValueAsreadValueAsTreeskipChildrenstreamReadConstraintsstreamReadFeatures

Field Detail

_binaryValueback to summary
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.

_byteArrayBuilderback to summary
protected ByteArrayBuilder _byteArrayBuilder

ByteArrayBuilder is needed if 'getBinaryValue' is called. If so, we better reuse it for remainder of content.

_cfgNameForTextElementback to summary
protected final 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.

Name used for pseudo-property used for returning XML Text value (which does not have actual element name to use). Defaults to empty String, but may be changed for inter-operability reasons: JAXB, for example, uses "value" as name.

_currTextback to summary
protected String _currText
_formatFeaturesback to summary
protected final int _formatFeatures

Bit flag composed of bits that indicate which XmlReadFeatures are enabled.

_mayBeLeafback to summary
protected boolean _mayBeLeaf

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

_nextIsLeadingMixedback to summary
protected boolean _nextIsLeadingMixed

Additional flag that is strictly needed when exposing "mixed" leading String value as "anonymous" property/string pair. If so, code returns START_OBJECT first, sets _nextToken to be FIELD_NAME and sets this flag to indicate use of "anonymous" marker.

_nextTokenback to summary
protected JsonToken _nextToken
_numberBigIntback to summary
protected BigInteger _numberBigInt
_numberIntback to summary
protected int _numberInt
_numberLongback to summary
protected long _numberLong
_numTypesValidback to summary
protected int _numTypesValid

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

_streamReadContextback to summary
protected XmlReadContext _streamReadContext

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

_xmlTokensback to summary
protected final XmlTokenStream _xmlTokens
DEFAULT_UNNAMED_TEXT_PROPERTYback to summary
public static final String DEFAULT_UNNAMED_TEXT_PROPERTY

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

XML_READ_CAPABILITIESback to summary
protected static final JacksonFeatureSet<StreamReadCapability> XML_READ_CAPABILITIES

XML format has some peculiarities, indicated via capability system.

Constructor Detail

FromXmlParserback to summary
public FromXmlParser(ObjectReadContext readCtxt, IOContext ioCtxt, int parserFeatures, int xmlFeatures, XMLStreamReader xmlReader, XmlNameProcessor nameProcessor, String nameForTextElement)
FromXmlParserback to summary
public FromXmlParser(ObjectReadContext readCtxt, IOContext ioCtxt, int parserFeatures, int xmlFeatures, XMLStreamReader xmlReader, XmlTokenStream tokenStream, XmlNameProcessor nameProcessor, String nameForTextElement)

Method Detail

_checkNumericValueback to summary
protected final void _checkNumericValue(int expType) throws JacksonException
_closeInputback to summary
protected void _closeInput() throws IOException

Implements abstract tools.jackson.core.base.ParserMinimalBase._closeInput.

Doc from tools.jackson.core.base.ParserMinimalBase._closeInput.

Abstract method for sub-classes to implement; to be called by close() implementation here.

Annotations
@Override
Exceptions
IOException:
from underlying input source if thrown
_convertNumberToBigDecimalback to summary
protected BigDecimal _convertNumberToBigDecimal() throws JacksonException
_convertNumberToBigIntegerback to summary
protected void _convertNumberToBigInteger() throws JacksonException
_convertNumberToDoubleback to summary
protected double _convertNumberToDouble() throws JacksonException
_convertNumberToFloatback to summary
protected float _convertNumberToFloat() throws JacksonException
_convertNumberToIntback to summary
protected void _convertNumberToInt() throws JacksonException
_convertNumberToLongback to summary
protected void _convertNumberToLong() throws JacksonException
_decodeBase64back to summary
protected byte[] _decodeBase64(Base64Variant b64variant) throws JacksonException
Annotations
@SuppressWarnings:resource
_getByteArrayBuilderback to summary
protected ByteArrayBuilder _getByteArrayBuilder()
_handleEOFback to summary
protected void _handleEOF() throws StreamReadException

Implements abstract tools.jackson.core.base.ParserMinimalBase._handleEOF.

Method called when an EOF is encountered between tokens. If so, it may be a legitimate EOF, but only iff there is no open non-root context.

Annotations
@Override
_internalErrorUnknownTokenback to summary
private <T> T _internalErrorUnknownToken(Object token)
_isIntNumberback to summary
protected final int _isIntNumber(String text)
_nextTokenback to summary
protected int _nextToken() throws JacksonException
_releaseBuffersback to summary
protected void _releaseBuffers()

Implements abstract tools.jackson.core.base.ParserMinimalBase._releaseBuffers.

Doc from tools.jackson.core.base.ParserMinimalBase._releaseBuffers.

Method called to release internal buffers owned by the base reader. This is expected to be called after _closeInput since the buffers are expected not to be needed any longer.

Annotations
@Override
_skipEndElementback to summary
protected void _skipEndElement() throws JacksonException
_updateStateback to summary
private void _updateState(JsonToken t)
addVirtualWrappingback to summary
public void addVirtualWrapping(Set<String> namesToWrap0, boolean caseInsensitive)

Implements tools.jackson.dataformat.xml.deser.ElementWrappable.addVirtualWrapping.

Doc from tools.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. This is needed for supporting handling of so-called "unwrapped" array types, something XML mappings like JAXB often use.

Annotations
@Override
assignCurrentValueback to summary
public void assignCurrentValue(Object v)

Implements abstract tools.jackson.core.JsonParser.assignCurrentValue.

Doc from tools.jackson.core.JsonParser.assignCurrentValue.

Helper method, usually equivalent to: getParsingContext().assignCurrentValue(v);

Annotations
@Override
canReadObjectIdback to summary
public boolean canReadObjectId()

Overrides tools.jackson.core.JsonParser.canReadObjectId.

Doc from tools.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).

Default implementation returns true; overridden by data formats that do support native Object Ids. Caller is expected to either use a non-native notation (explicit property or such), or fail, in case it cannot use native object ids.

Annotations
@Override
canReadTypeIdback to summary
public boolean canReadTypeId()

Overrides tools.jackson.core.JsonParser.canReadTypeId.

Doc from tools.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).

Default implementation returns true; overridden by data formats that do support native Type Ids. Caller is expected to either use a non-native notation (explicit property or such), or fail, in case it cannot use native type ids.

Annotations
@Override
currentLocationback to summary
public TokenStreamLocation currentLocation()

Implements abstract tools.jackson.core.JsonParser.currentLocation.

Method that returns location of the last processed character; usually for error reporting purposes

Annotations
@Override
currentNameback to summary
public String currentName()

Implements abstract tools.jackson.core.JsonParser.currentName.

Method that can be called to get the name associated with the current event.

Annotations
@Override
currentTokenLocationback to summary
public TokenStreamLocation currentTokenLocation()

Implements abstract tools.jackson.core.JsonParser.currentTokenLocation.

Method that return the starting location of the current token; that is, position of the first character from input that starts the current token.

Annotations
@Override
currentValueback to summary
public Object currentValue()

Implements abstract tools.jackson.core.JsonParser.currentValue.

Doc from tools.jackson.core.JsonParser.currentValue.

Helper method, usually equivalent to: getParsingContext().currentValue();

Note that "current value" is NOT populated (or used) by Streaming parser; it is only used by higher-level data-binding functionality. The reason it is included here is that it can be stored and accessed hierarchically, and gets passed through data-binding.

Annotations
@Override
getBigIntegerValueback to summary
public BigInteger getBigIntegerValue() throws JacksonException

Implements abstract tools.jackson.core.JsonParser.getBigIntegerValue.

Doc from tools.jackson.core.JsonParser.getBigIntegerValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_INT and it cannot be used as a Java long primitive type due to its magnitude. It can also be called for JsonToken#VALUE_NUMBER_FLOAT; if so, it is equivalent to calling getDecimalValue and then constructing a BigInteger from that value.

Annotations
@Override
getBinaryValueback to summary
public byte[] getBinaryValue(Base64Variant b64variant) throws JacksonException

Implements abstract tools.jackson.core.JsonParser.getBinaryValue.

Doc from tools.jackson.core.JsonParser.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. It works similar to getting String value via getString() and decoding result (except for decoding part), but should be significantly more performant.

Note that non-decoded textual contents of the current token are not guaranteed to be accessible after this method is called. Current implementation, for example, clears up textual content during decoding. Decoded binary content, however, will be retained until parser is advanced to the next event.

Annotations
@Override
getDecimalValueback to summary
public BigDecimal getDecimalValue() throws JacksonException

Implements abstract tools.jackson.core.JsonParser.getDecimalValue.

Doc from tools.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. No under/overflow exceptions are ever thrown.

Annotations
@Override
getDoubleValueback to summary
public double getDoubleValue() throws JacksonException

Implements abstract tools.jackson.core.JsonParser.getDoubleValue.

Doc from tools.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. It can also be called for JsonToken#VALUE_NUMBER_INT; if so, it is equivalent to calling getLongValue and then casting; except for possible overflow/underflow exception.

Note

if the value falls outside of range of Java double, a InputCoercionException will be thrown to indicate numeric overflow/underflow.

Annotations
@Override
getEmbeddedObjectback to summary
public Object getEmbeddedObject() throws JacksonException

Overrides tools.jackson.core.base.ParserMinimalBase.getEmbeddedObject.

Doc from tools.jackson.core.JsonParser.getEmbeddedObject.

Accessor that can be called if (and only if) the current token is JsonToken#VALUE_EMBEDDED_OBJECT. For other token types, null is returned.

Note

only some specialized parser implementations support embedding of objects (usually ones that are facades on top of non-streaming sources, such as object trees). One exception is access to binary content (whether via base64 encoding or not) which typically is accessible using this method, as well as getBinaryValue().

Annotations
@Override
getFloatValueback to summary
public float getFloatValue() throws JacksonException

Implements abstract tools.jackson.core.JsonParser.getFloatValue.

Doc from tools.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. It can also be called for JsonToken#VALUE_NUMBER_INT; if so, it is equivalent to calling getLongValue and then casting; except for possible overflow/underflow exception.

Note

if the value falls outside of range of Java float, a InputCoercionException will be thrown to indicate numeric overflow/underflow.

Annotations
@Override
getIntValueback to summary
public int getIntValue() throws JacksonException

Implements abstract tools.jackson.core.JsonParser.getIntValue.

Doc from tools.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. It can also be called for JsonToken#VALUE_NUMBER_FLOAT; if so, it is equivalent to calling getDoubleValue and then casting; except for possible overflow/underflow exception.

Note

if the resulting integer value falls outside range of Java int, a InputCoercionException may be thrown to indicate numeric overflow/underflow.

Annotations
@Override
getLongValueback to summary
public long getLongValue() throws JacksonException

Implements abstract tools.jackson.core.JsonParser.getLongValue.

Doc from tools.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. It can also be called for JsonToken#VALUE_NUMBER_FLOAT; if so, it is equivalent to calling getDoubleValue and then casting to int; except for possible overflow/underflow exception.

Note

if the token is an integer, but its value falls outside of range of Java long, a InputCoercionException may be thrown to indicate numeric overflow/underflow.

Annotations
@Override
getNumberTypeback to summary
public JsonParser.NumberType getNumberType()

Implements abstract tools.jackson.core.JsonParser.getNumberType.

Doc from tools.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.

Note

in Jackson 2.x, an exception was wrong if called for non-numeric token.

Annotations
@Override
getNumberValueback to summary
public Number getNumberValue() throws JacksonException

Implements abstract tools.jackson.core.JsonParser.getNumberValue.

Doc from tools.jackson.core.JsonParser.getNumberValue.

Generic number value accessor method that will work for all kinds of numeric values. It will return the optimal (simplest/smallest possible) wrapper object that can express the numeric value just parsed.

Annotations
@Override
getStaxReaderback to summary
public XMLStreamReader getStaxReader()

Method that allows application direct access to underlying Stax XMLStreamWriter. Note that use of writer is discouraged, and may interfere with processing of this writer; however, occasionally it may be necessary.

Note

writer instance will always be of type org.codehaus.stax2.XMLStreamWriter2 (including Typed Access API) so upcasts are safe.

getStringback to summary
public String getString() throws JacksonException

Implements abstract tools.jackson.core.JsonParser.getString.

Doc from tools.jackson.core.JsonParser.getString.

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. Method can be called for any token type.

Annotations
@Override
getStringback to summary
public int getString(Writer writer) throws JacksonException

Overrides tools.jackson.core.base.ParserMinimalBase.getString.

Doc from tools.jackson.core.JsonParser.getString.

Method to read the textual representation of the current token in chunks and pass it to the given Writer. Functionally same as calling:

  writer.write(parser.getString());
but should typically be more efficient as longer content does need to be combined into a single String to return, and write can occur directly from intermediate buffers Jackson uses.

Note

String value will still be buffered (usually using TextBuffer) and will be accessible with other getString() calls (that is, it will not be consumed). So this accessor only avoids construction of java.lang.String compared to plain getString() method.

Note

In Jackson 2.x this method was called getString(Writer).

Annotations
@Override
getStringCharactersback to summary
public char[] getStringCharacters() throws JacksonException

Implements abstract tools.jackson.core.JsonParser.getStringCharacters.

Doc from tools.jackson.core.JsonParser.getStringCharacters.

Method similar to getString(), but that will return underlying (unmodifiable) character array that contains textual value, instead of constructing a String object to contain this information. Note, however, that:

  • String contents are not guaranteed to start at index 0 (rather, call getStringOffset) to know the actual offset
  • Length of string contents may be less than the length of returned buffer: call getStringLength for actual length of returned content.

Note that caller MUST NOT modify the returned character array in any way -- doing so may corrupt current parser state and render parser instance useless.

The only reason to call this method (over getString()) is to avoid construction of a String object (which will make a copy of contents).

Annotations
@Override
getStringLengthback to summary
public int getStringLength() throws JacksonException

Implements abstract tools.jackson.core.JsonParser.getStringLength.

Doc from tools.jackson.core.JsonParser.getStringLength.

Accessor used with getStringCharacters, to know length of String stored in returned buffer.

Annotations
@Override
getStringOffsetback to summary
public int getStringOffset() throws JacksonException

Implements abstract tools.jackson.core.JsonParser.getStringOffset.

Doc from tools.jackson.core.JsonParser.getStringOffset.

Accessor used with getStringCharacters, to know offset of the first text content character within buffer.

Annotations
@Override
hasStringCharactersback to summary
public boolean hasStringCharacters()

Implements abstract tools.jackson.core.JsonParser.hasStringCharacters.

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

Annotations
@Override
isEnabledback to summary
public final boolean isEnabled(XmlReadFeature f)
isExpectedNumberIntTokenback to summary
public boolean isExpectedNumberIntToken()

Overrides tools.jackson.core.base.ParserMinimalBase.isExpectedNumberIntToken.

Since xml representation cannot 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. The main benefit is avoiding checks for coercion.

Annotations
@Override
isExpectedStartArrayTokenback to summary
public boolean isExpectedStartArrayToken()

Overrides tools.jackson.core.base.ParserMinimalBase.isExpectedStartArrayToken.

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

Annotations
@Override
isNaNback to summary
public boolean isNaN()

Implements abstract tools.jackson.core.JsonParser.isNaN.

Doc from tools.jackson.core.JsonParser.isNaN.

Accessor for checking whether current token is a special "not-a-number" (NaN) token (including both "NaN" AND positive/negative infinity!). These values are not supported by all formats: JSON, for example, only supports them if JsonReadFeature#ALLOW_NON_NUMERIC_NUMBERS is enabled.

Note

in case where numeric value is outside range of requested type -- most notably java.lang.Float or java.lang.Double -- and decoding results effectively in a NaN value, this method DOES NOT return true: only explicit incoming markers do. This is because value could still be accessed as a valid BigDecimal.

Annotations
@Override
nextStringValueback to summary
public String nextStringValue() throws JacksonException

Overrides tools.jackson.core.JsonParser.nextStringValue.

Method overridden to support more reliable deserialization of String collections.

Annotations
@Override
nextTokenback to summary
public JsonToken nextToken() throws JacksonException

Implements abstract tools.jackson.core.JsonParser.nextToken.

Doc from tools.jackson.core.JsonParser.nextToken.

Main iteration method, which will advance stream enough to determine type of the next token, if any. If none remaining (stream has no content other than possible white space before ending), null will be returned.

Annotations
@Override
Exceptions
JacksonException:
for low-level read issues
streamReadCapabilitiesback to summary
public JacksonFeatureSet<StreamReadCapability> streamReadCapabilities()

Overrides tools.jackson.core.base.ParserMinimalBase.streamReadCapabilities.

Doc from tools.jackson.core.JsonParser.streamReadCapabilities.

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

Annotations
@Override
streamReadContextback to summary
public TokenStreamContext streamReadContext()

Implements abstract tools.jackson.core.JsonParser.streamReadContext.

Doc from tools.jackson.core.JsonParser.streamReadContext.

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. Contexts are hierarchically nested, and can be used for example for figuring out part of the input document that correspond to specific array or object (for highlighting purposes, or error reporting). Contexts can also be used for simple xpath-like matching of input, if so desired.

Note

method was called getParsingContext() in Jackson 2.x

Annotations
@Override
streamReadInputSourceback to summary
public XMLStreamReader2 streamReadInputSource()

Implements abstract tools.jackson.core.JsonParser.streamReadInputSource.

Doc from tools.jackson.core.JsonParser.streamReadInputSource.

Method that can be used to get access to object that is used to access input being parsed; this is usually either InputStream or Reader, depending on what parser was constructed with. Note that returned value may be null in some cases; including case where parser implementation does not want to exposed raw source to caller. In cases where input has been decorated, object returned here is the decorated version; this allows some level of interaction between users of parser and decorator object.

In general use of this accessor should be considered as "last effort", i.e. only used if no other mechanism is applicable.

Note

was named getInputSource() in Jackson 2.x.

Annotations
@Override
versionback to summary
public Version version()

Implements abstract tools.jackson.core.JsonParser.version.

Implements tools.jackson.core.Versioned.version.

Doc from tools.jackson.core.JsonParser.version.

Accessor for getting version of the core package, given a parser instance. Left for sub-classes to implement.

Annotations
@Override