Top Description Fields Constructors Methods
tools.jackson.databind.node

public Class TreeTraversingParser

extends ParserMinimalBase
Class Inheritance
Imports
java.io.IOException, .OutputStream, java.math.BigDecimal, .BigInteger, tools.jackson.core.*, tools.jackson.core.base.ParserMinimalBase, tools.jackson.core.exc.InputCoercionException, tools.jackson.core.util.JacksonFeatureSet, tools.jackson.databind.JsonNode

Facade over JsonNode that implements JsonParser to allow accessing contents of JSON tree in alternate form (stream of tokens). Useful when a streaming source is expected by code, such as data binding functionality.

Field Summary

Modifier and TypeField and Description
protected boolean
_closed

Hides tools.jackson.core.base.ParserMinimalBase._closed.

Flag that indicates whether parser is closed or not.
protected NodeCursor
_nodeCursor

Traversal context within tree

protected final JsonNode
Inherited from tools.jackson.core.base.ParserMinimalBase:
_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
public

Method Summary

Modifier and TypeMethod and Description
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 void
_handleEOF()

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

Method sub-classes need to implement to check whether end-of-content is allowed at the current decoding position: formats often want to verify the all start/end token pairs match, for example.

protected void
_releaseBuffers()

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

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

public void
assignCurrentValue(Object v)

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

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

public void
close()

Overrides tools.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 StreamReadFeature#AUTO_CLOSE_SOURCE is enabled.

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 token: for JsonToken#PROPERTY_NAMEs it will be the same as what getString() returns; for Object property values it will be the preceding property name; and for others (array element, root-level values) null.

protected JsonNode
protected JsonNode
currentNumericNode(int targetNumType)

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 JsonParser.NumberTypeFP
getNumberTypeFP()

Overrides tools.jackson.core.base.ParserMinimalBase.getNumberTypeFP.

If current token is of type JsonToken#VALUE_NUMBER_FLOAT, returns one of NumberTypeFP constants; otherwise returns NumberTypeFP#UNKNOWN.

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 short
getShortValue()

Overrides tools.jackson.core.base.ParserMinimalBase.getShortValue.

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 short primitive type.

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 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 int
getValueAsInt()

Overrides tools.jackson.core.base.ParserMinimalBase.getValueAsInt.

Method that will try to convert value of current token to a Java int value.

public int
getValueAsInt(int defaultValue)

Overrides tools.jackson.core.base.ParserMinimalBase.getValueAsInt.

Method that will try to convert value of current token to a int.

public long
getValueAsLong()

Overrides tools.jackson.core.base.ParserMinimalBase.getValueAsLong.

Method that will try to convert value of current token to a long.

public long
getValueAsLong(long defaultValue)

Overrides tools.jackson.core.base.ParserMinimalBase.getValueAsLong.

Method that will try to convert value of current token to a long.

public boolean
hasStringCharacters()

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

Method that can be used to determine whether calling of getStringCharacters would be the most efficient way to access String value for the event parser currently points to (compared to getString()).

public boolean
isClosed()

Overrides tools.jackson.core.base.ParserMinimalBase.isClosed.

Method that can be called to determine whether this parser is closed or not.

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 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 int
readBinaryValue(Base64Variant b64variant, OutputStream out)

Overrides tools.jackson.core.JsonParser.readBinaryValue.

Similar to readBinaryValue(OutputStream) but allows explicitly specifying base64 variant to use.

public JsonParser
skipChildren()

Overrides tools.jackson.core.base.ParserMinimalBase.skipChildren.

Method that will skip all child tokens of an array or object token that the parser currently points to, iff stream points to JsonToken#START_OBJECT or JsonToken#START_ARRAY.

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 JsonNode
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_wrapIOFailureclearCurrentTokencurrentNameMatchcurrentTokencurrentTokenCountcurrentTokenIdfinishTokengetBooleanValuegetByteValuegetLastClearedTokengetNumberValueDeferredgetNumberValueExactgetStringgetValueAsBooleangetValueAsDoublegetValueAsStringgetValueAsStringhasCurrentTokenhasTokenhasTokenIdisEnabledisExpectedNumberIntTokenisExpectedStartArrayTokenisExpectedStartObjectTokennextNamenextNamenextNameMatchnextValueobjectReadContextreadValueAsreadValueAsreadValueAsreadValueAsTreestreamReadConstraintsstreamReadFeatures

