|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.parancoe.yaml.parser.ParserReader
public final class ParserReader
A character Reader with some additional functionality.
This implementation uses a circular buffer with a default size of 64k. To create a ParserReader from a Reader do:
ParserReader parserReader = ParserReader(reader);
The constructor accepts any reader and returns a new reader with the functions defined here. As of now, this class is not an extension of Reader.
Care has to be taken when using mark(), unmark() and reset(), since they can be nested. Each mark() call has to be matched by exactly one unmark() or reset(). This code is now legal:
ParserReader r = new ParserReader(reader);
mark(); // position 1
mark(); // position 2
reset(); // return to position 2
if (condition)
reset(); // return to position 1
else
unmark();
| Constructor Summary | |
|---|---|
ParserReader(java.io.Reader reader)
|
|
| Method Summary | |
|---|---|
int |
current()
return one character from the stream without 'consuming' it |
void |
mark()
remember the current position for a future reset() |
int |
previous()
return the previous character |
int |
read()
read and return one character from the stream. |
void |
reset()
return to the position of a previous mark(). |
java.lang.String |
string()
return a string begining at the last mark() untill the current position |
void |
unmark()
|
void |
unread()
unread one character. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ParserReader(java.io.Reader reader)
throws java.lang.Exception
java.lang.Exception| Method Detail |
|---|
public java.lang.String string()
public int read()
throws java.io.IOException
java.io.IOException
public int current()
throws java.io.IOException
java.io.IOExceptionpublic int previous()
public void mark()
public void unmark()
public void reset()
public void unread()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||