Class JsonParserBase
java.lang.Object
tools.jackson.core.JsonParser
tools.jackson.core.base.ParserMinimalBase
tools.jackson.core.base.ParserBase
tools.jackson.core.json.JsonParserBase
- All Implemented Interfaces:
Closeable, AutoCloseable, Versioned
- Direct Known Subclasses:
NonBlockingJsonParserBase, ReaderBasedJsonParser, UTF8DataInputJsonParser, UTF8StreamJsonParser
Another intermediate base class, only used by actual JSON-backed parser
implementations.
- Since:
- 3.0
-
Nested Class Summary
Nested classes/interfaces inherited from class JsonParser
JsonParser.NumberType, JsonParser.NumberTypeFP -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intBit flag forJsonReadFeatures that are enabled.protected booleanFlag set to indicate whether the Object property name is available from the name copy buffer or not (in addition to its String representation being available via read context)private char[]Temporary buffer that is needed if an Object property name is accessed usingJsonParser.getTextCharacters()method (instead of String returning alternatives)protected JsonTokenSecondary token related to the next token after current one; used if its type is known.protected JsonReadContextInformation about parser context, context in which the next token is to be parsed (root, array, object).private char[]Lazily-allocated intermediate buffer used by_streamString()implementations to batch writes to the targetWriter.private static final char[]Fields inherited from class ParserBase
_binaryValue, _byteArrayBuilder, _currInputProcessed, _currInputRow, _currInputRowStart, _expLength, _fractLength, _inputEnd, _inputPtr, _intLength, _numberBigDecimal, _numberBigInt, _numberDouble, _numberFloat, _numberInt, _numberIsNaN, _numberLong, _numberNegative, _numberString, _numTypesValid, _textBuffer, _tokenInputCol, _tokenInputRow, _tokenInputTotalFields inherited from class ParserMinimalBase
_closed, _currToken, _ioContext, _lastClearedToken, _objectReadContext, _streamReadConstraints, _streamReadFeatures, _tokenCount, _trackMaxTokenCount, BD_MAX_INT, BD_MAX_LONG, BD_MIN_INT, BD_MIN_LONG, BI_MAX_INT, BI_MAX_LONG, BI_MIN_INT, BI_MIN_LONG, CHAR_NULL, INT_0, INT_9, INT_APOS, INT_ASTERISK, INT_BACKSLASH, INT_COLON, INT_COMMA, INT_CR, INT_e, INT_E, INT_HASH, INT_LBRACKET, INT_LCURLY, INT_LF, INT_MINUS, INT_PERIOD, INT_PLUS, INT_QUOTE, INT_RBRACKET, INT_RCURLY, INT_RS, INT_SLASH, INT_SPACE, INT_TAB, MAX_BYTE_I, MAX_INT_D, MAX_INT_L, MAX_LONG_D, MAX_SHORT_I, MIN_BYTE_I, MIN_INT_D, MIN_INT_L, MIN_LONG_D, MIN_SHORT_I, NO_BYTES, NO_INTS, NR_BIGDECIMAL, NR_BIGINT, NR_DOUBLE, NR_FLOAT, NR_INT, NR_LONG, NR_UNKNOWN, STREAM_READ_FEATURE_DEFAULTSFields inherited from class JsonParser
DEFAULT_READ_CAPABILITIES -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJsonParserBase(ObjectReadContext readCtxt, IOContext ctxt, int streamReadFeatures, int formatReadFeatures) -
Method Summary
Modifier and TypeMethodDescriptionprotected char[]Returns the lazily-allocated intermediate buffer used by_streamString()to batch-write decoded characters to aWriter.protected int_decodeSurrogate(int hi, int lo) Validate thatlois a valid low surrogate (DC00-DFFF) and combine with high surrogatehiinto a supplementary code point.protected char_handleUnrecognizedCharacterEscape(char ch) protected boolean_isAllowedCtrlCharRS(int i) protected intprotected void_parseNumericValue(int 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_reportExtraEndMarker(int actCh) protected void_reportMismatchedEndMarker(int actCh, char expCh) protected void_reportTooLongIntegral(int expType, String rawNum) protected <T> T_reportUnexpectedLowSurrogate(int ch) Report an error for a lone low surrogate encountered without a preceding high surrogate.protected void_throwUnquotedSpace(int i, String ctxtDesc) protected Stringprotected StringvoidHelper method, usually equivalent to:getParsingContext().assignCurrentValue(v);protected voidcreateChildArrayContext(int lineNr, int colNr) protected voidcreateChildObjectContext(int lineNr, int colNr) Method that can be called to get the name associated with the current event.protected char[]Helper method, usually equivalent to:getParsingContext().currentValue();booleanMethod that can be used to determine whether calling ofJsonParser.getStringCharacters()would be the most efficient way to access String value for the event parser currently points to (compared toJsonParser.getString()).booleanAccessor for getting metadata on capabilities of this parser, based on underlying data format being read (directly or indirectly).Method that can be used to access current parsing context reader is in.version()Accessor for getting version of the core package, given a parser instance.Methods inherited from class ParserBase
_contentReference, _contentReferenceRedacted, _convertBigDecimalToBigInteger, _decodeBase64Escape, _decodeBase64Escape, _decodeEscaped, _eofAsNextChar, _getBigDecimal, _getBigInteger, _getByteArrayBuilder, _getNumberDouble, _getNumberFloat, _growNameDecodeBuffer, _handleBase64MissingPadding, _handleEOF, _releaseBuffers, _reportInvalidBase64Char, _reportInvalidBase64Char, close, convertNumberToBigDecimal, convertNumberToBigInteger, convertNumberToDouble, convertNumberToFloat, convertNumberToInt, convertNumberToLong, getBigIntegerValue, getBinaryValue, getDecimalValue, getDoubleValue, getFloatValue, getIntValue, getLongValue, getNumberType, getNumberValue, getNumberValueDeferred, getNumberValueExact, getTokenCharacterOffset, getTokenColumnNr, getTokenLineNr, growArrayBy, isNaN, reset, resetAsNaN, resetFloat, resetIntMethods inherited from class ParserMinimalBase
_closeInput, _constructInputCoercion, _constructNotNumericType, _currentLocationMinusOne, _decodeBase64, _getCharDesc, _hasTextualNull, _longIntegerDesc, _longNumberDesc, _nullSafeUpdateToken, _reportBadInputStream, _reportBadReader, _reportError, _reportError, _reportError, _reportError, _reportInvalidEOF, _reportInvalidEOF, _reportInvalidEOFInValue, _reportInvalidNumber, _reportInvalidSpace, _reportInvalidUTF8Surrogate, _reportMissingRootWS, _reportOverflowByte, _reportOverflowInt, _reportOverflowInt, _reportOverflowInt, _reportOverflowLong, _reportOverflowLong, _reportOverflowLong, _reportOverflowShort, _reportUnexpectedChar, _reportUnexpectedNumberChar, _throwInternal, _updateToken, _updateTokenToNA, _updateTokenToNull, _wrapIOFailure, clearCurrentToken, currentNameMatch, currentToken, currentTokenCount, currentTokenId, finishToken, getBooleanValue, getByteValue, getEmbeddedObject, getLastClearedToken, getNumberTypeFP, getShortValue, getString, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, getValueAsString, getValueAsString, hasCurrentToken, hasToken, hasTokenId, isClosed, isEnabled, isExpectedNumberIntToken, isExpectedStartArrayToken, isExpectedStartObjectToken, nextName, nextName, nextNameMatch, nextValue, objectReadContext, readValueAs, readValueAs, readValueAs, readValueAsTree, skipChildren, streamReadConstraints, streamReadFeaturesMethods inherited from class JsonParser
_constructReadException, _constructReadException, _constructReadException, _constructReadException, _constructReadException, _constructReadException, _reportUnsupportedOperation, canParseAsync, canReadObjectId, canReadTypeId, currentLocation, currentTokenLocation, getBinaryValue, getObjectId, getSchema, getString, getStringCharacters, getStringLength, getStringOffset, getText, getTextCharacters, getTextLength, getTextOffset, getTypeId, getValueAsBoolean, getValueAsDouble, nextBooleanValue, nextIntValue, nextLongValue, nextStringValue, nextToken, nonBlockingInputFeeder, readBinaryValue, readBinaryValue, readString, releaseBuffered, releaseBuffered, streamReadInputSource
-
Field Details
-
NO_CHARS
private static final char[] NO_CHARS -
_formatReadFeatures
protected int _formatReadFeaturesBit flag forJsonReadFeatures that are enabled. -
_streamReadContext
Information about parser context, context in which the next token is to be parsed (root, array, object). -
_nextToken
Secondary token related to the next token after current one; used if its type is known. This may be value token that followsJsonToken.PROPERTY_NAME, for example. -
_nameCopyBuffer
private char[] _nameCopyBufferTemporary buffer that is needed if an Object property name is accessed usingJsonParser.getTextCharacters()method (instead of String returning alternatives) -
_nameCopied
protected boolean _nameCopiedFlag set to indicate whether the Object property name is available from the name copy buffer or not (in addition to its String representation being available via read context) -
_streamStringBuffer
private char[] _streamStringBufferLazily-allocated intermediate buffer used by_streamString()implementations to batch writes to the targetWriter. Allocated on first call and reused on subsequent calls to avoid repeated allocation for parsers that callreadString(Writer)multiple times.- Since:
- 3.1
-
-
Constructor Details
-
JsonParserBase
protected JsonParserBase(ObjectReadContext readCtxt, IOContext ctxt, int streamReadFeatures, int formatReadFeatures)
-
-
Method Details
-
version
Description copied from class:JsonParserAccessor for getting version of the core package, given a parser instance. Left for sub-classes to implement.- Specified by:
versionin interfaceVersioned- Specified by:
versionin classJsonParser- Returns:
- Version of the component
-
streamReadCapabilities
Description copied from class:JsonParserAccessor for getting metadata on capabilities of this parser, based on underlying data format being read (directly or indirectly).- Overrides:
streamReadCapabilitiesin classParserMinimalBase- Returns:
- Set of read capabilities for content to read via this parser
-
streamReadContext
Description copied from class:JsonParserMethod 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- Specified by:
streamReadContextin classJsonParser- Returns:
- Stream output context (
TokenStreamContext) associated with this parser
-
currentValue
Description copied from class:JsonParserHelper 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.
- Overrides:
currentValuein classParserBase- Returns:
- "Current value" for the current input context this parser has
-
assignCurrentValue
Description copied from class:JsonParserHelper method, usually equivalent to:getParsingContext().assignCurrentValue(v);- Overrides:
assignCurrentValuein classParserBase- Parameters:
v- "Current value" to assign to the current input context of this parser
-
currentName
Method that can be called to get the name associated with the current event.- Specified by:
currentNamein classJsonParser- Returns:
- Name of the current property name, if any, in the parsing context (
nullif none)
-
hasStringCharacters
public boolean hasStringCharacters()Description copied from class:JsonParserMethod that can be used to determine whether calling ofJsonParser.getStringCharacters()would be the most efficient way to access String value for the event parser currently points to (compared toJsonParser.getString()).- Overrides:
hasStringCharactersin classParserBase- Returns:
- True if parser currently has character array that can
be efficiently returned via
JsonParser.getStringCharacters(); false means that it may or may not exist
-
createChildArrayContext
- Throws:
JacksonException
-
createChildObjectContext
- Throws:
JacksonException
-
_parseNumericValue
Description copied from class:ParserBaseMethod that will parse actual numeric value out of a syntactically valid number value. Type it will parse into depends on whether it is a floating point number, as well as its magnitude: smallest legal type (of ones available) is used for efficiency.- Specified by:
_parseNumericValuein classParserBase- Parameters:
expType- Numeric type that we will immediately need, if any; mostly necessary to optimize handling of floating point numbers- Throws:
InputCoercionException- if the current token not of numeric typeJacksonException
-
_parseIntValue
- Specified by:
_parseIntValuein classParserBase- Throws:
JacksonException
-
_parseSlowFloat
- Throws:
JacksonException
-
_parseSlowInt
- Throws:
JacksonException
-
_reportTooLongIntegral
- Throws:
JacksonException
-
isEnabled
-
currentNameInBuffer
protected char[] currentNameInBuffer() -
_bufferForStringStreaming
protected char[] _bufferForStringStreaming()Returns the lazily-allocated intermediate buffer used by_streamString()to batch-write decoded characters to aWriter. The same buffer is reused across calls.- Since:
- 3.1
-
_handleUnrecognizedCharacterEscape
- Throws:
StreamReadException
-
_reportMismatchedEndMarker
- Throws:
StreamReadException
-
_reportExtraEndMarker
- Throws:
StreamReadException
-
_throwUnquotedSpace
- Throws:
StreamReadException
-
_validJsonTokenList
-
_validJsonValueList
-
_decodeSurrogate
Validate thatlois a valid low surrogate (DC00-DFFF) and combine with high surrogatehiinto a supplementary code point.- Throws:
StreamReadException- Since:
- 3.1
-
_reportUnexpectedLowSurrogate
Report an error for a lone low surrogate encountered without a preceding high surrogate.- Throws:
StreamReadException- Since:
- 3.1
-
_isAllowedCtrlCharRS
protected boolean _isAllowedCtrlCharRS(int i)
-