Top Description Fields Constructors Methods
com.fasterxml.jackson.core.base

public abstract Class ParserBase

extends ParserMinimalBase
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.core.json.JsonParserBase
Imports
java.io.*, java.math.BigDecimal, .BigInteger, java.util.Arrays, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.exc.StreamConstraintsException, com.fasterxml.jackson.core.io.IOContext, .ContentReference, .NumberInput, com.fasterxml.jackson.core.json.DupDetector, .JsonReadContext, .PackageVersion, com.fasterxml.jackson.core.util.ByteArrayBuilder, .JacksonFeatureSet, .TextBuffer

Intermediate base class used by all Jackson JsonParser implementations. Contains most common things that are independent of actual underlying input source.

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 boolean
_closed

Flag that indicates whether parser is closed or not.

protected long
_currInputProcessed

Number of characters/bytes that were contained in previous blocks (blocks that were already processed prior to the current buffer).

protected int
_currInputRow

Current row location of current point in input buffer, starting from 1, if available.

protected int
_currInputRowStart

Current index of the first character of the current row in input buffer.

protected int
_expLength

Length of the exponent part of the number, if any, not including 'e' marker or sign, just digits.

protected int
_fractLength

Length of the fractional part (not including decimal point or exponent), in characters.

protected int
_inputEnd

Index of character after last available one in the buffer.

protected int
_inputPtr

Pointer to next available character in buffer

protected int
_intLength

Length of integer part of the number, in characters

protected final IOContext
_ioContext

I/O context for this reader.

protected boolean
_nameCopied

Flag set to indicate whether the field name is available from the name copy buffer or not (in addition to its String representation being available via read context)

protected char[]
_nameCopyBuffer

Temporary buffer that is needed if field name is accessed using getTextCharacters method (instead of String returning alternatives)

protected JsonToken
_nextToken

Secondary token related to the next token after current one; used if its type is known.

protected BigDecimal
protected BigInteger
protected double
protected float
protected int
protected boolean
_numberIsNaN

Marker for explicit "Not a Number" (NaN) values that may be read by some formats: this includes positive and negative infinity, as well as "NaN" result for some arithmetic operations.

protected long
protected boolean
_numberNegative

Flag that indicates whether numeric value has a negative value.

protected String
_numberString

Textual number representation captured from input in cases lazy-parsing is desired.

protected int
_numTypesValid

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

protected JsonReadContext
_parsingContext

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

protected final TextBuffer
_textBuffer

Buffer that contains contents of String values, including field names if necessary (name split across boundary, contains escape sequence, or access needed to char array)

protected int
_tokenInputCol

Column on input row that current token starts; 0-based (although in the end it'll be converted to 1-based)

protected int
_tokenInputRow

Input row on which current token starts, 1-based

protected long
_tokenInputTotal

Total number of bytes/characters read before start of current token.

protected static final JacksonFeatureSet<StreamReadCapability>
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
protected
ParserBase(IOContext ctxt, int features)

Method Summary

Modifier and TypeMethod and Description
protected void
_checkStdFeatureChanges(int
Bitflag of standard features after they were changed
newFeatureFlags
,
int
Bitflag of standard features for which setting did change
changedFeatures
)

Helper method called to verify changes to standard features.

protected abstract void
protected ContentReference

Returns:

ContentReference object to use.
_contentReference
()

Helper method used to encapsulate logic of including (or not) of "content reference" when constructing JsonLocation instances.

protected ContentReference

Returns:

ContentReference object to use when source is not to be included
_contentReferenceRedacted
()

Helper method used to encapsulate logic of providing "content reference" when constructing JsonLocation instances and source information is NOT to be included (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled).

protected BigInteger
protected final int
_decodeBase64Escape(Base64Variant b64variant, int ch, int index)

protected final int
_decodeBase64Escape(Base64Variant b64variant, char ch, int index)

protected char

Returns:

Character decoded, if any
_decodeEscaped
()

Method that sub-classes must implement to support escaped sequences in base64-encoded sections.

protected final int

Returns:

If no exception is thrown, -1 which is used as marked for "end-of-input"
_eofAsNextChar
()

protected void
protected BigDecimal

Returns:

BigDecimal value of the current token
_getBigDecimal
()

Internal accessor that needs to be used for accessing number value of type BigDecimal which -- as of 2.14 -- is typically lazily parsed.

protected BigInteger

Returns:

BigInteger value of the current token
_getBigInteger
()

Internal accessor that needs to be used for accessing number value of type BigInteger which -- as of 2.14 -- is typically lazily parsed.

public ByteArrayBuilder
protected double

Returns:

double value of the current token
_getNumberDouble
()

Internal accessor that needs to be used for accessing number value of type double which -- as of 2.15 -- will be lazily parsed.

protected float

Returns:

float value of the current token
_getNumberFloat
()

Internal accessor that needs to be used for accessing number value of type float which -- as of 2.15 -- will be lazily parsed.

protected Object

Returns:

Source reference
_getSourceReference
()
Deprecated Since 2.13, use _contentReference() instead.

protected int[]
_growNameDecodeBuffer(int[] arr, int more)

protected void
protected void
_handleEOF()

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

Method called when an EOF is encountered between tokens.

protected char
protected int
protected void
_parseNumericValue(int
Numeric type that we will immediately need, if any; mostly necessary to optimize handling of floating point numbers
expType
)

Method that will parse actual numeric value out of a syntactically valid number value.

private void
_parseSlowFloat(int expType)

private void
_parseSlowInt(int expType)

protected void
_releaseBuffers()

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

protected void
_reportMismatchedEndMarker(int actCh, char expCh)

protected void
_reportTooLongIntegral(int expType, String rawNum)

protected void
_throwUnquotedSpace(int
Invalid control character
i
,
String
Addition description of context to use in exception message
ctxtDesc
)

Method called to report a problem with unquoted control character.

protected String

Returns:

Description to use as "valid tokens" in an exception message about invalid (unrecognized) JSON token: called when parser finds something that looks like unquoted textual token
_validJsonTokenList
()

protected String

Returns:

Description to use as "valid JSON values" in an exception message about invalid (unrecognized) JSON value: called when parser finds something that does not look like a value or separator.
_validJsonValueList
()

public void
assignCurrentValue(Object
Current value to assign for the current input context of this parser
v
)

Overrides com.fasterxml.jackson.core.JsonParser.assignCurrentValue.

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

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.

protected void
protected void
protected void
protected void
protected void
protected void
protected void
createChildArrayContext(final int lineNr, final int colNr)

protected void
createChildObjectContext(final int lineNr, final int colNr)

public Object
currentValue()

Overrides com.fasterxml.jackson.core.JsonParser.currentValue.

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

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

public JsonParser
disable(JsonParser.Feature
Feature to disable
f
)

Overrides com.fasterxml.jackson.core.JsonParser.disable.

Method for disabling specified feature (check Feature for list of features)

public JsonParser
enable(JsonParser.Feature
Feature to enable
f
)

Overrides com.fasterxml.jackson.core.JsonParser.enable.

Method for enabling specified parser feature (check Feature for list of features)

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).
variant
)

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

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

