Top Description Fields Constructors Methods
org.codehaus.groovy.util

public Class CharSequenceReader

extends Reader
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Reader, .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.

Field Summary

Modifier and TypeField and Description
private final CharSequence
private static final int
private int
private int
private static final long
Inherited from java.io.Reader:
lock

Constructor Summary

AccessConstructor and Description
public
CharSequenceReader(final CharSequence
The character sequence, may be null
charSequence
)

Construct a new instance with the specified character sequence.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

Close resets the reader back to the start and removes any marked position.
public void
mark(final int
ignored
readAheadLimit
)

Overrides java.io.Reader.mark.

Mark the current position.
public boolean

Returns:

true
markSupported
()

Overrides java.io.Reader.markSupported.

Mark is supported (returns true).
public int

Returns:

the next character from the character sequence or -1 if the end has been reached.
read
()

Overrides java.io.Reader.read.

Read a single character.
public int

Returns:

The number of characters read or -1 if there are no more
read
(final char[]
The array to store the characters in
array
,
final int
The starting position in the array to store
offset
,
final int
The maximum number of characters to read
length
)

Implements abstract java.io.Reader.read.

Read the sepcified number of characters into the array.
public void
reset()

Overrides java.io.Reader.reset.

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

Returns:

The actual number of characters skipped
skip
(final long
The number of characters to skip
n
)

Overrides java.io.Reader.skip.

Skip the specified number of characters.
public String

Returns:

The contents of the character sequence
toString
()

Overrides java.lang.Object.toString.

Return a String representation of the underlying character sequence.
Inherited from java.io.Reader:
nullReaderreadreadreadytransferTo

Field Detail

charSequenceback to summary
private final CharSequence charSequence
EOFback to summary
private static final int EOF
idxback to summary
private int idx
markback to summary
private int mark
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

CharSequenceReaderback to summary
public CharSequenceReader(final CharSequence charSequence)

Construct a new instance with the specified character sequence.

Parameters
charSequence:CharSequence

The character sequence, may be null

Method Detail

closeback to summary
public void close()

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

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

Annotations
@Override
markback to summary
public void mark(final int readAheadLimit)

Overrides java.io.Reader.mark.

Mark the current position.

Parameters
readAheadLimit:int

ignored

Annotations
@Override
markSupportedback to summary
public boolean markSupported()

Overrides java.io.Reader.markSupported.

Mark is supported (returns true).

Returns:boolean

true

Annotations
@Override
readback to summary
public int read()

Overrides java.io.Reader.read.

Read a single character.

Returns:int

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

Annotations
@Override
readback to summary
public int read(final char[] array, final int offset, final int length)

Implements abstract java.io.Reader.read.

Read the sepcified number of characters into the array.

Parameters
array:char[]

The array to store the characters in

offset:int

The starting position in the array to store

length:int

The maximum number of characters to read

Returns:int

The number of characters read or -1 if there are no more

Annotations
@Override
resetback to summary
public void reset()

Overrides java.io.Reader.reset.

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

Annotations
@Override
skipback to summary
public long skip(final long n)

Overrides java.io.Reader.skip.

Skip the specified number of characters.

Parameters
n:long

The number of characters to skip

Returns:long

The actual number of characters skipped

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return a String representation of the underlying character sequence.

Returns:String

The contents of the character sequence

Annotations
@Override