|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavafe.util.CorrelatedReader
javafe.util.BufferedCorrelatedReader
Instances of this CorrelatedReader
contain a buffer.
Field Summary | |
protected int |
beforeBufLoc
The location of the first character in the buffer, minus 1. |
protected byte[] |
buf
While open, we buffer input in the buffer buf , which
grows on demand.
|
protected int |
curNdx
The index of the next character to be read from the buffer. |
protected int |
endBufNdx
The first unused entry in the buffer. |
protected int |
lastCharNdx
The value of curNdx for the last character read, or, if no characters have been read yet, the value of curNdx. |
protected int |
markNdx
The value of curNdx at the mark point (if marked is true). |
protected int |
maxLoc
|
protected int |
minLoc
The allocated location range for this CorrelatedReader instance is [minLoc, maxLoc). |
protected int |
oddSlashLoc
For unicode conversion, we need to know if we have just seen an even or odd number of backslashes. |
(package private) static int |
STARTFREELOC
All locations are allocated at or above a medium-large int STARTFREELOC to make it less likely that other program ints can be interpreted as locations. |
Fields inherited from class javafe.util.CorrelatedReader |
marked |
Constructor Summary | |
(package private) |
BufferedCorrelatedReader(int minLoc,
int beforeBufLoc,
int maxLoc)
This constructor leaves buf as null. |
Method Summary | |
void |
clearMark()
Removes the mark (if any) from the input stream. |
void |
close()
Closes us. |
CorrelatedReader |
createReaderFromMark(int discard)
Creates a CorrelatedReader object for the input
text from the marked position, to the current position. |
int |
getBeforeMarkLocation()
Returns the location of the character before the mark. |
byte[] |
getBufferFromMark(int discard)
Returns a new buffer containing the contents of this BufferedCorrelatedReader's buffer, from the marked position to the current position less discard bytes (not characters).
|
int |
getLocation()
Returns the location of the last character read. |
void |
mark()
Marks the position of the current character in this input stream. |
protected int |
peek()
Peeks the next character from this input stream. |
protected int |
readRaw()
Reads the next character from this input stream. |
protected abstract boolean |
refillBuf()
Refills the buffer. |
void |
reset()
Repositions this stream to the position at the time the mark method was last called on this input stream. |
Methods inherited from class javafe.util.CorrelatedReader |
getFile, read |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
static final int STARTFREELOC
protected int minLoc
Note that in practice only a prefix, [minLoc, min(beforeBufLoc + curNdx, maxLoc-1)], of the range representing the characters read so far are actually valid locations at any given time.
protected int maxLoc
protected byte[] buf
buf
, which
grows on demand.
We are closed iff buf
is non-null.
protected int beforeBufLoc
The locations of later valid characters are obtained by adding their index to this loc.
protected int endBufNdx
protected int curNdx
protected int lastCharNdx
protected int oddSlashLoc
protected int markNdx
Constructor Detail |
BufferedCorrelatedReader(int minLoc, int beforeBufLoc, int maxLoc)
buf
as null.
Method Detail |
public void close()
close
in class CorrelatedReader
public int getLocation()
getLocation
in class CorrelatedReader
protected abstract boolean refillBuf() throws java.io.IOException
In doing so, may reallocate the buffer.
Returns true iff not end-of-file, and at least one character was read from the file. Throws an IOException if no characters could be read from the stream.
Requires we are open.
java.io.IOException
protected int peek() throws java.io.IOException
Requires we are open.
java.io.IOException
protected int readRaw() throws java.io.IOException
Requires we are open.
java.io.IOException
public void mark()
reset
method
repositions this stream at the last marked position.
This method differs from
java.io.InputStream.readlimit
in that it does not
take a readlimit
argument.
mark
in class CorrelatedReader
reset()
,
clearMark()
,
createReaderFromMark(int)
public void clearMark()
clearMark
in class CorrelatedReader
mark()
public void reset() throws java.io.IOException
mark
method was last called on this input stream.
Requires that the input stream had been previously marked
via the mark()
method.
If mark() is called before read(), then the mark will be restored to its previous value (and not the preceeding character().
reset
in class CorrelatedReader
java.io.IOException
- if this stream is not marked.mark()
public int getBeforeMarkLocation()
public byte[] getBufferFromMark(int discard) throws java.lang.IndexOutOfBoundsException
discard
bytes (not characters).
Clears the mark as a side-effect.
java.lang.IndexOutOfBoundsException
- if discard
is negative or exceeds the number of marked characterspublic CorrelatedReader createReaderFromMark(int discard) throws java.lang.IndexOutOfBoundsException
CorrelatedReader
object for the input
text from the marked position, to the current position.
Calls to getLocation()
for characters from the
new CorrelatedReader
yield the same locations as
calls to getLocation()
for the same characters on
this CorrelatedReader
.
The discard
argument specifies the number of
characters to discard from the end of the
sub-CorrelatedReader
.
Clears the mark as a side-effect.
Requires that the input stream had been previously marked via
the mark()
method and that we have not been
closed.
createReaderFromMark
in class CorrelatedReader
java.lang.IndexOutOfBoundsException
- if discard
is negative or exceeds the number of marked charactersmark()
|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |