public class BufferedOutput extends Object implements Output
List
.Constructor and Description |
---|
BufferedOutput()
Constructor using an
ArrayList as backing buffer for the lines. |
BufferedOutput(List<Line> buffer)
Constructor using the specified list as line buffer.
|
Modifier and Type | Method and Description |
---|---|
BufferedInput |
asInput()
Returns a
BufferedInput with all lines contained in this
BufferedOutput . |
List<Line> |
asList()
Returns a new list with the lines currently stored by this
BufferdOutput object. |
BufferedOutput |
clear()
Clears all lines in this buffer.
|
void |
finish()
Indicates that all output has been written.
|
boolean |
processLine(Line line)
Writes a line to the output.
|
int |
size()
Returns the number of lines currently stored by this
BufferedOutput object. |
String |
toMultiLineString()
Returns a multi-line representation of the lines in this buffer.
|
String |
toString()
Returns a list-like representation of the lines contained in this buffer.
|
void |
writeTo(Output output)
Writes the buffered output lines to the specified
output device. |
public BufferedOutput()
ArrayList
as backing buffer for the lines.public BufferedOutput(List<Line> buffer)
BufferedOutput
and vice versa.buffer
- the line buffer used "as is" without cloningpublic boolean processLine(Line line)
Output
processLine
in interface Output
processLine
in interface LineProcessor
line
- the line to write to the output.Output
device is ready to process more
lines, and false otherwise; output devices usually return truepublic void finish()
Output
finish
in interface Output
finish
in interface LineProcessor
public String toString()
toMultiLineString()
instead.public String toMultiLineString()
LineUtil.toMultiLineString(List)
public void writeTo(Output output)
output
device.
This buffered output devices does not change, that is, all lines will
still be contained in the buffer after calling this method.output
- the output device to write topublic BufferedInput asInput()
BufferedInput
with all lines contained in this
BufferedOutput
. The lists used as buffer in this
BufferedOutput
and the returned BufferedInput
are NOT
shared, meaning that subsequent modifications of this
BufferedOutput
are not reflected in the returned
BufferedInput
.BufferdInput
object reflecting the current snapshot of
lines in this BufferedOutput
public List<Line> asList()
BufferdOutput
object.public int size()
BufferedOutput
object.public BufferedOutput clear()
Copyright © 2024. All rights reserved.