|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.percederberg.grammatica.parser.ReaderBuffer
public class ReaderBuffer
A character buffer that automatically reads from an input source stream when needed. This class keeps track of the current position in the buffer and its line and column number in the original input source. It allows unlimited look-ahead of characters in the input, reading and buffering the required data internally. As the position is advanced, the buffer content prior to the current position is subject to removal to make space for reading new content. A few characters before the current position are always kept to enable boundary condition checks.
| Field Summary | |
|---|---|
static int |
BLOCK_SIZE
The stream reading block size. |
| Constructor Summary | |
|---|---|
ReaderBuffer(java.io.Reader input)
Creates a new tokenizer character buffer. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int BLOCK_SIZE
| Constructor Detail |
|---|
public ReaderBuffer(java.io.Reader input)
input - the input source character reader| Method Detail |
|---|
public 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.CharSequenceindex - the char index, 0 <= index < length()
java.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.CharSequencestart - the start index, inclusiveend - the end index, exclusive
java.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.CharSequencetoString 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 up
java.io.IOException - if an I/O error occurred
public java.lang.String read(int offset)
throws java.io.IOException
offset - the character offset, from 0 and up
java.io.IOException - if an I/O error occurred
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||