Package eu.simuline.octave.exec
Class OctaveReaderCallable.OctaveExecuteReader
- java.lang.Object
-
- java.io.Reader
-
- eu.simuline.octave.exec.OctaveReaderCallable.OctaveExecuteReader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
- Enclosing class:
- OctaveReaderCallable
final class OctaveReaderCallable.OctaveExecuteReader extends Reader
Reader that passes the reading on to the output from the octave process, i.e. fromOctaveReaderCallable.processReader
until the spacerOctaveReaderCallable.spacer
reached, then it returns EOF. When this reader is closed the underlying reader is slurped up to the spacer.This is used in
OctaveReaderCallable.call()
only.
-
-
Field Summary
Fields Modifier and Type Field Description private StringBuffer
buffer
The current line read fromOctaveReaderCallable.processReader
but not yet passed to a char-array byread(char[], int, int)
.private boolean
eof
Whether end of reader found.private boolean
firstLine
Whether reading the first line.
-
Constructor Summary
Constructors Constructor Description OctaveExecuteReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
int
read(char[] cbuf, int off, int len)
Reads characters into a portion of an array.-
Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, read, ready, reset, skip, transferTo
-
-
-
-
Field Detail
-
buffer
private StringBuffer buffer
The current line read fromOctaveReaderCallable.processReader
but not yet passed to a char-array byread(char[], int, int)
. If this buffer were empty, it isnull
instead, which is also the initial value. If this is not the first line, the line read fromOctaveReaderCallable.processReader
is preceded by newline before being passed tobuffer
.
-
firstLine
private boolean firstLine
Whether reading the first line. Initially, this is true. It is set to false, byread(char[], int, int)
ifbuffer
is filled for the first time.
-
eof
private boolean eof
Whether end of reader found. Initially, this is false. It is set to false, byread(char[], int, int)
ifbuffer
equalsOctaveReaderCallable.spacer
, not really end ofOctaveReaderCallable.processReader
.
-
-
Method Detail
-
read
public int read(char[] cbuf, int off, int len) throws IOException
Reads characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.- Specified by:
read
in classReader
- Parameters:
cbuf
- Destination bufferoff
- Offset at which to start storing characters.len
- Maximum number of characters to read.- Returns:
- The number of characters read,
or -1 if the end of the stream has been reached.
The latter is the case if
eof
is set which means that lineOctaveReaderCallable.spacer
has been found. - Throws:
IOException
- If an I/O error occurs. This is true in particular, if null-line has been read fromOctaveReaderCallable.processReader
.
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
-
-