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.processReaderuntil the spacerOctaveReaderCallable.spacerreached, 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 StringBufferbufferThe current line read fromOctaveReaderCallable.processReaderbut not yet passed to a char-array byread(char[], int, int).private booleaneofWhether end of reader found.private booleanfirstLineWhether reading the first line.
-
Constructor Summary
Constructors Constructor Description OctaveExecuteReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()intread(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.processReaderbut not yet passed to a char-array byread(char[], int, int). If this buffer were empty, it isnullinstead, which is also the initial value. If this is not the first line, the line read fromOctaveReaderCallable.processReaderis 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)ifbufferis 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)ifbufferequalsOctaveReaderCallable.spacer, not really end ofOctaveReaderCallable.processReader.
-
-
Method Detail
-
read
public int read(char[] cbuf, int off, int len) throws IOExceptionReads 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:
readin 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
eofis set which means that lineOctaveReaderCallable.spacerhas 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException
-
-