Field Detail

_closedback to summary
protected boolean _closed

Hides tools.jackson.core.base.ParserMinimalBase._closed.

Flag that indicates whether parser is closed or not. Gets set when parser is either closed by explicit call (close) or when end-of-input is reached.

_nodeCursorback to summary
protected NodeCursor _nodeCursor

Traversal context within tree

_sourceback to summary
protected final JsonNode _source
Since
3.0

Constructor Detail

TreeTraversingParserback to summary
public TreeTraversingParser(JsonNode n)
TreeTraversingParserback to summary
public TreeTraversingParser(JsonNode n, ObjectReadContext readContext)

Method Detail

_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
_handleEOFback to summary
protected void _handleEOF()

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

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

Method sub-classes need to implement to check whether end-of-content is allowed at the current decoding position: formats often want to verify the all start/end token pairs match, for example.

Annotations
@Override
_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
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
closeback to summary
public void close()

Overrides tools.jackson.core.base.ParserMinimalBase.close.

Implements java.io.Closeable.close.

Doc from tools.jackson.core.JsonParser.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 StreamReadFeature#AUTO_CLOSE_SOURCE is enabled. Whether parser owns the input source depends on factory method that was used to construct instance (so check tools.jackson.core.json.JsonFactory for details, but the general idea is that if caller passes in closable resource (such as InputStream or Reader) parser does NOT own the source; but if it passes a reference (such as java.io.File or java.net.URL and creates stream or reader it does own them.

Annotations
@Override
currentLocationback to summary
public TokenStreamLocation currentLocation()

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

Doc from tools.jackson.core.JsonParser.currentLocation.

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

Note that the location is not guaranteed to be accurate (although most implementation will try their best): some implementations may only report specific boundary locations (start or end locations of tokens) and others only return TokenStreamLocation#NA due to not having access to input location information (when delegating actual decoding work to other library).

Annotations
@Override
currentNameback to summary
public String currentName()

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

Doc from tools.jackson.core.JsonParser.currentName.

Method that can be called to get the name associated with the current token: for JsonToken#PROPERTY_NAMEs it will be the same as what getString() returns; for Object property values it will be the preceding property name; and for others (array element, root-level values) null.

Annotations
@Override
currentNodeback to summary
protected JsonNode currentNode()
currentNumericNodeback to summary
protected JsonNode currentNumericNode(int targetNumType)
currentTokenLocationback to summary
public TokenStreamLocation currentTokenLocation()

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

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

Note that the location is not guaranteed to be accurate (although most implementation will try their best): some implementations may only return TokenStreamLocation#NA due to not having access to input location information (when delegating actual decoding work to other library).

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 InputCoercionException

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
Exceptions
InputCoercionException:
If either token type is not a number
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 InputCoercionException

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
Exceptions
InputCoercionException:
If either token type is not a number
getDoubleValueback to summary
public double getDoubleValue() throws InputCoercionException

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
Exceptions
InputCoercionException:
If either token type is not a number OR numeric value exceeds allowed range
getEmbeddedObjectback to summary
public Object getEmbeddedObject()

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 InputCoercionException

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
Exceptions
InputCoercionException:
If either token type is not a number OR numeric value exceeds allowed range
getIntValueback to summary
public int getIntValue() throws InputCoercionException

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
Exceptions
InputCoercionException:
If either token type is not a number OR numeric value exceeds allowed range
getLongValueback to summary
public long getLongValue() throws InputCoercionException

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
Exceptions
InputCoercionException:
If either token type is not a number OR numeric value exceeds allowed range
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
getNumberTypeFPback to summary
public JsonParser.NumberTypeFP getNumberTypeFP()

Overrides tools.jackson.core.base.ParserMinimalBase.getNumberTypeFP.

Doc from tools.jackson.core.JsonParser.getNumberTypeFP.

