Package: org.codehaus.groovy.util

## [Java] Class CharSequenceReader

- org.codehaus.groovy.util.CharSequenceReader

- All Implemented Interfaces and Traits:
    Serializable

      public class CharSequenceReader
      extends Reader
      implements Serializable

  Reader implementation that can read from String, StringBuffer, StringBuilder, CharBuffer or GString.

  Note: Supports mark(int) and reset().

  Note: This class is mostly a copy from Commons IO and is intended for internal Groovy usage only. It may be deprecated and removed from Groovy at a faster pace than other classes. If you need this functionality in your Groovy programs, we recommend using the Commons IO equivalent directly.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `CharSequenceReader(CharSequence charSequence)` Construct a new instance with the specified character sequence.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `close()` Close resets the reader back to the start and removes any marked position.
    `` | `public void` | `mark(int readAheadLimit)` Mark the current position.
    `` | `public boolean` | `markSupported()` Mark is supported (returns true).
    `` | `public int` | `read()` Read a single character.
    `` | `public int` | `read(char[] array, int offset, int length)` Read the specified number of characters into the array.
    `` | `public void` | `reset()` Reset the reader to the last marked position (or the beginning if mark has not been called).
    `` | `public long` | `skip(long n)` Skip the specified number of characters.
    `` | `public String` | `toString()` Return a String representation of the underlying character sequence.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Reader` | `close, equals, getClass, hashCode, mark, markSupported, notify, notifyAll, nullReader, read, read, read, read, ready, reset, skip, toString, transferTo, wait, wait, wait`

- - ### Constructor Detail

    - #### public CharSequenceReader(CharSequence charSequence)

      Construct a new instance with the specified character sequence.

      Parameters:
        `charSequence` - The character sequence, may be `null`

  - ### Method Detail

    - #### @Override
      public void close()

      Close resets the reader back to the start and removes any marked position.

    - #### @Override
      public void mark(int readAheadLimit)

      Mark the current position.

      Parameters:
        `readAheadLimit` - ignored

    - #### @Override
      public boolean markSupported()

      Mark is supported (returns true).

      Returns:
        `true`

    - #### @Override
      public int read()

      Read a single character.

      Returns:
        the next character from the character sequence or -1 if the end has been reached.

    - #### @Override
      public int read(char[] array, int offset, int length)

      Read the specified number of characters into the array.

      Parameters:
        `array` - The array to store the characters in
        `offset` - The starting position in the array to store
        `length` - The maximum number of characters to read
      Returns:
        The number of characters read or -1 if there are no more

    - #### @Override
      public void reset()

      Reset the reader to the last marked position (or the beginning if mark has not been called).

    - #### @Override
      public long skip(long n)

      Skip the specified number of characters.

      Parameters:
        `n` - The number of characters to skip
      Returns:
        The actual number of characters skipped

    - #### @Override
      public String toString()

      Return a String representation of the underlying character sequence.

      Returns:
        The contents of the character sequence