|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.Reader
info.aduna.io.LookAheadReader
public class LookAheadReader
A character-stream reader that allows look-aheads to be performed. The reader does not look ahead any more than necesarry, so performing a look ahead of 5 characters means that max. 5 characters will be read into the look ahead buffer. The look ahead buffer grows as needed.
Note that this implementation is not synchronized.
FIXME: implementation does too many array copies. Using a 'sliding window' in the buffer is cheaper.
| Field Summary |
|---|
| Fields inherited from class java.io.Reader |
|---|
lock |
| Constructor Summary | |
|---|---|
LookAheadReader(Reader r)
Creates a new LookAheadReader with a initial buffer size of 8 characters. |
|
LookAheadReader(Reader r,
int bufSize)
Creates a new LookAheadReader. |
|
| Method Summary | |
|---|---|
int |
charAt(int lookAhead)
Get the character at the supplied lookAhead. |
void |
close()
|
int |
fillLABuf(int charsNeeded)
Tries to fill the look ahead buffer so that it contains 'charsNeeded' characters. |
boolean |
moreInput()
Checks whether there's more input to read. |
boolean |
nextInputIgnoreCaseIs(String s)
Check whether the next input is equal to the supplied string (case-insensitive). |
boolean |
nextInputIs(String s)
Check whether the next input is equal to the supplied string (case-sensitive). |
int |
read()
|
int |
read(char[] cbuf,
int off,
int len)
|
long |
skip(long n)
|
| Methods inherited from class java.io.Reader |
|---|
mark, markSupported, read, read, ready, reset |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LookAheadReader(Reader r,
int bufSize)
r - The reader to do the look ahead onbufSize - The initial size of the look ahead buffer. Minimum size is 1
(needed for 'moreInput()').public LookAheadReader(Reader r)
r - The reader to do the look ahead on| Method Detail |
|---|
public boolean nextInputIs(String s)
throws IOException
s - The string to compare to the input
IOException - If an I/O error occurred in the current Reader or if the
string is longer than the maximum look ahead.
public boolean nextInputIgnoreCaseIs(String s)
throws IOException
s - The string to compare to the input
IOException - If an I/O error occurred in the current Reader or if the
string is longer than the maximum look ahead.
public int charAt(int lookAhead)
throws IOException
IOException
public boolean moreInput()
throws IOException
IOException - If an I/O error occurred in the current Reader
public int fillLABuf(int charsNeeded)
throws IOException
IOException
public int read()
throws IOException
read in class ReaderIOException
public int read(char[] cbuf,
int off,
int len)
throws IOException
read in class ReaderIOException
public long skip(long n)
throws IOException
skip in class ReaderIOException
public void close()
throws IOException
close in interface Closeableclose in class ReaderIOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||