If current token is of type JsonToken#VALUE_NUMBER_FLOAT, returns one of NumberTypeFP constants; otherwise returns NumberTypeFP#UNKNOWN.

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

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
Exceptions
InputCoercionException:
If the current token is not of numeric type
getShortValueback to summary
public short getShortValue() throws InputCoercionException

Overrides tools.jackson.core.base.ParserMinimalBase.getShortValue.

Doc from tools.jackson.core.JsonParser.getShortValue.

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 short 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 short, a InputCoercionException will be thrown to indicate numeric overflow/underflow.

Annotations
@Override
Exceptions
InputCoercionException:
If either token type is not a number OR numeric value exceeds allowed range
getStringback to summary
public String getString()

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
getStringCharactersback to summary
public char[] getStringCharacters()

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

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

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
getValueAsIntback to summary
public int getValueAsInt()

Overrides tools.jackson.core.base.ParserMinimalBase.getValueAsInt.

Doc from tools.jackson.core.JsonParser.getValueAsInt.

Method that will try to convert value of current token to a Java int value. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.

If representation cannot be converted to an int (including structured type markers like start/end Object/Array) default value of 0 will be returned; no exceptions are thrown.

Annotations
@Override
getValueAsIntback to summary
public int getValueAsInt(int defaultValue)

Overrides tools.jackson.core.base.ParserMinimalBase.getValueAsInt.

Doc from tools.jackson.core.JsonParser.getValueAsInt.

Method that will try to convert value of current token to a int. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.

If representation cannot be converted to an int (including structured type markers like start/end Object/Array) specified def will be returned; no exceptions are thrown.

Annotations
@Override
getValueAsLongback to summary
public long getValueAsLong()

Overrides tools.jackson.core.base.ParserMinimalBase.getValueAsLong.

Doc from tools.jackson.core.JsonParser.getValueAsLong.

Method that will try to convert value of current token to a long. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.

If representation cannot be converted to a long (including structured type markers like start/end Object/Array) default value of 0L will be returned; no exceptions are thrown.

Annotations
@Override
getValueAsLongback to summary
public long getValueAsLong(long defaultValue)

Overrides tools.jackson.core.base.ParserMinimalBase.getValueAsLong.

Doc from tools.jackson.core.JsonParser.getValueAsLong.

Method that will try to convert value of current token to a long. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.

If representation cannot be converted to a long (including structured type markers like start/end Object/Array) specified def will be returned; no exceptions are thrown.

Annotations
@Override
hasStringCharactersback to summary
public boolean hasStringCharacters()

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

Doc from tools.jackson.core.JsonParser.hasStringCharacters.

Method that can be used to determine whether calling of getStringCharacters would be the most efficient way to access String value for the event parser currently points to (compared to getString()).

Annotations
@Override
isClosedback to summary
public boolean isClosed()

Overrides tools.jackson.core.base.ParserMinimalBase.isClosed.

Doc from tools.jackson.core.JsonParser.isClosed.

Method that can be called to determine whether this parser is closed or not. If it is closed, no new tokens can be retrieved by calling nextToken (and the underlying stream may be closed). Closing may be due to an explicit call to close or because parser has encountered end of input.

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
nextTokenback to summary
public JsonToken nextToken()

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
readBinaryValueback to summary
public int readBinaryValue(Base64Variant b64variant, OutputStream out) throws JacksonException

Overrides tools.jackson.core.JsonParser.readBinaryValue.

Doc from tools.jackson.core.JsonParser.readBinaryValue.

Similar to readBinaryValue(OutputStream) but allows explicitly specifying base64 variant to use.

Annotations
@Override
skipChildrenback to summary
public JsonParser skipChildren()

Overrides tools.jackson.core.base.ParserMinimalBase.skipChildren.

Doc from tools.jackson.core.JsonParser.skipChildren.

Method that will skip all child tokens of an array or object token that the parser currently points to, iff stream points to JsonToken#START_OBJECT or JsonToken#START_ARRAY. If not, it will do nothing. After skipping, stream will point to matching JsonToken#END_OBJECT or JsonToken#END_ARRAY (possibly skipping nested pairs of START/END OBJECT/ARRAY tokens as well as value tokens). The idea is that after calling this method, application will call nextToken to point to the next available token, if any.

Annotations
@Override
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 JsonNode 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