public class MultipleInputLineProcessor extends Object implements LineProcessor
LineProcessor
reading the lines passed to it from the standard input.
The processLine(Line)
method does nothing and returns false
indicating that the (standard) input is not read by this processor. The
finish()
method reads the lines from the Input
object passed
to the constructor and passes them as input to the delegate processor
performing the real work.
Constructor and Description |
---|
MultipleInputLineProcessor(List<? extends Input> inputs,
InputProcessor processor,
LineProcessor output)
Constructor with input objects (usually file operands of the command) and
the input processor of the command that reads from the standard input.
|
Modifier and Type | Method and Description |
---|---|
protected void |
beginMultiple(List<? extends Input> inputs,
LineProcessor output)
Called once at the beginning before iterating over the
Input
objects in the given inputs list. |
void |
finish()
Performs the following operations to process all
Input objects
that have been passed to the constructor:
Calls beginMultiple(..)
Iterates over all input objects in sequence
Calls InputProcessor.begin(Input, LineProcessor)
Calls InputProcessor.processLine(Input, Line, LineProcessor)
for every line in the current input
Calls InputProcessor.finish(Input, LineProcessor)
Calls finishMultiple(..)
|
protected void |
finishMultiple(List<? extends Input> inputs,
LineProcessor output)
Called once at the end after iterating over the
Input objects in
the given inputs list. |
boolean |
processLine(Line line)
Processes a single line and returns true if this
LineProcessor is
ready to process more lines. |
public MultipleInputLineProcessor(List<? extends Input> inputs, InputProcessor processor, LineProcessor output)
inputs
- the input devices, usually file operands of the commandprocessor
- the operation applied to every input in the given
inputs
listpublic boolean processLine(Line line)
LineProcessor
LineProcessor
is
ready to process more lines. Returning false indicates that the process
can be finished
because subsequent lines would not
change the result anyway.processLine
in interface LineProcessor
line
- the line to processLineProcessor
is ready to process more
lines, and false if it does not require any more input linespublic void finish()
Input
objects
that have been passed to the constructor:
beginMultiple(..)
InputProcessor.begin(Input, LineProcessor)
InputProcessor.processLine(Input, Line, LineProcessor)
for every line in the current inputInputProcessor.finish(Input, LineProcessor)
finishMultiple(..)
finish
in interface LineProcessor
protected void beginMultiple(List<? extends Input> inputs, LineProcessor output)
Input
objects in the given inputs
list.
The DEFAULT implementation performs no operation.
inputs
- the input object being iterated nextoutput
- the output to write toprotected void finishMultiple(List<? extends Input> inputs, LineProcessor output)
Input
objects in
the given inputs
list.
The DEFAULT implementation calls output.finish()
and closes all input objects.
inputs
- the input object being iterated nextoutput
- the output to write toCopyright © 2024. All rights reserved.