Class SmileParser

java.lang.Object
tools.jackson.core.JsonParser
tools.jackson.core.base.ParserMinimalBase
tools.jackson.dataformat.smile.SmileParserBase
tools.jackson.dataformat.smile.SmileParser
All Implemented Interfaces:
Closeable, AutoCloseable, tools.jackson.core.Versioned

public class SmileParser extends SmileParserBase
  • Field Details

    • JDK11_OR_LATER

      private static final boolean JDK11_OR_LATER
      Flag 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.
    • _inputStream

      protected InputStream _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[] _inputBuffer
      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.
    • _bufferRecyclable

      protected boolean _bufferRecyclable
      Flag 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 _typeAsInt
      Type byte of the current token (as in)
    • _tokenIncomplete

      protected boolean _tokenIncomplete
      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)
  • Constructor Details

    • SmileParser

      public SmileParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ctxt, int parserFeatures, int smileFeatures, tools.jackson.core.sym.ByteQuadsCanonicalizer sym, InputStream in, byte[] inputBuffer, int start, int end, boolean bufferRecyclable)
  • Method Details

    • handleSignature

      protected boolean handleSignature(boolean consumeFirstByte, boolean throwException) throws tools.jackson.core.JacksonException
      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:
      tools.jackson.core.JacksonException
    • releaseBuffered

      public int releaseBuffered(OutputStream out) throws tools.jackson.core.JacksonException
      Overrides:
      releaseBuffered in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • streamReadInputSource

      public Object streamReadInputSource()
      Specified by:
      streamReadInputSource in class tools.jackson.core.JsonParser
    • _nextByteGuaranteed

      private final byte _nextByteGuaranteed() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _loadMoreGuaranteed

      protected final void _loadMoreGuaranteed() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _loadMore

      protected final boolean _loadMore() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _loadToHaveAtLeast

      protected final void _loadToHaveAtLeast(int minAvailable) throws tools.jackson.core.JacksonException
      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:
      tools.jackson.core.JacksonException - if read failed, either due to I/O issue or because not enough content could be read before end-of-input.
    • _tryToLoadToHaveAtLeast

      protected final int _tryToLoadToHaveAtLeast(int minAvailable) throws tools.jackson.core.JacksonException
      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:
      tools.jackson.core.JacksonException
    • _closeInput

      protected void _closeInput()
      Specified by:
      _closeInput in class SmileParserBase
    • hasStringCharacters

      public boolean hasStringCharacters()
      Specified by:
      hasStringCharacters in class tools.jackson.core.JsonParser
    • _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 class SmileParserBase
    • nextToken

      public tools.jackson.core.JsonToken nextToken() throws tools.jackson.core.JacksonException
      Specified by:
      nextToken in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • _reportUnknownValueTypeToken

      private tools.jackson.core.JsonToken _reportUnknownValueTypeToken(int ch) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _nextAfterHeader

      private tools.jackson.core.JsonToken _nextAfterHeader() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _handleSharedString

      private final tools.jackson.core.JsonToken _handleSharedString(int index) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _addSeenStringValue

      private final tools.jackson.core.JsonToken _addSeenStringValue() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _expandSeenStringValues

      private final void _expandSeenStringValues(String newText)
    • finishToken

      public void finishToken()
      Method for forcing full read of current token, even if it might otherwise only be read if data is accessed via getString() and similar methods.
      Overrides:
      finishToken in class tools.jackson.core.base.ParserMinimalBase
    • nextName

      public String nextName() throws tools.jackson.core.JacksonException
      Overrides:
      nextName in class tools.jackson.core.base.ParserMinimalBase
      Throws:
      tools.jackson.core.JacksonException
    • nextName

      public boolean nextName(tools.jackson.core.SerializableString str) throws tools.jackson.core.JacksonException
      Overrides:
      nextName in class tools.jackson.core.base.ParserMinimalBase
      Throws:
      tools.jackson.core.JacksonException
    • nextNameMatch

      public int nextNameMatch(tools.jackson.core.sym.PropertyNameMatcher matcher) throws tools.jackson.core.JacksonException
      Overrides:
      nextNameMatch in class tools.jackson.core.base.ParserMinimalBase
      Throws:
      tools.jackson.core.JacksonException
    • _nextNameOptimized

      private final int _nextNameOptimized(tools.jackson.core.sym.PropertyNameMatcher matcher, int len) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _nextNameFromSymbolsLong

      private final int _nextNameFromSymbolsLong(tools.jackson.core.sym.PropertyNameMatcher matcher, int len, int q1, int q2) throws tools.jackson.core.JacksonException
      Method for locating names longer than 8 bytes (in UTF-8)
      Throws:
      tools.jackson.core.JacksonException
    • _nextNameAsciiDecodeAndAdd

      private int _nextNameAsciiDecodeAndAdd(tools.jackson.core.sym.PropertyNameMatcher matcher, int len) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _nextNameUnicodeDecodeAndAdd

      private int _nextNameUnicodeDecodeAndAdd(tools.jackson.core.sym.PropertyNameMatcher matcher, int lenMarker) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • nextStringValue

      public String nextStringValue() throws tools.jackson.core.JacksonException
      Overrides:
      nextStringValue in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • nextIntValue

      public int nextIntValue(int defaultValue) throws tools.jackson.core.JacksonException
      Overrides:
      nextIntValue in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • nextLongValue

      public long nextLongValue(long defaultValue) throws tools.jackson.core.JacksonException
      Overrides:
      nextLongValue in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • nextBooleanValue

      public Boolean nextBooleanValue() throws tools.jackson.core.JacksonException
      Overrides:
      nextBooleanValue in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getString

      public String getString() throws tools.jackson.core.JacksonException
      Method for accessing textual representation of the current event; if no current event (before first call to nextToken(), or after encountering end-of-input), returns null. Method can be called for any event.
      Specified by:
      getString in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getStringCharacters

      public char[] getStringCharacters() throws tools.jackson.core.JacksonException
      Specified by:
      getStringCharacters in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getStringLength

      public int getStringLength() throws tools.jackson.core.JacksonException
      Specified by:
      getStringLength in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getStringOffset

      public int getStringOffset() throws tools.jackson.core.JacksonException
      Specified by:
      getStringOffset in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getValueAsString

      public String getValueAsString() throws tools.jackson.core.JacksonException
      Overrides:
      getValueAsString in class tools.jackson.core.base.ParserMinimalBase
      Throws:
      tools.jackson.core.JacksonException
    • getValueAsString

      public String getValueAsString(String defaultValue) throws tools.jackson.core.JacksonException
      Overrides:
      getValueAsString in class tools.jackson.core.base.ParserMinimalBase
      Throws:
      tools.jackson.core.JacksonException
    • getString

      public int getString(Writer writer) throws tools.jackson.core.JacksonException
      Overrides:
      getString in class tools.jackson.core.base.ParserMinimalBase
      Throws:
      tools.jackson.core.JacksonException
    • getBinaryValue

      public byte[] getBinaryValue(tools.jackson.core.Base64Variant b64variant) throws tools.jackson.core.JacksonException
      Specified by:
      getBinaryValue in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getEmbeddedObject

      public Object getEmbeddedObject() throws tools.jackson.core.JacksonException
      Overrides:
      getEmbeddedObject in class tools.jackson.core.base.ParserMinimalBase
      Throws:
      tools.jackson.core.JacksonException
    • readBinaryValue

      public int readBinaryValue(tools.jackson.core.Base64Variant b64variant, OutputStream out) throws tools.jackson.core.JacksonException
      Overrides:
      readBinaryValue in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • _readBinaryEncoded

      private void _readBinaryEncoded(OutputStream out, int length, byte[] buffer) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _getBinaryFromString

      private final byte[] _getBinaryFromString(tools.jackson.core.Base64Variant variant) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _handlePropertyName

      protected final tools.jackson.core.JsonToken _handlePropertyName() throws tools.jackson.core.JacksonException
      Method that handles initial token type recognition for token that has to be either PROPERTY_NAME or END_OBJECT.
      Throws:
      tools.jackson.core.JacksonException
    • _findOrDecodeShortAsciiName

      private String _findOrDecodeShortAsciiName(int len) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _findOrDecodeShortUnicodeName

      private String _findOrDecodeShortUnicodeName(int len) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _expandSeenNames

      private final String[] _expandSeenNames(String[] oldShared)
      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

      private final String _addDecodedToSymbols(int len, String name)
    • _decodeShortAsciiName

      private final String _decodeShortAsciiName(int len) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _decodeShortUnicodeName

      private final String _decodeShortUnicodeName(int len) throws tools.jackson.core.JacksonException
      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:
      tools.jackson.core.JacksonException
    • _decodeLongUnicodeName

      private final String _decodeLongUnicodeName(int[] quads, int byteLen, int quadLen, boolean addToSymbolTable) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _handleLongFieldName

      private final String _handleLongFieldName() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _findDecodedFromSymbols

      private final String _findDecodedFromSymbols(int len) throws tools.jackson.core.JacksonException
      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:
      tools.jackson.core.JacksonException
    • _findDecodedFixed12

      private final String _findDecodedFixed12(int len, int q1, int q2) throws tools.jackson.core.JacksonException
      Method for locating names longer than 12 bytes (in UTF-8)
      Throws:
      tools.jackson.core.JacksonException
    • _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

      protected void _parseNumericValue() throws tools.jackson.core.JacksonException
      Description copied from class: SmileParserBase
      Method called to complete parsing of a numeric value: will throw StreamReadException if current token is not numeric.
      Specified by:
      _parseNumericValue in class SmileParserBase
      Throws:
      tools.jackson.core.JacksonException
    • _parseNumericValueIfNumber

      protected boolean _parseNumericValueIfNumber() throws tools.jackson.core.JacksonException
      Description copied from class: SmileParserBase
      Similar to SmileParserBase._parseNumericValue(), but will not throw exception if the current token is not a numeric value.
      Specified by:
      _parseNumericValueIfNumber in class SmileParserBase
      Returns:
      true if current token is numeric; false otherwise
      Throws:
      tools.jackson.core.JacksonException
    • _finishToken

      protected final void _finishToken() throws tools.jackson.core.JacksonException
      Method called to finish parsing of a token so that token contents are retrievable
      Throws:
      tools.jackson.core.JacksonException
    • _finishNumberToken

      protected final void _finishNumberToken(int tb) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _finishInt

      private final void _finishInt() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _finishIntSlow

      private final void _finishIntSlow() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _finishLong

      private final void _finishLong() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _finishLongSlow

      private final void _finishLongSlow() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _fourBytesToInt

      private final int _fourBytesToInt() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _fourBytesToIntSlow

      private final int _fourBytesToIntSlow() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _finishBigInteger

      private final void _finishBigInteger() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _finishFloat

      private final void _finishFloat() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _finishDouble

      private final void _finishDouble() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _finishBigDecimal

      private final void _finishBigDecimal() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _readUnsignedVInt

      protected final int _readUnsignedVInt() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _readUnsignedVIntSlow

      protected final int _readUnsignedVIntSlow() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _reportInvalidUnsignedVInt

      protected final void _reportInvalidUnsignedVInt(int firstCh, int lastCh) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _decodeShortAsciiValue

      protected final String _decodeShortAsciiValue(int len) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _decodeShortUnicodeValue

      protected final String _decodeShortUnicodeValue(int byteLen) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _decodeLongAsciiValue

      private final void _decodeLongAsciiValue() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _decodeLongUnicodeValue

      private final void _decodeLongUnicodeValue() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _finishBinaryRaw

      private final byte[] _finishBinaryRaw() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _finishBinaryRawLong

      protected byte[] _finishBinaryRawLong(int expLen) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _read7BitBinaryWithLength

      private final byte[] _read7BitBinaryWithLength() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _finishBinary7BitLong

      protected byte[] _finishBinary7BitLong(int expLen) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _skipIncomplete

      protected void _skipIncomplete() throws tools.jackson.core.JacksonException
      Method called to skip remainders of an incomplete token, when contents themselves will not be needed any more
      Throws:
      tools.jackson.core.JacksonException
    • _skipBytes

      protected void _skipBytes(int len) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _skip7BitBinary

      protected void _skip7BitBinary() throws tools.jackson.core.JacksonException
      Helper method for skipping length-prefixed binary data section
      Throws:
      tools.jackson.core.JacksonException
    • _decodeUtf8_2

      private final int _decodeUtf8_2(int c) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _decodeUtf8_3

      private final int _decodeUtf8_3(int c1) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _decodeUtf8_3fast

      private final int _decodeUtf8_3fast(int c1) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _decodeUtf8_4

      private final int _decodeUtf8_4(int c) throws tools.jackson.core.JacksonException
      Returns:
      Character value minus 0x10000; this so that caller can readily expand it to actual surrogates
      Throws:
      tools.jackson.core.JacksonException
    • _reportInvalidSharedName

      protected void _reportInvalidSharedName(int index) throws tools.jackson.core.exc.StreamReadException
      Throws:
      tools.jackson.core.exc.StreamReadException
    • _reportInvalidSharedStringValue

      protected void _reportInvalidSharedStringValue(int index) throws tools.jackson.core.exc.StreamReadException
      Throws:
      tools.jackson.core.exc.StreamReadException
    • _reportInvalidInitial

      protected void _reportInvalidInitial(int mask) throws tools.jackson.core.exc.StreamReadException
      Throws:
      tools.jackson.core.exc.StreamReadException
    • _reportInvalidOther

      protected void _reportInvalidOther(int mask, int ptr) throws tools.jackson.core.exc.StreamReadException
      Throws:
      tools.jackson.core.exc.StreamReadException
    • _reportInvalidOther

      protected void _reportInvalidOther(int mask) throws tools.jackson.core.exc.StreamReadException
      Throws:
      tools.jackson.core.exc.StreamReadException
    • _reportIncompleteBinaryReadRaw

      protected void _reportIncompleteBinaryReadRaw(int expLen, int actLen) throws tools.jackson.core.exc.StreamReadException
      Throws:
      tools.jackson.core.exc.StreamReadException
    • _reportIncompleteBinaryRead7Bit

      protected void _reportIncompleteBinaryRead7Bit(int expLen, int actLen) throws tools.jackson.core.exc.StreamReadException
      Throws:
      tools.jackson.core.exc.StreamReadException
    • _reportTruncatedUTF8InString

      protected String _reportTruncatedUTF8InString(int strLenBytes, int truncatedCharOffset, int firstUTFByteValue, int bytesExpected) throws tools.jackson.core.exc.StreamReadException
      Throws:
      tools.jackson.core.exc.StreamReadException
    • _reportTruncatedUTF8InName

      protected String _reportTruncatedUTF8InName(int strLenBytes, int truncatedCharOffset, int firstUTFByteValue, int bytesExpected) throws tools.jackson.core.exc.StreamReadException
      Throws:
      tools.jackson.core.exc.StreamReadException
    • _eofAsNextToken

      private final tools.jackson.core.JsonToken _eofAsNextToken() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • createChildArrayContext

      private void createChildArrayContext(int lineNr, int colNr) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • createChildObjectContext

      private void createChildObjectContext(int lineNr, int colNr) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException