/**
* Reads the next character from the stream per the general contract of
* Reader.read(). Returns -1 on error or end of stream.
*/
/**
* Reads the next byte from the stream per the general contract of
* InputStream.read(). Returns -1 on error or end of stream.
*/
public int read() {
// If we have buffered replace data, use it.
if ((buffer != null) && (bufpos < buffer.length())) {
return (int) buffer.charAt(bufpos++);
}
// check if input is at a valid position
if ( !stream.isValid())
return -1;
REMatch mymatch = new REMatch(expr.getNumSubs(), offset, 0);
if (expr.match(stream, mymatch)) {
mymatch.end[0] = mymatch.index;
mymatch.finish(stream);
stream.move(mymatch.toString().length());
offset += mymatch.toString().length();
buffer = mymatch.substituteInto(replace);
bufpos = 1;
// This is prone to infinite loops if replace string turns out empty.
if (buffer.length() > 0) {
return buffer.charAt(0);
}
}
char ch = stream.charAt(0);
if (ch == CharIndexed.OUT_OF_BOUNDS)
return -1;
stream.move(1);
offset++;
return ch;
}
/**
* Returns false. REFilterReader does not support mark() and
* reset() methods.
*/
/**
* Returns false. REFilterInputStream does not support mark() and
* reset() methods.
*/
public boolean markSupported() {
return false;
}
/** Reads from the stream into the provided array. */
public int read( [[#variablee24cdc0]][] b, int off, int len) {
int i;
int ok = 0;
while (len-- > 0) {
i = read();
if (i == -1)
return (ok == 0) ? -1: ok;
b[off++ ] = ( [[#variablee24cdc0]]) i;
ok++;
}
return ok;
}
/** Reads from the stream into the provided array. */
public int read( [[#variablee24cdc0]][] b) {
return read(b, 0, b.length);
}
|