public class EmptyCharSource extends java.lang.Object implements CharSource
represents a minimal implementation of the CharSource
interface mainly providing the ability to push characters back into
the stream for later reading. Objects of this class don't deliver
any data except it was pushed into them before. Subclasses exist
which read from input sources.
Extend this class and override the read()
methods to
create a character source which is not empty up front. The
implementation of the read()
function should look like
this:
public int read() throws java.io.IOException {
int ch = super.readOne();
if( ch>=0 ) return ch;
<em>code to deliver new data</em>
}
Hint: Use objects of this class with DfaRun.setIn()
from within an FaAction
to force early EOF
and stop the DfaRun
.
Constructor and Description |
---|
EmptyCharSource() |
EmptyCharSource(int initialDepth) |
Modifier and Type | Method and Description |
---|---|
int |
pop(java.lang.StringBuilder out) |
int |
pop(java.lang.StringBuilder out,
int count) |
void |
pushBack(java.lang.StringBuilder buf,
int start)
moves the tail of
buf starting with character
index startAt back onto the character source while
deleting them from the given StringBuilder . |
int |
read()
returns a single character or -1 to indicate end of file.
|
public EmptyCharSource()
public EmptyCharSource(int initialDepth)
public void pushBack(java.lang.StringBuilder buf, int start)
CharSource
moves the tail of buf
starting with character
index startAt
back onto the character source while
deleting them from the given StringBuilder
. The data
is pushed from back to front such that a sequence of
read/pushBack/read will read two times the same string.
pushBack
in interface CharSource
public int pop(java.lang.StringBuilder out)
public int pop(java.lang.StringBuilder out, int count)
public int read() throws java.io.IOException
CharSource
read
in interface CharSource
java.io.IOException