Package: org.apache.groovy.json.internal

## [Java] Class CharScanner

- org.apache.groovy.json.internal.CharScanner

-     public class CharScanner
      extends Object

  Low-level character scanning utilities used while parsing JSON values.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected static int` | `ALPHA_0` | Character code for `'0'`.
    `protected static int` | `ALPHA_9` | Character code for `'9'`.
    `protected static int` | `CLOSED_BRACKET` | Closing bracket character code.
    `protected static int` | `CLOSED_CURLY` | Closing curly brace character code.
    `protected static int` | `COMMA` | Comma character code.
    `protected static int` | `DECIMAL_POINT` | Decimal point character code.
    `protected static int` | `LETTER_BIG_E` | Uppercase exponent marker.
    `protected static int` | `LETTER_E` | Lowercase exponent marker.
    `protected static int` | `MINUS` | Minus sign character code.
    `protected static int` | `PLUS` | Plus sign character code.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static String` | `debugCharDescription(int c)` Returns a debug string for a character code.
    `` | `public static String` | `errorDetails(String message, char[] array, int index, int ch)` Builds a human-readable parse error description for the current character position.
    `` | `public static boolean` | `hasDecimalChar(char[] chars, boolean negative)` Tests whether a character range contains decimal punctuation.
    `` | `public static boolean` | `isDecimalChar(int currentChar)` Tests whether the supplied code point is decimal punctuation.
    `` | `public static boolean` | `isDecimalDigit(int c)` Tests whether the supplied code point can appear in a decimal number.
    `` | `protected static boolean` | `isDelimiter(int c)` Tests whether the supplied code point terminates a JSON number token.
    `` | `public static boolean` | `isDigit(int c)` Tests whether the supplied code point is an ASCII digit.
    `` | `public static boolean` | `isInteger(char[] digitChars)` Tests whether the supplied digits fit in an `int`.
    `` | `public static boolean` | `isInteger(char[] digitChars, int offset, int len)` Tests whether the supplied digit range fits in an `int`.
    `` | `public static boolean` | `isLong(char[] digitChars)` Tests whether the supplied digits fit in a `long`.
    `` | `public static boolean` | `isLong(char[] digitChars, int offset, int len)` Tests whether the supplied digit range fits in a `long`.
    `` | `public static boolean` | `isNumberDigit(int c)` Tests whether the supplied code point is a numeric digit.
    `` | `public static BigDecimal` | `parseBigDecimal(char[] buffer)` Parses a BigDecimal from the supplied characters.
    `` | `public static double` | `parseDouble(char[] buffer, int from, int to)` Parses a `double` from a character range.
    `` | `public static float` | `parseFloat(char[] buffer, int from, int to)` Parses a `float` from a character range.
    `` | `public static int` | `parseInt(char[] digitChars)` Parses an `int` from the supplied digit characters.
    `` | `public static int` | `parseIntFromTo(char[] digitChars, int offset, int to)` Parses an `int` from a character range.
    `` | `public static int` | `parseIntFromToIgnoreDot(char[] digitChars, int offset, int to)` Parses an `int` from a character range while ignoring decimal points.
    `` | `public static Number` | `parseJsonNumber(char[] buffer)` Parses a JSON number from the supplied character array.
    `` | `public static Number` | `parseJsonNumber(char[] buffer, int from, int to)` Parses a JSON number from a character range.
    `` | `public static Number` | `parseJsonNumber(char[] buffer, int from, int max, int[] size)` Parses a JSON number and optionally reports the stopping index.
    `` | `public static Number` | `parseJsonNumber(char[] buffer, int from, int max, int[] size, int maxNumberLength)` Parses a JSON number and optionally reports the stopping index, bounding the length of the number token.
    `` | `public static long` | `parseLong(char[] digitChars)` Parses a `long` from the supplied digit characters.
    `` | `public static long` | `parseLongFromTo(char[] digitChars, int offset, int to)` Parses a `long` from a character range.
    `` | `public static long` | `parseLongFromToIgnoreDot(char[] digitChars, int offset, int to)` Parses a `long` from a character range while ignoring decimal points.
    `` | `public static char[]` | `readNumber(char[] array, int idx, int len)` Copies a contiguous JSON number token into a new array.
    `` | `public static int` | `skipWhiteSpace(char[] array, int index, int length)` Advances past ASCII whitespace.

  - ### 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 `'0'`.

    - #### protected static final int ALPHA_9

      Character code for `'9'`.

    - #### protected static final int CLOSED_BRACKET

      Closing bracket character code.

    - #### protected static final int CLOSED_CURLY

      Closing curly brace character code.

    - #### protected static final int COMMA

      Comma character code.

    - #### protected static final int DECIMAL_POINT

      Decimal point character code.

    - #### protected static final int LETTER_BIG_E

      Uppercase exponent marker.

    - #### protected static final int LETTER_E

      Lowercase exponent marker.

    - #### protected static final int MINUS

      Minus sign character code.

    - #### protected static final int PLUS

      Plus sign character code.

  - ### Method Detail

    - #### public static String debugCharDescription(int c)

      Returns a debug string for a character code.

      Parameters:
        `c` - the character code to describe
      Returns:
        a printable character description

    - #### public static String errorDetails(String message, char[] array, int index, int ch)

      Builds a human-readable parse error description for the current character position.

      Parameters:
        `message` - the high-level error message
        `array` - the source character array
        `index` - the failing index
        `ch` - the current character code
      Returns:
        the formatted diagnostic text

    - #### public static boolean hasDecimalChar(char[] chars, boolean negative)

      Tests whether a character range contains decimal punctuation.

      Parameters:
        `chars` - the character array to inspect
        `negative` - whether the first character is a sign and should be skipped
      Returns:
        `true` if a decimal marker or exponent marker is present

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

      Tests whether the supplied code point is decimal punctuation.

      Parameters:
        `currentChar` - the character code to test
      Returns:
        `true` for sign, exponent, or decimal point characters

    - #### public static boolean isDecimalDigit(int c)

      Tests whether the supplied code point can appear in a decimal number.

      Parameters:
        `c` - the character code to test
      Returns:
        `true` for digits and decimal punctuation

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

      Tests whether the supplied code point terminates a JSON number token.

      Parameters:
        `c` - the character code to test
      Returns:
        `true` if the code point is a structural delimiter

    - #### public static boolean isDigit(int c)

      Tests whether the supplied code point is an ASCII digit.

      Parameters:
        `c` - the character code to test
      Returns:
        `true` if the code point is between `'0'` and `'9'`

    - #### public static boolean isInteger(char[] digitChars)

      Tests whether the supplied digits fit in an `int`.

      Parameters:
        `digitChars` - the digit characters to test
      Returns:
        `true` if the value is within the `int` range

    - #### public static boolean isInteger(char[] digitChars, int offset, int len)

      Tests whether the supplied digit range fits in an `int`.

      Parameters:
        `digitChars` - the digit characters to test
        `offset` - the inclusive range start
        `len` - the number of characters to compare
      Returns:
        `true` if the value is within the `int` range

    - #### public static boolean isLong(char[] digitChars)

      Tests whether the supplied digits fit in a `long`.

      Parameters:
        `digitChars` - the digit characters to test
      Returns:
        `true` if the value is within the `long` range

    - #### public static boolean isLong(char[] digitChars, int offset, int len)

      Tests whether the supplied digit range fits in a `long`.

      Parameters:
        `digitChars` - the digit characters to test
        `offset` - the inclusive range start
        `len` - the number of characters to compare
      Returns:
        `true` if the value is within the `long` range

    - #### public static boolean isNumberDigit(int c)

      Tests whether the supplied code point is a numeric digit.

      Parameters:
        `c` - the character code to test
      Returns:
        `true` if the code point is between `'0'` and `'9'`

    - #### public static BigDecimal parseBigDecimal(char[] buffer)

      Parses a BigDecimal from the supplied characters.

      Parameters:
        `buffer` - the character array to parse
      Returns:
        the parsed decimal value

    - #### public static double parseDouble(char[] buffer, int from, int to)

      Parses a `double` from a character range.

      Parameters:
        `buffer` - the character array to parse
        `from` - the inclusive range start
        `to` - the exclusive range end
      Returns:
        the parsed value

    - #### public static float parseFloat(char[] buffer, int from, int to)

      Parses a `float` from a character range.

      Parameters:
        `buffer` - the character array to parse
        `from` - the inclusive range start
        `to` - the exclusive range end
      Returns:
        the parsed value

    - #### public static int parseInt(char[] digitChars)

      Parses an `int` from the supplied digit characters.

      Parameters:
        `digitChars` - the digit characters to parse
      Returns:
        the parsed value

    - #### public static int parseIntFromTo(char[] digitChars, int offset, int to)

      Parses an `int` from a character range.

      Parameters:
        `digitChars` - the digit characters to parse
        `offset` - the inclusive range start
        `to` - the exclusive range end
      Returns:
        the parsed value

    - #### public static int parseIntFromToIgnoreDot(char[] digitChars, int offset, int to)

      Parses an `int` from a character range while ignoring decimal points.

      Parameters:
        `digitChars` - the digit characters to parse
        `offset` - the inclusive range start
        `to` - the exclusive range end
      Returns:
        the parsed value

    - #### public static Number parseJsonNumber(char[] buffer)

      Parses a JSON number from the supplied character array.

      Parameters:
        `buffer` - the character array containing the number
      Returns:
        the parsed Number

    - #### public static Number parseJsonNumber(char[] buffer, int from, int to)

      Parses a JSON number from a character range.

      Parameters:
        `buffer` - the character array containing the number
        `from` - the inclusive range start
        `to` - the exclusive range end
      Returns:
        the parsed Number

    - #### public static Number parseJsonNumber(char[] buffer, int from, int max, int[] size)

      Parses a JSON number and optionally reports the stopping index.

      Parameters:
        `buffer` - the character array containing the number
        `from` - the inclusive range start
        `max` - the exclusive scan limit
        `size` - optional single-element output array receiving the stopping index
      Returns:
        the parsed Number

    - #### public static Number parseJsonNumber(char[] buffer, int from, int max, int[] size, int maxNumberLength)

      Parses a JSON number and optionally reports the stopping index, bounding the length of the number token.

      throws:
        JsonException if the number token is longer than `maxNumberLength`
      Parameters:
        `buffer` - the character array containing the number
        `from` - the inclusive range start
        `max` - the exclusive scan limit
        `size` - optional single-element output array receiving the stopping index
        `maxNumberLength` - the maximum permitted token length; `0` or less disables the check
      Returns:
        the parsed Number

    - #### public static long parseLong(char[] digitChars)

      Parses a `long` from the supplied digit characters.

      Parameters:
        `digitChars` - the digit characters to parse
      Returns:
        the parsed value

    - #### public static long parseLongFromTo(char[] digitChars, int offset, int to)

      Parses a `long` from a character range.

      Parameters:
        `digitChars` - the digit characters to parse
        `offset` - the inclusive range start
        `to` - the exclusive range end
      Returns:
        the parsed value

    - #### public static long parseLongFromToIgnoreDot(char[] digitChars, int offset, int to)

      Parses a `long` from a character range while ignoring decimal points.

      Parameters:
        `digitChars` - the digit characters to parse
        `offset` - the inclusive range start
        `to` - the exclusive range end
      Returns:
        the parsed value

    - #### public static char[] readNumber(char[] array, int idx, int len)

      Copies a contiguous JSON number token into a new array.

      Parameters:
        `array` - the source character array
        `idx` - the index at which the number starts
        `len` - the exclusive scan limit
      Returns:
        a new array containing the number token

    - #### public static int skipWhiteSpace(char[] array, int index, int length)

      Advances past ASCII whitespace.

      Parameters:
        `array` - the character array to scan
        `index` - the index to start from
        `length` - the exclusive scan limit
      Returns:
        the first index whose character is greater than space, or `length`