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 enum
Enumeration 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 boolean
Flag 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 InputStream
Input stream that can be used for reading more content, if one in use.protected com.fasterxml.jackson.core.ObjectCodec
Codec used for data binding when (if) requested.protected boolean
Flag 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 int
Type byte of the current token (as in)private static final boolean
Flag to indicate if the JDK version is 11 or later.Fields inherited from class com.fasterxml.jackson.dataformat.smile.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, _streamReadConstraints, _streamReadContext, _symbols, _symbolsCanonical, _textBuffer, _tokenOffsetForTotal, DEFAULT_NAME_BUFFER_LENGTH, DEFAULT_STRING_VALUE_BUFFER_LENGTH, LONGEST_NON_CHUNKED_BINARY, NO_STRINGS, SMILE_READ_CAPABILITIES
Fields inherited from class com.fasterxml.jackson.core.base.ParserMinimalBase
_currToken, _lastClearedToken, 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_UNKNOWN
Fields 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.JsonToken
protected void
private final void
private final String
_decodeLongUnicodeName
(int[] quads, int byteLen, int quadLen, boolean addToSymbolTable) private final void
private 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.JsonToken
private 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 void
private final void
protected byte[]
_finishBinary7BitLong
(int expLen) private final byte[]
protected byte[]
_finishBinaryRawLong
(int expLen) private final void
private final void
private final void
private final void
private final void
private final void
protected final void
_finishNumberToken
(int tb) protected final void
Method called to finish parsing of a token so that token contents are retrievableprivate final int
private final int
private final byte[]
_getBinaryFromString
(com.fasterxml.jackson.core.Base64Variant variant) private static int[]
_growArrayTo
(int[] arr, int minSize) protected final com.fasterxml.jackson.core.JsonToken
Method that handles initial token type recognition for token that has to be either FIELD_NAME or END_OBJECT.private final String
private final com.fasterxml.jackson.core.JsonToken
_handleSharedString
(int index) protected final boolean
protected final void
protected 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.JsonToken
private final byte
private static final int
_padLastQuad
(int q, int bytes) private static final int
_padQuadForNulls
(int firstByte) protected void
private final byte[]
private void
_readBinaryEncoded
(OutputStream out, int length, byte[] buffer) protected final int
protected final int
protected void
Method 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 void
Helper method for skipping length-prefixed binary data sectionprotected void
_skipBytes
(int len) protected void
Method 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 void
createChildArrayContext
(int lineNr, int colNr) private void
createChildObjectContext
(int lineNr, int colNr) void
Method 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.ObjectCodec
getCodec()
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.int
char[]
int
int
getValueAsString
(String defaultValue) protected boolean
handleSignature
(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.boolean
boolean
nextFieldName
(com.fasterxml.jackson.core.SerializableString str) int
nextIntValue
(int defaultValue) long
nextLongValue
(long defaultValue) com.fasterxml.jackson.core.JsonToken
int
readBinaryValue
(com.fasterxml.jackson.core.Base64Variant b64variant, OutputStream out) int
void
setCodec
(com.fasterxml.jackson.core.ObjectCodec c) Methods inherited from class com.fasterxml.jackson.dataformat.smile.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, streamReadConstraints, version
Methods inherited from class com.fasterxml.jackson.core.base.ParserMinimalBase
_ascii, _asciiBytes, _constructError, _currentLocationMinusOne, _decodeBase64, _getCharDesc, _hasTextualNull, _longIntegerDesc, _longNumberDesc, _reportError, _reportError, _reportError, _reportInputCoercion, _reportInvalidEOF, _reportInvalidEOF, _reportInvalidEOFInValue, _reportMissingRootWS, _reportUnexpectedChar, _reportUnexpectedNumberChar, _throwInternal, _throwInternalReturnAny, _throwInvalidSpace, _wrapError, clearCurrentToken, currentToken, 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
Methods 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:
getCodec
in classcom.fasterxml.jackson.core.JsonParser
-
setCodec
public void setCodec(com.fasterxml.jackson.core.ObjectCodec c) - Specified by:
setCodec
in 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:
releaseBuffered
in classcom.fasterxml.jackson.core.JsonParser
- Throws:
IOException
-
getInputSource
- Overrides:
getInputSource
in 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;
0
for successful read - Throws:
IOException
- Since:
- 2.12.3
-
_closeInput
- Specified by:
_closeInput
in classSmileParserBase
- Throws:
IOException
-
hasTextCharacters
public boolean hasTextCharacters()- Specified by:
hasTextCharacters
in 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:
_releaseBuffers2
in classSmileParserBase
-
nextToken
- Specified by:
nextToken
in 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:
finishToken
in classcom.fasterxml.jackson.core.JsonParser
- Throws:
IOException
-
nextFieldName
- Overrides:
nextFieldName
in classcom.fasterxml.jackson.core.JsonParser
- Throws:
IOException
-
nextFieldName
- Overrides:
nextFieldName
in classcom.fasterxml.jackson.core.JsonParser
- Throws:
IOException
-
_reportUnknownNameToken
- Throws:
IOException
-
nextTextValue
- Overrides:
nextTextValue
in classcom.fasterxml.jackson.core.JsonParser
- Throws:
IOException
-
nextIntValue
- Overrides:
nextIntValue
in classcom.fasterxml.jackson.core.JsonParser
- Throws:
IOException
-
nextLongValue
- Overrides:
nextLongValue
in classcom.fasterxml.jackson.core.JsonParser
- Throws:
IOException
-
nextBooleanValue
- Overrides:
nextBooleanValue
in 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:
getText
in classcom.fasterxml.jackson.core.base.ParserMinimalBase
- Throws:
IOException
-
getTextCharacters
- Specified by:
getTextCharacters
in classcom.fasterxml.jackson.core.base.ParserMinimalBase
- Throws:
IOException
-
getTextLength
- Specified by:
getTextLength
in classcom.fasterxml.jackson.core.base.ParserMinimalBase
- Throws:
IOException
-
getTextOffset
- Specified by:
getTextOffset
in classcom.fasterxml.jackson.core.base.ParserMinimalBase
- Throws:
IOException
-
getValueAsString
- Overrides:
getValueAsString
in classcom.fasterxml.jackson.core.base.ParserMinimalBase
- Throws:
IOException
-
getValueAsString
- Overrides:
getValueAsString
in classcom.fasterxml.jackson.core.base.ParserMinimalBase
- Throws:
IOException
-
getText
- Overrides:
getText
in classcom.fasterxml.jackson.core.JsonParser
- Throws:
IOException
-
getBinaryValue
public byte[] getBinaryValue(com.fasterxml.jackson.core.Base64Variant b64variant) throws IOException - Specified by:
getBinaryValue
in classcom.fasterxml.jackson.core.base.ParserMinimalBase
- Throws:
IOException
-
getEmbeddedObject
- Overrides:
getEmbeddedObject
in classcom.fasterxml.jackson.core.JsonParser
- Throws:
IOException
-
readBinaryValue
public int readBinaryValue(com.fasterxml.jackson.core.Base64Variant b64variant, OutputStream out) throws IOException - Overrides:
readBinaryValue
in 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
Method called to try to expand shared name area to fit one more potentially shared String. If area is already at its biggest size, will just clear the area (by setting next-offset to 0) -
_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:
_parseNumericValue
in 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
-