Package org.apache.groovy.json.internal

# Interface CharacterSource

All Known Implementing Classes:
  `ReaderCharacterSource`

public interface CharacterSource
Character cursor abstraction used by the streaming JSON parsers.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `consumeIfMatch(char[] match)`
  Useful for finding constants in a string like true, false, etc.
  `int`
  `currentChar()`
  returns the current character without changing the IO pointer or index.
  `String`
  `errorDetails(String message)`
  Builds an error message using the current source position.
  `char[]`
  `findNextChar(int ch, int esc)`
  Used to find strings and their ilk Finds the next non-escaped char
  `boolean`
  `hadEscape()`
  Reports whether the last string scan encountered an escape sequence.
  `boolean`
  `hasChar()`
  Checks to see if there is a next character.
  `int`
  `location()`
  This is mostly for debugging and testing.
  `int`
  `nextChar()`
  returns the next character moving the file pointer or index to the next location.
  `char[]`
  `readNumber()`
  Reads a number from the character source.
  `int`
  `safeNextChar()`
  Combines the operations of nextChar and hasChar.
  `void`
  `skipWhiteSpace()`
  Skip white space.

- ## Method Details

  - ### skipWhiteSpace

    void skipWhiteSpace()
    Skip white space.

  - ### nextChar

    int nextChar()
    returns the next character moving the file pointer or index to the next location.

  - ### currentChar

    int currentChar()
    returns the current character without changing the IO pointer or index.

  - ### hasChar

    boolean hasChar()
    Checks to see if there is a next character.

  - ### consumeIfMatch

    boolean consumeIfMatch(char[] match)
    Useful for finding constants in a string like true, false, etc.

  - ### location

    int location()
    This is mostly for debugging and testing.

  - ### safeNextChar

    int safeNextChar()
    Combines the operations of nextChar and hasChar. Characters is -1 if not found which signifies end of file. This might be preferable to avoid two method calls.

  - ### findNextChar

    char[] findNextChar(int ch, int esc)
    Used to find strings and their ilk Finds the next non-escaped char
    Parameters:
      `ch` - character to find
      `esc` - escape character to avoid next char if escaped
    Returns:
      list of chars until this is found.

  - ### hadEscape

    boolean hadEscape()
    Reports whether the last string scan encountered an escape sequence.
    Returns:
      `true` when an escape was seen

  - ### readNumber

    char[] readNumber()
    Reads a number from the character source.

  - ### errorDetails

    String errorDetails(String message)
    Builds an error message using the current source position.
    Parameters:
      `message` - parser-specific message
    Returns:
      formatted error details