Package: org.apache.groovy.json.internal

## [Java] Class BaseJsonParser

- org.apache.groovy.json.internal.BaseJsonParser

- All Implemented Interfaces and Traits:
    JsonParser

      public abstract class BaseJsonParser
      extends Object
      implements JsonParser

  Base JSON parser. Scaled down version of Boon JsonParser with features removed that are JDK 1.7 dependent or Groovy duplicated functionality.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected static int` | `ALPHA_0` | Character code for digit `0`.
    `protected static int` | `ALPHA_1` | Character code for digit `1`.
    `protected static int` | `ALPHA_2` | Character code for digit `2`.
    `protected static int` | `ALPHA_3` | Character code for digit `3`.
    `protected static int` | `ALPHA_4` | Character code for digit `4`.
    `protected static int` | `ALPHA_5` | Character code for digit `5`.
    `protected static int` | `ALPHA_6` | Character code for digit `6`.
    `protected static int` | `ALPHA_7` | Character code for digit `7`.
    `protected static int` | `ALPHA_8` | Character code for digit `8`.
    `protected static int` | `ALPHA_9` | Character code for digit `9`.
    `protected static int` | `CLOSED_BRACKET` | Character code for the closing array delimiter `]`.
    `protected static int` | `CLOSED_CURLY` | Character code for the closing object delimiter ``}.
    `protected static int` | `COLON` | Character code for the `:` name/value separator.
    `protected static int` | `COMMA` | Character code for the `,` element separator.
    `protected static int` | `DECIMAL_POINT` | Character code for the decimal point in number literals.
    `protected static int` | `DOUBLE_QUOTE` | Character code for the JSON string delimiter `"`.
    `protected static int` | `ESCAPE` | Character code for the JSON escape marker `\`.
    `protected static int` | `LETTER_BIG_E` | Uppercase exponent marker used in JSON numbers.
    `protected static int` | `LETTER_E` | Lowercase exponent marker used in JSON numbers.
    `protected static int` | `MINUS` | Character code for the minus sign in number literals.
    `protected static int` | `PLUS` | Character code for the plus sign in exponent literals.
    `protected int` | `bufSize` | Initial buffer size used when reading character streams.
    `protected String` | `charset` | Charset used for byte-based input when no override is supplied.
    `protected static boolean` | `internKeys` | Whether parsed object keys should be interned.
    `protected static ConcurrentHashMap<String, String>` | `internedKeysCache` | Cache used when key interning is enabled.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected String` | `charDescription(int c)` Builds a readable description of a character code for parser errors.
    `` | `protected static int` | `findEndQuote(char[] array, int index)` Finds the closing quote of a JSON string while honoring escapes.
    `` | `protected static boolean` | `hasEscapeChar(char[] array, int index, int[] indexHolder)` Scans a string body until it finds an escape or the closing quote.
    `` | `protected static boolean` | `isDecimalChar(int currentChar)` Checks whether a character can appear in a decimal JSON number.
    `` | `protected static boolean` | `isDelimiter(int c)` Checks whether a character terminates the current JSON value.
    `` | `protected static final boolean` | `isDoubleQuote(int c)` Checks whether a character code is a double quote.
    `` | `protected static final boolean` | `isEscape(int c)` Checks whether a character code is the JSON escape marker.
    `` | `protected static final boolean` | `isNumberDigit(int c)` Checks whether a character code is an ASCII digit.
    `` | `public Object` | `parse(String jsonString)` Parses a JSON string.
    `` | `public Object` | `parse(byte[] bytes)` Parses JSON bytes using the parser's configured charset.
    `` | `public Object` | `parse(byte[] bytes, String charset)` Parses JSON bytes using the supplied charset.
    `` | `public Object` | `parse(CharSequence charSequence)` Parses JSON from a character sequence.
    `` | `public Object` | `parse(Reader reader)` Parses JSON from a reader.
    `` | `public Object` | `parse(InputStream input)` Parses JSON from a byte stream using the configured charset.
    `` | `public Object` | `parse(InputStream input, String charset)` Parses JSON from a byte stream using the supplied charset.
    `` | `public Object` | `parse(File file, String charset)` Parses JSON from a file.
    `` | `public void` | `setCharset(String charset)` Sets the default charset used for byte and stream input.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### protected static final int ALPHA_0

      Character code for digit `0`.

    - #### protected static final int ALPHA_1

      Character code for digit `1`.

    - #### protected static final int ALPHA_2

      Character code for digit `2`.

    - #### protected static final int ALPHA_3

      Character code for digit `3`.

    - #### protected static final int ALPHA_4

      Character code for digit `4`.

    - #### protected static final int ALPHA_5

      Character code for digit `5`.

    - #### protected static final int ALPHA_6

      Character code for digit `6`.

    - #### protected static final int ALPHA_7

      Character code for digit `7`.

    - #### protected static final int ALPHA_8

      Character code for digit `8`.

    - #### protected static final int ALPHA_9

      Character code for digit `9`.

    - #### protected static final int CLOSED_BRACKET

      Character code for the closing array delimiter `]`.

    - #### protected static final int CLOSED_CURLY

      Character code for the closing object delimiter ``}.

    - #### protected static final int COLON

      Character code for the `:` name/value separator.

    - #### protected static final int COMMA

      Character code for the `,` element separator.

    - #### protected static final int DECIMAL_POINT

      Character code for the decimal point in number literals.

    - #### protected static final int DOUBLE_QUOTE

      Character code for the JSON string delimiter `"`.

    - #### protected static final int ESCAPE

      Character code for the JSON escape marker `\`.

    - #### protected static final int LETTER_BIG_E

      Uppercase exponent marker used in JSON numbers.

    - #### protected static final int LETTER_E

      Lowercase exponent marker used in JSON numbers.

    - #### protected static final int MINUS

      Character code for the minus sign in number literals.

    - #### protected static final int PLUS

      Character code for the plus sign in exponent literals.

    - #### protected int bufSize

      Initial buffer size used when reading character streams.

    - #### protected String charset

      Charset used for byte-based input when no override is supplied.

    - #### protected static final boolean internKeys

      Whether parsed object keys should be interned.

    - #### protected static final ConcurrentHashMap<String, String> internedKeysCache

      Cache used when key interning is enabled.

  - ### Method Detail

    - #### protected String charDescription(int c)

      Builds a readable description of a character code for parser errors.

      Parameters:
        `c` - character code to describe
      Returns:
        human-readable description of `c`

    - #### protected static int findEndQuote(char[] array, int index)

      Finds the closing quote of a JSON string while honoring escapes.

      Parameters:
        `array` - source buffer
        `index` - index at which to start scanning
      Returns:
        index of the terminating quote or the buffer end

    - #### protected static boolean hasEscapeChar(char[] array, int index, int[] indexHolder)

      Scans a string body until it finds an escape or the closing quote.

      Parameters:
        `array` - source buffer
        `index` - index at which to start scanning
        `indexHolder` - single-item holder updated with the stop index
      Returns:
        `true` when an escape character is encountered before the closing quote

    - #### protected static boolean isDecimalChar(int currentChar)

      Checks whether a character can appear in a decimal JSON number.

      Parameters:
        `currentChar` - character code to test
      Returns:
        `true` for decimal-number markers

    - #### protected static boolean isDelimiter(int c)

      Checks whether a character terminates the current JSON value.

      Parameters:
        `c` - character code to test
      Returns:
        `true` when `c` is a value delimiter

    - #### protected static final boolean isDoubleQuote(int c)

      Checks whether a character code is a double quote.

      Parameters:
        `c` - character code to test
      Returns:
        `true` when `c` is `"`

    - #### protected static final boolean isEscape(int c)

      Checks whether a character code is the JSON escape marker.

      Parameters:
        `c` - character code to test
      Returns:
        `true` when `c` is `\`

    - #### protected static final boolean isNumberDigit(int c)

      Checks whether a character code is an ASCII digit.

      Parameters:
        `c` - character code to test
      Returns:
        `true` when `c` is between `0` and `9`

    - #### public Object parse(String jsonString)

      Parses a JSON string.

      Parameters:
        `jsonString` - JSON text to parse
      Returns:
        parsed Groovy JSON value

    - #### public Object parse(byte[] bytes)

      Parses JSON bytes using the parser's configured charset.

      Parameters:
        `bytes` - JSON bytes to parse
      Returns:
        parsed Groovy JSON value

    - #### public Object parse(byte[] bytes, String charset)

      Parses JSON bytes using the supplied charset.

      Parameters:
        `bytes` - JSON bytes to parse
        `charset` - charset name to use
      Returns:
        parsed Groovy JSON value

    - #### public Object parse(CharSequence charSequence)

      Parses JSON from a character sequence.

      Parameters:
        `charSequence` - JSON text to parse
      Returns:
        parsed Groovy JSON value

    - #### public Object parse(Reader reader)

      Parses JSON from a reader.

      Parameters:
        `reader` - reader supplying JSON content
      Returns:
        parsed Groovy JSON value

    - #### public Object parse(InputStream input)

      Parses JSON from a byte stream using the configured charset.

      Parameters:
        `input` - input stream supplying JSON bytes
      Returns:
        parsed Groovy JSON value

    - #### public Object parse(InputStream input, String charset)

      Parses JSON from a byte stream using the supplied charset.

      Parameters:
        `input` - input stream supplying JSON bytes
        `charset` - charset name to use
      Returns:
        parsed Groovy JSON value

    - #### public Object parse(File file, String charset)

      Parses JSON from a file.

      Parameters:
        `file` - file containing JSON content
        `charset` - charset name to use, or the platform default when blank
      Returns:
        parsed Groovy JSON value

    - #### public void setCharset(String charset)

      Sets the default charset used for byte and stream input.

      Parameters:
        `charset` - charset name to use for subsequent parsing