RootInputStreampublic class RootInputStream extends InputStream InputStream used by the parser to wrap the original user
supplied stream. This stream keeps track of the current line number and
can also be truncated. When truncated the stream will appear to have
reached end of file. This is used by the parser's
{@link org.apache.james.mime4j.MimeStreamParser#stop()} method. |
Fields Summary |
---|
private InputStream | is | private int | lineNumber | private int | prev | private boolean | truncated |
Constructors Summary |
---|
public RootInputStream(InputStream is)Creates a new RootInputStream .
this.is = is;
|
Methods Summary |
---|
public int | getLineNumber()Gets the current line number starting at 1
(the number of \r\n read so far plus 1).
return lineNumber;
| public int | read()
if (truncated) {
return -1;
}
int b = is.read();
if (prev == '\r" && b == '\n") {
lineNumber++;
}
prev = b;
return b;
| public int | read(byte[] b, int off, int len)
if (truncated) {
return -1;
}
int n = is.read(b, off, len);
for (int i = off; i < off + n; i++) {
if (prev == '\r" && b[i] == '\n") {
lineNumber++;
}
prev = b[i];
}
return n;
| public int | read(byte[] b)
return read(b, 0, b.length);
| public void | truncate()Truncates this InputStream . After this call any
call to {@link #read()}, {@link #read(byte[]) or
{@link #read(byte[], int, int)} will return
-1 as if end-of-file had been reached.
this.truncated = true;
|
|