Class SmileParser
java.lang.Object
com.fasterxml.jackson.core.JsonParser
com.fasterxml.jackson.core.base.ParserMinimalBase
com.fasterxml.jackson.dataformat.smile.SmileParserBase
com.fasterxml.jackson.dataformat.smile.SmileParser
- All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned, Closeable, AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration that defines all togglable features for Smile generators.Nested classes/interfaces inherited from class com.fasterxml.jackson.core.JsonParser
com.fasterxml.jackson.core.JsonParser.NumberType, com.fasterxml.jackson.core.JsonParser.NumberTypeFP -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag that indicates whether the input buffer is recycable (and needs to be returned to recycler once we are done) or not.protected byte[]Current buffer from which data is read; generally data is read into buffer from input source, but in some cases pre-loaded buffer is handed to the parser.protected InputStreamInput stream that can be used for reading more content, if one in use.protected com.fasterxml.jackson.core.ObjectCodecCodec used for data binding when (if) requested.protected booleanFlag that indicates that the current token has not yet been fully processed, and needs to be finished for some access (or skipped to obtain the next token)protected intType byte of the current token (as in)private static final booleanFlag to indicate if the JDK version is 11 or later.Fields inherited from class SmileParserBase
_binaryValue, _closed, _currInputProcessed, _formatFeatures, _inputEnd, _inputPtr, _ioContext, _mayContainRawBinary, _nameCopied, _nameCopyBuffer, _numberBigDecimal, _numberBigInt, _numberDouble, _numberFloat, _numberInt, _numberLong, _numberType, _numTypesValid, _quad1, _quad2, _quad3, _quadBuffer, _seenNameCount, _seenNames, _seenStringValueCount, _seenStringValues, _streamReadContext, _symbols, _symbolsCanonical, _textBuffer, _tokenOffsetForTotal, DEFAULT_NAME_BUFFER_LENGTH, DEFAULT_STRING_VALUE_BUFFER_LENGTH, LONGEST_NON_CHUNKED_BINARY, NO_STRINGS, SMILE_READ_CAPABILITIESFields inherited from class com.fasterxml.jackson.core.base.ParserMinimalBase
_currToken, _lastClearedToken, _streamReadConstraints, _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_SLASH, INT_SPACE, INT_TAB, MAX_ERROR_TOKEN_LENGTH, MAX_INT_D, MAX_INT_L, MAX_LONG_D, MIN_INT_D, MIN_INT_L, MIN_LONG_D, NO_BYTES, NO_INTS, NR_BIGDECIMAL, NR_BIGINT, NR_DOUBLE, NR_FLOAT, NR_INT, NR_LONG, NR_UNKNOWNFields inherited from class com.fasterxml.jackson.core.JsonParser
_features, _requestPayload, DEFAULT_READ_CAPABILITIES -
Constructor Summary
ConstructorsConstructorDescriptionSmileParser(com.fasterxml.jackson.core.io.IOContext ctxt, int parserFeatures, int smileFeatures, com.fasterxml.jackson.core.ObjectCodec codec, com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer sym, InputStream in, byte[] inputBuffer, int start, int end, boolean bufferRecyclable) -
Method Summary
Modifier and TypeMethodDescriptionprivate final String_addDecodedToSymbols(int len, String name) private final com.fasterxml.jackson.core.JsonTokenprotected voidprivate final voidprivate final String_decodeLongUnicodeName(int[] quads, int byteLen, int quadLen, boolean addToSymbolTable) private final voidprivate final String_decodeShortAsciiName(int len) protected final String_decodeShortAsciiValue(int len) private final String_decodeShortUnicodeName(int len) Helper method used to decode short Unicode string, length for which actual length (in bytes) is knownprotected final String_decodeShortUnicodeValue(int byteLen) private final int_decodeUtf8_2(int c) private final int_decodeUtf8_3(int c1) private final int_decodeUtf8_3fast(int c1) private final int_decodeUtf8_4(int c) private final com.fasterxml.jackson.core.JsonTokenprivate final String[]_expandSeenNames(String[] oldShared) Method called to try to expand shared name area to fit one more potentially shared String.private final void_expandSeenStringValues(String newText) private final String_findDecodedFixed12(int len, int q1, int q2) Method for locating names longer than 12 bytes (in UTF-8)private final String_findDecodedFromSymbols(int len) Helper method for trying to find specified encoded UTF-8 byte sequence from symbol table; if successful avoids actual decoding to String.private String_findOrDecodeShortAsciiName(int len) private String_findOrDecodeShortUnicodeName(int len) private final voidprivate final voidprotected byte[]_finishBinary7BitLong(int expLen) private final byte[]protected byte[]_finishBinaryRawLong(int expLen) private final voidprivate final voidprivate final voidprivate final voidprivate final voidprivate final voidprotected final void_finishNumberToken(int tb) protected final voidMethod called to finish parsing of a token so that token contents are retrievableprivate final intprivate final intprivate final byte[]_getBinaryFromString(com.fasterxml.jackson.core.Base64Variant variant) private static int[]_growArrayTo(int[] arr, int minSize) protected final com.fasterxml.jackson.core.JsonTokenMethod that handles initial token type recognition for token that has to be either FIELD_NAME or END_OBJECT.private final Stringprivate final com.fasterxml.jackson.core.JsonToken_handleSharedString(int index) protected final booleanprotected final voidprotected final void_loadToHaveAtLeast(int minAvailable) Helper method that will try to load at least specified number bytes in input buffer, possible moving existing data around if necessary.private com.fasterxml.jackson.core.JsonTokenprivate final byteprivate static final int_padLastQuad(int q, int bytes) private static final int_padQuadForNulls(int firstByte) protected voidprivate final byte[]private void_readBinaryEncoded(OutputStream out, int length, byte[] buffer) protected final intprotected final intprotected voidMethod called to release internal buffers owned by the base reader.protected void_reportIncompleteBinaryRead7Bit(int expLen, int actLen) protected void_reportIncompleteBinaryReadRaw(int expLen, int actLen) protected void_reportInvalidInitial(int mask) protected void_reportInvalidOther(int mask) protected void_reportInvalidOther(int mask, int ptr) protected void_reportInvalidSharedName(int index) protected void_reportInvalidSharedStringValue(int index) protected final void_reportInvalidUnsignedVInt(int firstCh, int lastCh) protected String_reportTruncatedUTF8InName(int strLenBytes, int truncatedCharOffset, int firstUTFByteValue, int bytesExpected) protected String_reportTruncatedUTF8InString(int strLenBytes, int truncatedCharOffset, int firstUTFByteValue, int bytesExpected) private String_reportUnknownNameToken(int ch) private com.fasterxml.jackson.core.JsonToken_reportUnknownValueTypeToken(int ch) protected voidHelper method for skipping length-prefixed binary data sectionprotected void_skipBytes(int len) protected voidMethod called to skip remainders of an incomplete token, when contents themselves will not be needed any moreprotected final int_tryToLoadToHaveAtLeast(int minAvailable) Helper method that will try to load at least specified number bytes in input buffer, possible moving existing data around if necessary.private voidcreateChildArrayContext(int lineNr, int colNr) private voidcreateChildObjectContext(int lineNr, int colNr) voidMethod for forcing full read of current token, even if it might otherwise only be read if data is accessed viagetText()and similar methods.byte[]getBinaryValue(com.fasterxml.jackson.core.Base64Variant b64variant) com.fasterxml.jackson.core.ObjectCodecgetCodec()getText()Method for accessing textual representation of the current event; if no current event (before first call tonextToken(), or after encountering end-of-input), returns null.intchar[]intintgetValueAsString(String defaultValue) protected booleanhandleSignature(boolean consumeFirstByte, boolean throwException) Helper method called when it looks like input might contain the signature; and it is necessary to detect and handle signature to get configuration information it might have.booleanbooleannextFieldName(com.fasterxml.jackson.core.SerializableString str) intnextIntValue(int defaultValue) longnextLongValue(long defaultValue) com.fasterxml.jackson.core.JsonTokenintreadBinaryValue(com.fasterxml.jackson.core.Base64Variant b64variant, OutputStream out) intvoidsetCodec(com.fasterxml.jackson.core.ObjectCodec c) Methods inherited from class SmileParserBase
_handleEOF, _releaseBuffers, _reportMismatchedEndMarker, _sourceReference, close, convertNumberToBigDecimal, convertNumberToBigInteger, convertNumberToDouble, convertNumberToFloat, convertNumberToInt, convertNumberToLong, currentLocation, currentName, currentTokenLocation, getBigIntegerValue, getCurrentLocation, getCurrentName, getDecimalValue, getDoubleValue, getFloatValue, getFormatFeatures, getIntValue, getLongValue, getNumberType, getNumberTypeFP, getNumberValue, getNumberValueExact, getParsingContext, getReadCapabilities, getTokenLocation, isClosed, isNaN, mayContainRawBinary, overrideCurrentName, overrideFormatFeatures, versionMethods inherited from class com.fasterxml.jackson.core.base.ParserMinimalBase
_ascii, _asciiBytes, _constructError, _currentLocationMinusOne, _decodeBase64, _getCharDesc, _hasTextualNull, _longIntegerDesc, _longNumberDesc, _nullSafeUpdateToken, _reportError, _reportError, _reportError, _reportInputCoercion, _reportInvalidEOF, _reportInvalidEOF, _reportInvalidEOFInValue, _reportMissingRootWS, _reportUnexpectedChar, _reportUnexpectedNumberChar, _throwInternal, _throwInternalReturnAny, _throwInvalidSpace, _updateToken, _updateTokenToNA, _updateTokenToNull, _wrapError, clearCurrentToken, currentToken, currentTokenCount, currentTokenId, getCurrentToken, getCurrentTokenId, getLastClearedToken, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, hasCurrentToken, hasToken, hasTokenId, isExpectedNumberIntToken, isExpectedStartArrayToken, isExpectedStartObjectToken, nextValue, reportInvalidNumber, reportOverflowInt, reportOverflowInt, reportOverflowInt, reportOverflowLong, reportOverflowLong, reportOverflowLong, reportUnexpectedNumberChar, skipChildren, streamReadConstraintsMethods inherited from class com.fasterxml.jackson.core.JsonParser
_codec, _constructError, _constructReadException, _constructReadException, _constructReadException, _constructReadException, _constructReadException, _constructReadException, _reportUnsupportedOperation, assignCurrentValue, canParseAsync, canReadObjectId, canReadTypeId, canUseSchema, configure, currentValue, disable, enable, getBinaryValue, getBooleanValue, getByteValue, getCurrentValue, getFeatureMask, getNonBlockingInputFeeder, getNumberValueDeferred, getObjectId, getSchema, getShortValue, getTypeId, getValueAsBoolean, getValueAsDouble, isEnabled, isEnabled, overrideStdFeatures, readBinaryValue, readValueAs, readValueAs, readValueAsTree, readValuesAs, readValuesAs, releaseBuffered, requiresCustomCodec, setCurrentValue, setFeatureMask, setRequestPayloadOnError, setRequestPayloadOnError, setRequestPayloadOnError, setSchema
-
Field Details
-
JDK11_OR_LATER
private static final boolean JDK11_OR_LATERFlag to indicate if the JDK version is 11 or later. This can be used in some methods to choose more optimal behavior. In particular, jdk9+ have different internals for the String class.- Since:
- 2.14.1
-
_objectCodec
protected com.fasterxml.jackson.core.ObjectCodec _objectCodecCodec used for data binding when (if) requested. -
_inputStream
Input stream that can be used for reading more content, if one in use. May be null, if input comes just as a full buffer, or if the stream has been closed. -
_inputBuffer
protected byte[] _inputBufferCurrent buffer from which data is read; generally data is read into buffer from input source, but in some cases pre-loaded buffer is handed to the parser. -
_bufferRecyclable
protected boolean _bufferRecyclableFlag that indicates whether the input buffer is recycable (and needs to be returned to recycler once we are done) or not.If it is not, it also means that parser can NOT modify underlying buffer.
-
_typeAsInt
protected int _typeAsIntType byte of the current token (as in) -
_tokenIncomplete
protected boolean _tokenIncompleteFlag that indicates that the current token has not yet been fully processed, and needs to be finished for some access (or skipped to obtain the next token)
-
-
Constructor Details
-
SmileParser
public SmileParser(com.fasterxml.jackson.core.io.IOContext ctxt, int parserFeatures, int smileFeatures, com.fasterxml.jackson.core.ObjectCodec codec, com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer sym, InputStream in, byte[] inputBuffer, int start, int end, boolean bufferRecyclable)
-
-
Method Details
-
getCodec
public com.fasterxml.jackson.core.ObjectCodec getCodec()- Specified by:
getCodecin classcom.fasterxml.jackson.core.JsonParser
-
setCodec
public void setCodec(com.fasterxml.jackson.core.ObjectCodec c) - Specified by:
setCodecin classcom.fasterxml.jackson.core.JsonParser
-
handleSignature
protected boolean handleSignature(boolean consumeFirstByte, boolean throwException) throws IOException Helper method called when it looks like input might contain the signature; and it is necessary to detect and handle signature to get configuration information it might have.- Returns:
- True if valid signature was found and handled; false if not
- Throws:
IOException
-
releaseBuffered
- Overrides:
releaseBufferedin classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
getInputSource
- Overrides:
getInputSourcein classcom.fasterxml.jackson.core.JsonParser
-
_nextByteGuaranteed
- Throws:
IOException
-
_loadMoreGuaranteed
- Throws:
IOException
-
_loadMore
- Throws:
IOException
-
_loadToHaveAtLeast
Helper method that will try to load at least specified number bytes in input buffer, possible moving existing data around if necessary. Exception throws if not enough content can be read.- Parameters:
minAvailable- Minimum number of bytes we absolutely need- Throws:
IOException- if read failed, either due to I/O issue or because not enough content could be read before end-of-input.
-
_tryToLoadToHaveAtLeast
Helper method that will try to load at least specified number bytes in input buffer, possible moving existing data around if necessary.- Returns:
- Number of bytes that were missing, if any;
0for successful read - Throws:
IOException- Since:
- 2.12.3
-
_closeInput
- Specified by:
_closeInputin classSmileParserBase- Throws:
IOException
-
hasTextCharacters
public boolean hasTextCharacters()- Specified by:
hasTextCharactersin classcom.fasterxml.jackson.core.base.ParserMinimalBase
-
_releaseBuffers2
protected void _releaseBuffers2()Method called to release internal buffers owned by the base reader. This may be called along with_closeInput()(for example, when explicitly closing this reader instance), or separately (if need be).- Specified by:
_releaseBuffers2in classSmileParserBase
-
nextToken
- Specified by:
nextTokenin classcom.fasterxml.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
_reportUnknownValueTypeToken
private com.fasterxml.jackson.core.JsonToken _reportUnknownValueTypeToken(int ch) throws IOException - Throws:
IOException
-
_nextAfterHeader
- Throws:
IOException
-
_addSeenStringValue
- Throws:
IOException
-
_expandSeenStringValues
-
finishToken
Method for forcing full read of current token, even if it might otherwise only be read if data is accessed viagetText()and similar methods.- Overrides:
finishTokenin classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
nextFieldName
- Overrides:
nextFieldNamein classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
nextFieldName
- Overrides:
nextFieldNamein classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
_reportUnknownNameToken
- Throws:
IOException
-
nextTextValue
- Overrides:
nextTextValuein classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
nextIntValue
- Overrides:
nextIntValuein classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
nextLongValue
- Overrides:
nextLongValuein classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
nextBooleanValue
- Overrides:
nextBooleanValuein classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
getText
Method for accessing textual representation of the current event; if no current event (before first call tonextToken(), or after encountering end-of-input), returns null. Method can be called for any event.- Specified by:
getTextin classcom.fasterxml.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
getTextCharacters
- Specified by:
getTextCharactersin classcom.fasterxml.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
getTextLength
- Specified by:
getTextLengthin classcom.fasterxml.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
getTextOffset
- Specified by:
getTextOffsetin classcom.fasterxml.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
getValueAsString
- Overrides:
getValueAsStringin classcom.fasterxml.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
getValueAsString
- Overrides:
getValueAsStringin classcom.fasterxml.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
getText
- Overrides:
getTextin classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
getBinaryValue
public byte[] getBinaryValue(com.fasterxml.jackson.core.Base64Variant b64variant) throws IOException - Specified by:
getBinaryValuein classcom.fasterxml.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
getEmbeddedObject
- Overrides:
getEmbeddedObjectin classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
readBinaryValue
public int readBinaryValue(com.fasterxml.jackson.core.Base64Variant b64variant, OutputStream out) throws IOException - Overrides:
readBinaryValuein classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
_readBinaryEncoded
- Throws:
IOException
-
_getBinaryFromString
private final byte[] _getBinaryFromString(com.fasterxml.jackson.core.Base64Variant variant) throws IOException - Throws:
IOException
-
_handleFieldName
Method that handles initial token type recognition for token that has to be either FIELD_NAME or END_OBJECT.- Throws:
IOException
-
_findOrDecodeShortAsciiName
- Throws:
IOException
-
_findOrDecodeShortUnicodeName
- Throws:
IOException
-
_expandSeenNames
-
_addDecodedToSymbols
- Throws:
IOException
-
_decodeShortAsciiName
- Throws:
IOException
-
_decodeShortUnicodeName
Helper method used to decode short Unicode string, length for which actual length (in bytes) is known- Parameters:
len- Length between 1 and 64- Throws:
IOException
-
_decodeLongUnicodeName
private final String _decodeLongUnicodeName(int[] quads, int byteLen, int quadLen, boolean addToSymbolTable) throws IOException - Throws:
IOException
-
_handleLongFieldName
- Throws:
IOException
-
_findDecodedFromSymbols
Helper method for trying to find specified encoded UTF-8 byte sequence from symbol table; if successful avoids actual decoding to String.NOTE: caller MUST ensure input buffer has enough content.
- Throws:
IOException
-
_findDecodedFixed12
Method for locating names longer than 12 bytes (in UTF-8)- Throws:
IOException
-
_growArrayTo
private static int[] _growArrayTo(int[] arr, int minSize) -
_padLastQuad
private static final int _padLastQuad(int q, int bytes) -
_padQuadForNulls
private static final int _padQuadForNulls(int firstByte) -
_parseNumericValue
- Specified by:
_parseNumericValuein classSmileParserBase- Throws:
IOException
-
_finishToken
Method called to finish parsing of a token so that token contents are retrievable- Throws:
IOException
-
_finishNumberToken
- Throws:
IOException
-
_finishInt
- Throws:
IOException
-
_finishIntSlow
- Throws:
IOException
-
_finishLong
- Throws:
IOException
-
_finishLongSlow
- Throws:
IOException
-
_fourBytesToInt
- Throws:
IOException
-
_fourBytesToIntSlow
- Throws:
IOException
-
_finishBigInteger
- Throws:
IOException
-
_finishFloat
- Throws:
IOException
-
_finishDouble
- Throws:
IOException
-
_finishBigDecimal
- Throws:
IOException
-
_readUnsignedVInt
- Throws:
IOException
-
_readUnsignedVIntSlow
- Throws:
IOException
-
_reportInvalidUnsignedVInt
- Throws:
IOException
-
_decodeShortAsciiValue
- Throws:
IOException
-
_decodeShortUnicodeValue
- Throws:
IOException
-
_decodeLongAsciiValue
- Throws:
IOException
-
_decodeLongUnicodeValue
- Throws:
IOException
-
_finishBinaryRaw
- Throws:
IOException
-
_finishBinaryRawLong
- Throws:
IOException
-
_read7BitBinaryWithLength
- Throws:
IOException
-
_finishBinary7BitLong
- Throws:
IOException
-
_skipIncomplete
Method called to skip remainders of an incomplete token, when contents themselves will not be needed any more- Throws:
IOException
-
_skipBytes
- Throws:
IOException
-
_skip7BitBinary
Helper method for skipping length-prefixed binary data section- Throws:
IOException
-
_decodeUtf8_2
- Throws:
IOException
-
_decodeUtf8_3
- Throws:
IOException
-
_decodeUtf8_3fast
- Throws:
IOException
-
_decodeUtf8_4
- Returns:
- Character value minus 0x10000; this so that caller can readily expand it to actual surrogates
- Throws:
IOException
-
_reportInvalidInitial
protected void _reportInvalidInitial(int mask) throws com.fasterxml.jackson.core.JsonParseException - Throws:
com.fasterxml.jackson.core.JsonParseException
-
_reportInvalidOther
protected void _reportInvalidOther(int mask) throws com.fasterxml.jackson.core.JsonParseException - Throws:
com.fasterxml.jackson.core.JsonParseException
-
_reportInvalidOther
protected void _reportInvalidOther(int mask, int ptr) throws com.fasterxml.jackson.core.JsonParseException - Throws:
com.fasterxml.jackson.core.JsonParseException
-
_reportIncompleteBinaryReadRaw
- Throws:
IOException
-
_reportIncompleteBinaryRead7Bit
- Throws:
IOException
-
_reportTruncatedUTF8InString
protected String _reportTruncatedUTF8InString(int strLenBytes, int truncatedCharOffset, int firstUTFByteValue, int bytesExpected) throws IOException - Throws:
IOException
-
_reportTruncatedUTF8InName
protected String _reportTruncatedUTF8InName(int strLenBytes, int truncatedCharOffset, int firstUTFByteValue, int bytesExpected) throws IOException - Throws:
IOException
-
_eofAsNextToken
- Throws:
IOException
-
createChildArrayContext
- Throws:
IOException
-
createChildObjectContext
- Throws:
IOException
-