Class NonBlockingUtf8JsonParserBase

  • All Implemented Interfaces:
    Versioned, java.io.Closeable, java.lang.AutoCloseable
    Direct Known Subclasses:
    NonBlockingByteBufferJsonParser, NonBlockingJsonParser

    public abstract class NonBlockingUtf8JsonParserBase
    extends NonBlockingJsonParserBase
    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.

    Since:
    2.9
    • Field Detail

      • 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 _origBufferLen
        In 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.
    • Method Detail

      • needMoreInput

        public final boolean needMoreInput()
      • endOfInput

        public void endOfInput()
      • _decodeEscaped

        protected char _decodeEscaped()
                               throws java.io.IOException
        Description copied from class: ParserBase
        Method 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:
        _decodeEscaped in class ParserBase
        Returns:
        Character decoded, if any
        Throws:
        java.io.IOException - If escape decoding fails
      • nextToken

        public JsonToken nextToken()
                            throws java.io.IOException
        Description copied from class: JsonParser
        Main 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:
        nextToken in class ParserMinimalBase
        Returns:
        Next token from the stream, if any found, or null to indicate end-of-input
        Throws:
        java.io.IOException - for low-level read issues, or JsonParseException for decoding problems
      • 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

        protected final JsonToken _finishToken()
                                        throws java.io.IOException
        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_AVAILABLE if not
        Throws:
        java.io.IOException - (generally JsonParseException) for decoding problems
      • _finishTokenWithEOF

        protected final JsonToken _finishTokenWithEOF()
                                               throws java.io.IOException
        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_AVAILABLE if not
        Throws:
        java.io.IOException - (generally JsonParseException) for decoding problems
      • _startDocument

        private final JsonToken _startDocument​(int ch)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishBOM

        private final JsonToken _finishBOM​(int bytesHandled)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • _startFieldName

        private final JsonToken _startFieldName​(int ch)
                                         throws java.io.IOException
        Method that handles initial token type recognition for token that has to be either FIELD_NAME or END_OBJECT.
        Throws:
        java.io.IOException
      • _startFieldNameAfterComma

        private final JsonToken _startFieldNameAfterComma​(int ch)
                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • _startValue

        private final JsonToken _startValue​(int ch)
                                     throws java.io.IOException
        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:
        java.io.IOException
      • _startValueExpectComma

        private final JsonToken _startValueExpectComma​(int ch)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • _startValueExpectColon

        private final JsonToken _startValueExpectColon​(int ch)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • _startValueAfterComma

        private final JsonToken _startValueAfterComma​(int ch)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • _startUnexpectedValue

        protected JsonToken _startUnexpectedValue​(boolean leadingComma,
                                                  int ch)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • _skipWS

        private final int _skipWS​(int ch)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • _startSlashComment

        private final JsonToken _startSlashComment​(int fromMinorState)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishHashComment

        private final JsonToken _finishHashComment​(int fromMinorState)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishCppComment

        private final JsonToken _finishCppComment​(int fromMinorState)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishCComment

        private final JsonToken _finishCComment​(int fromMinorState,
                                                boolean gotStar)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • _startAfterComment

        private final JsonToken _startAfterComment​(int fromMinorState)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • _startFalseToken

        protected JsonToken _startFalseToken()
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • _startTrueToken

        protected JsonToken _startTrueToken()
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • _startNullToken

        protected JsonToken _startNullToken()
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishKeywordToken

        protected JsonToken _finishKeywordToken​(java.lang.String expToken,
                                                int matched,
                                                JsonToken result)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishKeywordTokenWithEOF

        protected JsonToken _finishKeywordTokenWithEOF​(java.lang.String expToken,
                                                       int matched,
                                                       JsonToken result)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishNonStdToken

        protected JsonToken _finishNonStdToken​(int type,
                                               int matched)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishNonStdTokenWithEOF

        protected JsonToken _finishNonStdTokenWithEOF​(int type,
                                                      int matched)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishErrorToken

        protected JsonToken _finishErrorToken()
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishErrorTokenWithEOF

        protected JsonToken _finishErrorTokenWithEOF()
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • _reportErrorToken

        protected JsonToken _reportErrorToken​(java.lang.String actualToken)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • _startFloatThatStartsWithPeriod

        protected JsonToken _startFloatThatStartsWithPeriod()
                                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • _startPositiveNumber

        protected JsonToken _startPositiveNumber​(int ch)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • _startNegativeNumber

        protected JsonToken _startNegativeNumber()
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • _startPositiveNumber

        protected JsonToken _startPositiveNumber()
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • _startNumberLeadingZero

        protected JsonToken _startNumberLeadingZero()
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishNumberMinus

        protected JsonToken _finishNumberMinus​(int ch)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishNumberPlus

        protected JsonToken _finishNumberPlus​(int ch)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishNumberPlusMinus

        protected JsonToken _finishNumberPlusMinus​(int ch,
                                                   boolean negative)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishNumberLeadingZeroes

        protected JsonToken _finishNumberLeadingZeroes()
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishNumberLeadingNegZeroes

        protected JsonToken _finishNumberLeadingNegZeroes()
                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishNumberLeadingPosZeroes

        protected JsonToken _finishNumberLeadingPosZeroes()
                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishNumberLeadingPosNegZeroes

        protected JsonToken _finishNumberLeadingPosNegZeroes​(boolean negative)
                                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishNumberIntegralPart

        protected JsonToken _finishNumberIntegralPart​(char[] outBuf,
                                                      int outPtr)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • _startFloat

        protected JsonToken _startFloat​(char[] outBuf,
                                        int outPtr,
                                        int ch)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishFloatFraction

        protected JsonToken _finishFloatFraction()
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishFloatExponent

        protected JsonToken _finishFloatExponent​(boolean checkSign,
                                                 int ch)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • _fastParseName

        private final java.lang.String _fastParseName()
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • _parseMediumName

        private final java.lang.String _parseMediumName​(int ptr,
                                                        int q2)
                                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • _parseMediumName2

        private final java.lang.String _parseMediumName2​(int ptr,
                                                         int q3,
                                                         int q2)
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • _parseEscapedName

        private final JsonToken _parseEscapedName​(int qlen,
                                                  int currQuad,
                                                  int currQuadBytes)
                                           throws java.io.IOException
        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:
        java.io.IOException
      • _handleOddName

        private JsonToken _handleOddName​(int ch)
                                  throws java.io.IOException
        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:
        java.io.IOException
      • _finishUnquotedName

        private JsonToken _finishUnquotedName​(int qlen,
                                              int currQuad,
                                              int currQuadBytes)
                                       throws java.io.IOException
        Parsing of optionally supported non-standard "unquoted" names: names without either double-quotes or apostrophes surrounding them. Unlike other
        Throws:
        java.io.IOException
      • _finishAposName

        private JsonToken _finishAposName​(int qlen,
                                          int currQuad,
                                          int currQuadBytes)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishFieldWithEscape

        protected final JsonToken _finishFieldWithEscape()
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • _decodeSplitEscaped

        private int _decodeSplitEscaped​(int value,
                                        int bytesRead)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • _startString

        protected JsonToken _startString()
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishRegularString

        private final JsonToken _finishRegularString()
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • _startAposString

        protected JsonToken _startAposString()
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • _finishAposString

        private final JsonToken _finishAposString()
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • _decodeSplitMultiByte

        private final boolean _decodeSplitMultiByte​(int c,
                                                    int type,
                                                    boolean gotNext)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • _decodeSplitUTF8_3

        private final boolean _decodeSplitUTF8_3​(int prev,
                                                 int prevCount,
                                                 int next)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • _decodeSplitUTF8_4

        private final boolean _decodeSplitUTF8_4​(int prev,
                                                 int prevCount,
                                                 int next)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • _decodeCharEscape

        private final int _decodeCharEscape()
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • _decodeFastCharEscape

        private final int _decodeFastCharEscape()
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • _decodeUTF8_2

        private final int _decodeUTF8_2​(int c,
                                        int d)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • _decodeUTF8_3

        private final int _decodeUTF8_3​(int c,
                                        int d,
                                        int e)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • _decodeUTF8_4

        private final int _decodeUTF8_4​(int c,
                                        int d,
                                        int e,
                                        int f)
                                 throws java.io.IOException
        Throws:
        java.io.IOException