Package: org.apache.groovy.json.internal

## [Java] Class ReaderCharacterSource

- org.apache.groovy.json.internal.ReaderCharacterSource

- All Implemented Interfaces and Traits:
    CharacterSource

      public class ReaderCharacterSource
      extends Object
      implements CharacterSource

  Buffered CharacterSource implementation backed by a Reader.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `ReaderCharacterSource(Reader reader, int readAheadSize)` Creates a buffered character source.
    `ReaderCharacterSource(Reader reader)` Creates a buffered character source with the default read-ahead size.
    `ReaderCharacterSource(String string)` Creates a character source over an in-memory string.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public final boolean` | `consumeIfMatch(char[] match)` Consumes the supplied character sequence when it matches the current position.
    `` | `public final int` | `currentChar()` Returns the current character without advancing.
    `` | `public String` | `errorDetails(String message)` Builds an error message using the current reader context.
    `` | `public char[]` | `findNextChar(int match, int esc)` Collects characters until the next unescaped match character.
    `` | `public boolean` | `hadEscape()` Reports whether the last string scan encountered an escape sequence.
    `` | `public final boolean` | `hasChar()` Checks whether another character is available.
    `` | `public final int` | `location()` Returns the current buffer index for diagnostics.
    `` | `public final int` | `nextChar()` Advances to the next character.
    `` | `public char[]` | `readNumber()` Reads a numeric token from the current position.
    `` | `public final int` | `safeNextChar()` Advances when possible and returns `-1` at end of input.
    `` | `public void` | `skipWhiteSpace()` Advances past whitespace characters.

  - ### Inherited Methods Summary

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

- - ### Constructor Detail

    - #### public ReaderCharacterSource(Reader reader, int readAheadSize)

      Creates a buffered character source.

      Parameters:
        `reader` - reader supplying characters
        `readAheadSize` - number of characters to read per buffer refill

    - #### public ReaderCharacterSource(Reader reader)

      Creates a buffered character source with the default read-ahead size.

      Parameters:
        `reader` - reader supplying characters

    - #### public ReaderCharacterSource(String string)

      Creates a character source over an in-memory string.

      Parameters:
        `string` - JSON content to expose as characters

  - ### Method Detail

    - #### public final boolean consumeIfMatch(char[] match)

      Consumes the supplied character sequence when it matches the current position.

      Parameters:
        `match` - character sequence to test
      Returns:
        `true` when the sequence was consumed

    - #### public final int currentChar()

      Returns the current character without advancing.

      Returns:
        current character code

    - #### public String errorDetails(String message)

      Builds an error message using the current reader context.

      Parameters:
        `message` - parser-specific message
      Returns:
        formatted error details

    - #### public char[] findNextChar(int match, int esc)

      Collects characters until the next unescaped match character.

      Parameters:
        `match` - terminating character to search for
        `esc` - escape character that shields the following character
      Returns:
        collected characters between the current position and the terminator

    - #### public boolean hadEscape()

      Reports whether the last string scan encountered an escape sequence.

      Returns:
        `true` when an escape was seen

    - #### public final boolean hasChar()

      Checks whether another character is available.

      Returns:
        `true` when more input remains

    - #### public final int location()

      Returns the current buffer index for diagnostics.

      Returns:
        current character index

    - #### public final int nextChar()

      Advances to the next character.

      Returns:
        next character code

    - #### public char[] readNumber()

      Reads a numeric token from the current position.

      Returns:
        characters that form the numeric token

    - #### public final int safeNextChar()

      Advances when possible and returns `-1` at end of input.

      Returns:
        next character code or `-1` when no more input remains

    - #### public void skipWhiteSpace()

      Advances past whitespace characters.