Class NonBlockingUtf8JsonParserBase
java.lang.Object
tools.jackson.core.JsonParser
tools.jackson.core.base.ParserMinimalBase
tools.jackson.core.base.ParserBase
tools.jackson.core.json.JsonParserBase
tools.jackson.core.json.async.NonBlockingJsonParserBase
tools.jackson.core.json.async.NonBlockingUtf8JsonParserBase
- All Implemented Interfaces:
Closeable, AutoCloseable, Versioned
- Direct Known Subclasses:
NonBlockingByteArrayJsonParser, NonBlockingByteBufferJsonParser
Non-blocking parser base implementation for JSON content.
NOTE: only supports parsing of UTF-8 encoded content (and 7-bit US-ASCII since it is strict subset of UTF-8): other encodings are not supported.
-
Nested Class Summary
Nested classes/interfaces inherited from class JsonParser
JsonParser.NumberType, JsonParser.NumberTypeFP -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int[]private static final int[]protected intIn addition to current buffer pointer, and end pointer, we will also need to know number of bytes originally contained.private static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intFields inherited from class NonBlockingJsonParserBase
_currBufferStart, _currInputRowAlt, _endOfInput, _majorState, _majorStateAfterValue, _minorState, _minorStateAfterSplit, _nonStdTokenType, _pending32, _pendingBytes, _pendingSurrogateInName, _quad1, _quadBuffer, _quadLength, _quoted32, _quotedDigits, _symbols, MAJOR_ARRAY_ELEMENT_FIRST, MAJOR_ARRAY_ELEMENT_NEXT, MAJOR_CLOSED, MAJOR_INITIAL, MAJOR_OBJECT_PROPERTY_FIRST, MAJOR_OBJECT_PROPERTY_NEXT, MAJOR_OBJECT_VALUE, MAJOR_ROOT, MINOR_COMMENT_C, MINOR_COMMENT_CLOSING_ASTERISK, MINOR_COMMENT_CPP, MINOR_COMMENT_LEADING_SLASH, MINOR_COMMENT_YAML, MINOR_NUMBER_EXPONENT_DIGITS, MINOR_NUMBER_EXPONENT_MARKER, MINOR_NUMBER_FRACTION_DIGITS, MINOR_NUMBER_INTEGER_DIGITS, MINOR_NUMBER_MINUS, MINOR_NUMBER_MINUSZERO, MINOR_NUMBER_PLUS, MINOR_NUMBER_ZERO, MINOR_PROPERTY_APOS_NAME, MINOR_PROPERTY_LEADING_COMMA, MINOR_PROPERTY_LEADING_WS, MINOR_PROPERTY_NAME, MINOR_PROPERTY_NAME_ESCAPE, MINOR_PROPERTY_UNQUOTED_NAME, MINOR_ROOT_BOM, MINOR_ROOT_GOT_SEPARATOR, MINOR_ROOT_NEED_SEPARATOR, MINOR_VALUE_APOS_STRING, MINOR_VALUE_EXPECTING_COLON, MINOR_VALUE_EXPECTING_COMMA, MINOR_VALUE_LEADING_WS, MINOR_VALUE_STRING, MINOR_VALUE_STRING_ESCAPE, MINOR_VALUE_STRING_UTF8_2, MINOR_VALUE_STRING_UTF8_3, MINOR_VALUE_STRING_UTF8_4, MINOR_VALUE_TOKEN_ERROR, MINOR_VALUE_TOKEN_FALSE, MINOR_VALUE_TOKEN_NON_STD, MINOR_VALUE_TOKEN_NULL, MINOR_VALUE_TOKEN_TRUE, MINOR_VALUE_WS_AFTER_COMMA, NON_STD_TOKEN_INFINITY, NON_STD_TOKEN_MINUS_INFINITY, NON_STD_TOKEN_NAN, NON_STD_TOKEN_PLUS_INFINITY, NON_STD_TOKEN_VALUES, NON_STD_TOKENSFields inherited from class JsonParserBase
_formatReadFeatures, _nameCopied, _nextToken, _streamReadContextFields 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
ConstructorsModifierConstructorDescriptionprotectedNonBlockingUtf8JsonParserBase(ObjectReadContext readCtxt, IOContext ctxt, int stdFeatures, int formatFeatures, ByteQuadsCanonicalizer sym) -
Method Summary
Modifier and TypeMethodDescriptionprivate final intprotected charMethod that sub-classes must implement to support escaped sequences in base64-encoded sections.private final intprivate int_decodeSplitEscaped(int value, int bytesRead) private final boolean_decodeSplitMultiByte(int c, int type, boolean gotNext) private final boolean_decodeSplitUTF8_3(int prev, int prevCount, int next) private final boolean_decodeSplitUTF8_4(int prev, int prevCount, int next) private final int_decodeUTF8_2(int c, int d) private final int_decodeUTF8_3(int c, int d, int e) private final int_decodeUTF8_4(int c, int d, int e, int f) private final Stringprivate JsonToken_finishAposName(int qlen, int currQuad, int currQuadBytes) private final JsonTokenprivate final JsonToken_finishBOM(int bytesHandled) private final JsonToken_finishCComment(int fromMinorState, boolean gotStar) private final JsonToken_finishCppComment(int fromMinorState) protected JsonTokenprotected JsonTokenprotected JsonToken_finishFloatExponent(boolean checkSign, int ch) protected JsonTokenprivate final JsonToken_finishHashComment(int fromMinorState) protected JsonToken_finishKeywordToken(String expToken, int matched, JsonToken result) protected JsonToken_finishKeywordTokenWithEOF(String expToken, int matched, JsonToken result) protected JsonToken_finishNonStdToken(int type, int matched) protected JsonToken_finishNonStdTokenWithEOF(int type, int matched) protected JsonToken_finishNumberIntegralPart(char[] outBuf, int outPtr) protected JsonTokenprotected JsonToken_finishNumberLeadingPosNegZeroes(boolean negative) protected JsonTokenprotected JsonTokenprotected JsonToken_finishNumberMinus(int ch) protected JsonToken_finishNumberPlus(int ch) protected JsonToken_finishNumberPlusMinus(int ch, boolean negative) protected final JsonTokenprivate final JsonTokenprotected final JsonTokenMethod called when decoding of a token has been started, but not yet completed due to missing input; method is to continue decoding due to at least one more byte being made available to decode.protected final JsonTokenMethod similar to_finishToken(), but called when no more input is available, and end-of-input has been detected.private JsonToken_finishUnquotedName(int qlen, int currQuad, int currQuadBytes) Parsing of optionally supported non-standard "unquoted" names: names without either double-quotes or apostrophes surrounding them.private JsonToken_handleOddName(int ch) Method called when we see non-white space character other than double quote, when expecting a field name.private final JsonToken_parseEscapedName(int qlen, int currQuad, int currQuadBytes) Slower parsing method which is generally branched to when an escape sequence is detected (or alternatively for long names, one crossing input buffer boundary).private final String_parseMediumName(int ptr, int q2) private final String_parseMediumName2(int ptr, int q3, int q2) protected JsonToken_reportErrorToken(String actualToken) private void_setExpLength(int len) private void_setFractLength(int len) private void_setIntLength(int len) private final int_skipWS(int ch) private final JsonToken_startAfterComment(int fromMinorState) protected JsonTokenprivate final JsonToken_startDocument(int ch) protected JsonTokenprotected JsonToken_startFloat(char[] outBuf, int outPtr, int ch) protected JsonTokenprivate final JsonToken_startName(int ch) Method that handles initial token type recognition for token that has to be either PROPERTY_NAME or END_OBJECT.private final JsonToken_startNameAfterComma(int ch) protected JsonTokenprotected JsonTokenprotected JsonTokenprotected JsonTokenprotected JsonToken_startPositiveNumber(int ch) private final JsonToken_startSlashComment(int fromMinorState) protected JsonTokenprotected JsonTokenprotected JsonToken_startUnexpectedValue(boolean leadingComma, int ch) private final JsonToken_startValue(int ch) Helper method called to detect type of a value token (at any level), and possibly decode it if contained in input buffer.private final JsonToken_startValueAfterComma(int ch) private final JsonToken_startValueExpectColon(int ch) private final JsonToken_startValueExpectComma(int ch) private final void_verifyRootSpace(int ch) Method called to verify that a root-level value is followed by a space token (or EOF).voidprotected abstract bytegetByteFromBuffer(int ptr) protected abstract byteprotected abstract intfinal booleanMain iteration method, which will advance stream enough to determine type of the next token, if any.Methods inherited from class NonBlockingJsonParserBase
_addName, _closeArrayScope, _closeInput, _closeObjectScope, _currentLocationMinusOne, _eofAsNextToken, _fieldComplete, _findName, _findName, _findName, _getText2, _nonStdToken, _padLastQuad, _releaseBuffers, _reportInvalidChar, _reportInvalidInitial, _reportInvalidOther, _reportInvalidOther, _startArrayScope, _startObjectScope, _updateTokenLocation, _valueComplete, _valueCompleteInt, _valueNonStdNumberComplete, canParseAsync, currentLocation, currentTokenLocation, getBinaryValue, getEmbeddedObject, getString, getString, getStringCharacters, getStringLength, getStringOffset, getValueAsString, getValueAsString, hasStringCharacters, readBinaryValue, readString, releaseBuffered, streamReadInputSource, symbolTableForTestsMethods inherited from class JsonParserBase
_bufferForStringStreaming, _decodeSurrogate, _handleUnrecognizedCharacterEscape, _isAllowedCtrlCharRS, _parseIntValue, _parseNumericValue, _reportExtraEndMarker, _reportMismatchedEndMarker, _reportTooLongIntegral, _reportUnexpectedLowSurrogate, _throwUnquotedSpace, _validJsonTokenList, _validJsonValueList, assignCurrentValue, createChildArrayContext, createChildObjectContext, currentName, currentNameInBuffer, currentValue, isEnabled, streamReadCapabilities, streamReadContext, versionMethods inherited from class ParserBase
_contentReference, _contentReferenceRedacted, _convertBigDecimalToBigInteger, _decodeBase64Escape, _decodeBase64Escape, _eofAsNextChar, _getBigDecimal, _getBigInteger, _getByteArrayBuilder, _getNumberDouble, _getNumberFloat, _growNameDecodeBuffer, _handleBase64MissingPadding, _handleEOF, _reportInvalidBase64Char, _reportInvalidBase64Char, close, convertNumberToBigDecimal, convertNumberToBigInteger, convertNumberToDouble, convertNumberToFloat, convertNumberToInt, convertNumberToLong, getBigIntegerValue, getDecimalValue, getDoubleValue, getFloatValue, getIntValue, getLongValue, getNumberType, getNumberValue, getNumberValueDeferred, getNumberValueExact, getTokenCharacterOffset, getTokenColumnNr, getTokenLineNr, growArrayBy, isNaN, reset, resetAsNaN, resetFloat, resetIntMethods inherited from class ParserMinimalBase
_constructInputCoercion, _constructNotNumericType, _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, getLastClearedToken, getNumberTypeFP, getShortValue, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, 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, canReadObjectId, canReadTypeId, getBinaryValue, getObjectId, getSchema, getText, getTextCharacters, getTextLength, getTextOffset, getTypeId, getValueAsBoolean, getValueAsDouble, nextBooleanValue, nextIntValue, nextLongValue, nextStringValue, nonBlockingInputFeeder, readBinaryValue, releaseBuffered
-
Field Details
-
FEAT_MASK_TRAILING_COMMA
private static final int FEAT_MASK_TRAILING_COMMA -
FEAT_MASK_LEADING_ZEROS
private static final int FEAT_MASK_LEADING_ZEROS -
FEAT_MASK_ALLOW_MISSING
private static final int FEAT_MASK_ALLOW_MISSING -
FEAT_MASK_ALLOW_SINGLE_QUOTES
private static final int FEAT_MASK_ALLOW_SINGLE_QUOTES -
FEAT_MASK_ALLOW_UNQUOTED_NAMES
private static final int FEAT_MASK_ALLOW_UNQUOTED_NAMES -
FEAT_MASK_ALLOW_JAVA_COMMENTS
private static final int FEAT_MASK_ALLOW_JAVA_COMMENTS -
FEAT_MASK_ALLOW_YAML_COMMENTS
private static final int FEAT_MASK_ALLOW_YAML_COMMENTS -
_icUTF8
private static final int[] _icUTF8 -
_icLatin1
protected static final int[] _icLatin1 -
_origBufferLen
protected int _origBufferLenIn addition to current buffer pointer, and end pointer, we will also need to know number of bytes originally contained. This is needed to correctly update location information when the block has been completed.
-
-
Constructor Details
-
NonBlockingUtf8JsonParserBase
protected NonBlockingUtf8JsonParserBase(ObjectReadContext readCtxt, IOContext ctxt, int stdFeatures, int formatFeatures, ByteQuadsCanonicalizer sym)
-
-
Method Details
-
needMoreInput
public final boolean needMoreInput() -
endOfInput
public void endOfInput() -
_decodeEscaped
Description copied from class:ParserBaseMethod that sub-classes must implement to support escaped sequences in base64-encoded sections. Sub-classes that do not need base64 support can leave this as is- Overrides:
_decodeEscapedin classParserBase- Returns:
- Character decoded, if any
- Throws:
JacksonException- If escape decoding fails
-
nextToken
Description copied from class:JsonParserMain 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.- Specified by:
nextTokenin classJsonParser- Returns:
- Next token from the stream, if any found, or null to indicate end-of-input
- Throws:
JacksonException- for low-level read issues
-
getNextSignedByteFromBuffer
protected abstract byte getNextSignedByteFromBuffer()- Returns:
- next signed byte from the buffer
- Since:
- v2.14
-
getNextUnsignedByteFromBuffer
protected abstract int getNextUnsignedByteFromBuffer()- Returns:
- next unsigned byte from the buffer
- Since:
- v2.14
-
getByteFromBuffer
protected abstract byte getByteFromBuffer(int ptr) - Parameters:
ptr- pointer to byte that is required- Returns:
- byte from the buffer at the given pointer
- Since:
- v2.14
-
_finishToken
Method called when decoding of a token has been started, but not yet completed due to missing input; method is to continue decoding due to at least one more byte being made available to decode.- Returns:
- Token decoded, if complete;
JsonToken.NOT_AVAILABLEif not - Throws:
JacksonException- (generallyStreamReadException) for decoding problems
-
_finishTokenWithEOF
Method similar to_finishToken(), but called when no more input is available, and end-of-input has been detected. This is usually problem case, but not always: root-level values may be properly terminated by this, and similarly trailing white-space may have been skipped.- Returns:
- Token decoded, if complete;
JsonToken.NOT_AVAILABLEif not - Throws:
JacksonException- (generallyStreamReadException) for decoding problems
-
_startDocument
- Throws:
JacksonException
-
_finishBOM
- Throws:
JacksonException
-
_startName
Method that handles initial token type recognition for token that has to be either PROPERTY_NAME or END_OBJECT.- Throws:
JacksonException
-
_startNameAfterComma
- Throws:
JacksonException
-
_startValue
Helper method called to detect type of a value token (at any level), and possibly decode it if contained in input buffer. Value may be preceded by leading white-space, but no separator (comma).- Throws:
JacksonException
-
_startValueExpectComma
- Throws:
JacksonException
-
_startValueExpectColon
- Throws:
JacksonException
-
_startValueAfterComma
- Throws:
JacksonException
-
_startUnexpectedValue
- Throws:
JacksonException
-
_skipWS
- Throws:
JacksonException
-
_startSlashComment
- Throws:
JacksonException
-
_finishHashComment
- Throws:
JacksonException
-
_finishCppComment
- Throws:
JacksonException
-
_finishCComment
private final JsonToken _finishCComment(int fromMinorState, boolean gotStar) throws JacksonException - Throws:
JacksonException
-
_startAfterComment
- Throws:
JacksonException
-
_startFalseToken
- Throws:
JacksonException
-
_startTrueToken
- Throws:
JacksonException
-
_startNullToken
- Throws:
JacksonException
-
_finishKeywordToken
protected JsonToken _finishKeywordToken(String expToken, int matched, JsonToken result) throws JacksonException - Throws:
JacksonException
-
_finishKeywordTokenWithEOF
protected JsonToken _finishKeywordTokenWithEOF(String expToken, int matched, JsonToken result) throws JacksonException - Throws:
JacksonException
-
_finishNonStdToken
- Throws:
JacksonException
-
_finishNonStdTokenWithEOF
- Throws:
JacksonException
-
_finishErrorToken
- Throws:
JacksonException
-
_finishErrorTokenWithEOF
- Throws:
JacksonException
-
_reportErrorToken
- Throws:
JacksonException
-
_startFloatThatStartsWithPeriod
- Throws:
JacksonException
-
_startPositiveNumber
- Throws:
JacksonException
-
_startNegativeNumber
- Throws:
JacksonException
-
_startPositiveNumber
- Throws:
JacksonException
-
_startNumberLeadingZero
- Throws:
JacksonException
-
_finishNumberMinus
- Throws:
JacksonException
-
_finishNumberPlus
- Throws:
JacksonException
-
_finishNumberPlusMinus
- Throws:
JacksonException
-
_finishNumberLeadingZeroes
- Throws:
JacksonException
-
_finishNumberLeadingNegZeroes
- Throws:
JacksonException
-
_finishNumberLeadingPosZeroes
- Throws:
JacksonException
-
_finishNumberLeadingPosNegZeroes
- Throws:
JacksonException
-
_finishNumberIntegralPart
- Throws:
JacksonException
-
_startFloat
- Throws:
JacksonException
-
_finishFloatFraction
- Throws:
JacksonException
-
_finishFloatExponent
- Throws:
JacksonException
-
_fastParseName
- Throws:
JacksonException
-
_parseMediumName
- Throws:
JacksonException
-
_parseMediumName2
- Throws:
JacksonException
-
_parseEscapedName
private final JsonToken _parseEscapedName(int qlen, int currQuad, int currQuadBytes) throws JacksonException Slower parsing method which is generally branched to when an escape sequence is detected (or alternatively for long names, one crossing input buffer boundary). Needs to be able to handle more exceptional cases, gets slower, and hence is offlined to a separate method.- Throws:
JacksonException
-
_handleOddName
Method called when we see non-white space character other than double quote, when expecting a field name. In standard mode will just throw an exception; but in non-standard modes may be able to parse name.- Throws:
JacksonException
-
_finishUnquotedName
private JsonToken _finishUnquotedName(int qlen, int currQuad, int currQuadBytes) throws JacksonException Parsing of optionally supported non-standard "unquoted" names: names without either double-quotes or apostrophes surrounding them. Unlike other- Throws:
JacksonException
-
_finishAposName
private JsonToken _finishAposName(int qlen, int currQuad, int currQuadBytes) throws JacksonException - Throws:
JacksonException
-
_finishPropertyWithEscape
- Throws:
JacksonException
-
_decodeSplitEscaped
- Throws:
JacksonException
-
_startString
- Throws:
JacksonException
-
_finishRegularString
- Throws:
JacksonException
-
_startAposString
- Throws:
JacksonException
-
_finishAposString
- Throws:
JacksonException
-
_decodeSplitMultiByte
private final boolean _decodeSplitMultiByte(int c, int type, boolean gotNext) throws JacksonException - Throws:
JacksonException
-
_decodeSplitUTF8_3
- Throws:
JacksonException
-
_decodeSplitUTF8_4
- Throws:
JacksonException
-
_decodeCharEscape
- Throws:
JacksonException
-
_decodeFastCharEscape
- Throws:
JacksonException
-
_decodeUTF8_2
- Throws:
JacksonException
-
_decodeUTF8_3
- Throws:
JacksonException
-
_decodeUTF8_4
- Throws:
JacksonException
-
_verifyRootSpace
Method called to verify that a root-level value is followed by a space token (or EOF).NOTE: caller MUST ensure there is at least one character available; and that input pointer is AT given char (not past)
- Parameters:
ch- Character after number value- Throws:
JacksonException- for decoding problems (invalid white space)
-
_setIntLength
- Throws:
StreamConstraintsException
-
_setFractLength
- Throws:
StreamConstraintsException
-
_setExpLength
- Throws:
StreamConstraintsException
-