abstract class LineBuffer
extends java.lang.Object
LineReader. Line separators are per BufferedReader: line feed, carriage return,
or carriage return followed immediately by a linefeed.
Subclasses must implement handleLine(java.lang.String, java.lang.String), call add(char[], int, int) to pass character data, and
call finish() at the end of stream.
| Modifier and Type | Field and Description |
|---|---|
private java.lang.StringBuilder |
line
Holds partial line contents.
|
private boolean |
sawReturn
Whether a line ending with a CR is pending processing.
|
| Constructor and Description |
|---|
LineBuffer() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
add(char[] cbuf,
int off,
int len)
Process additional characters from the stream.
|
protected void |
finish()
Subclasses must call this method after finishing character processing, in order to ensure that
any unterminated line in the buffer is passed to
handleLine(java.lang.String, java.lang.String). |
private boolean |
finishLine(boolean sawNewline)
Called when a line is complete.
|
protected abstract void |
handleLine(java.lang.String line,
java.lang.String end)
Called for each line found in the character data passed to
add(char[], int, int). |
private java.lang.StringBuilder line
private boolean sawReturn
protected void add(char[] cbuf,
int off,
int len)
throws java.io.IOException
handleLine(java.lang.String, java.lang.String) method.cbuf - the character buffer to processoff - the offset into the bufferlen - the number of characters to processjava.io.IOException - if an I/O error occursfinish()private boolean finishLine(boolean sawNewline)
throws java.io.IOException
java.io.IOExceptionprotected void finish()
throws java.io.IOException
handleLine(java.lang.String, java.lang.String).java.io.IOException - if an I/O error occursprotected abstract void handleLine(java.lang.String line,
java.lang.String end)
throws java.io.IOException
add(char[], int, int).line - a line of text (possibly empty), without any line separatorsend - the line separator; one of "\r", "\n", "\r\n", or ""java.io.IOException - if an I/O error occurs