Deprecated

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.

Deprecated

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

Overrides com.fasterxml.jackson.core.JsonParser.getNumberValueDeferred.

Method similar to getNumberValue but that returns either same Number value as getNumberValue() (if already decoded), or String representation of as-of-yet undecoded number.

public Number
getNumberValueExact()

Overrides com.fasterxml.jackson.core.JsonParser.getNumberValueExact.

Method similar to getNumberValue with the difference that for floating-point numbers value returned may be BigDecimal if the underlying format does not store floating-point numbers using native representation: for example, textual formats represent numbers as Strings (which are 10-based), and conversion to java.lang.Double is potentially lossy operation.

public JsonReadContext
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 long
public int
public int
public JsonLocation
getTokenLocation()

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

Deprecated

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

protected static int[]
growArrayBy(int[] arr, int more)

public boolean
hasTextCharacters()

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

Method that can be used to determine whether calling of getTextCharacters would be the most efficient way to access textual content for the event parser currently points to.

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

Overrides com.fasterxml.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!).

protected boolean
loadMore()
Deprecated

protected void
loadMoreGuaranteed()
Deprecated

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
overrideStdFeatures(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.overrideStdFeatures.

Bulk set method for (re)setting states of features specified by mask.

protected IllegalArgumentException
reportInvalidBase64Char(Base64Variant b64variant, int ch, int bindex)

protected IllegalArgumentException
reportInvalidBase64Char(Base64Variant b64variant, int ch, int bindex, String msg)

protected final JsonToken
reset(boolean negative, int intLen, int fractLen, int expLen)

protected final JsonToken
resetAsNaN(String valueStr, double value)

protected final JsonToken
resetFloat(boolean negative, int intLen, int fractLen, int expLen)

protected final JsonToken
resetInt(boolean negative, int intLen)

public JsonParser
setFeatureMask(int
Bit mask that defines set of features to enable
newMask
)

Overrides com.fasterxml.jackson.core.JsonParser.setFeatureMask.

Deprecated

Bulk set method for (re)setting states of all standard Features

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_wrapErrorclearCurrentTokencurrentTokencurrentTokenIdgetCurrentTokengetCurrentTokenIdgetLastClearedTokengetTextgetTextCharactersgetTextLengthgetTextOffsetgetValueAsBooleangetValueAsDoublegetValueAsIntgetValueAsIntgetValueAsLonggetValueAsLonggetValueAsStringgetValueAsStringhasCurrentTokenhasTokenhasTokenIdisExpectedNumberIntTokenisExpectedStartArrayTokenisExpectedStartObjectTokennextTokennextValuereportInvalidNumberreportOverflowIntreportOverflowIntreportOverflowIntreportOverflowLongreportOverflowLongreportOverflowLongreportUnexpectedNumberCharskipChildren