public class ReaderBuffer
extends java.lang.Object
implements java.lang.CharSequence
Modifier and Type | Field and Description |
---|---|
static int |
BLOCK_SIZE
The stream reading block size.
|
Constructor and Description |
---|
ReaderBuffer(java.io.Reader input)
Creates a new tokenizer character buffer.
|
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index)
Returns a character already in the buffer.
|
int |
columnNumber()
Returns the current column number.
|
void |
dispose()
Discards all resources used by this buffer.
|
int |
length()
Returns the current character buffer length.
|
int |
lineNumber()
Returns the current line number.
|
int |
peek(int offset)
Returns a character relative to the current position.
|
int |
position()
Returns the current position in the buffer.
|
java.lang.String |
read(int offset)
Reads the specified number of characters from the current
position.
|
java.lang.CharSequence |
subSequence(int start,
int end)
Returns a character sequence already in the buffer.
|
java.lang.String |
toString()
Returns the current content of the buffer as a string.
|
public static final int BLOCK_SIZE
public ReaderBuffer(java.io.Reader input)
input
- the input source character readerpublic void dispose()
public int position()
public int lineNumber()
public int columnNumber()
public int length()
length
in interface java.lang.CharSequence
public char charAt(int index) throws java.lang.IndexOutOfBoundsException
charAt
in interface java.lang.CharSequence
index
- the char index, starting at 0java.lang.IndexOutOfBoundsException
- if the index is negative or
not less than length()public java.lang.CharSequence subSequence(int start, int end) throws java.lang.IndexOutOfBoundsException
subSequence
in interface java.lang.CharSequence
start
- the start index, inclusiveend
- the end index, exclusivejava.lang.IndexOutOfBoundsException
- if one of the indices were
negative or not less than (or equal) than length()public java.lang.String toString()
toString
in interface java.lang.CharSequence
toString
in class java.lang.Object
public int peek(int offset) throws java.io.IOException
The character offset must be positive, but is allowed to span the entire size of the input source stream. Note that the internal buffer must hold all the intermediate characters, which may be wasteful if the offset is too large.
offset
- the character offset, from 0 and upjava.io.IOException
- if an I/O error occurredpublic java.lang.String read(int offset) throws java.io.IOException
offset
- the character offset, from 0 and upjava.io.IOException
- if an I/O error occurred