Package eu.simuline.octave.exec
Class OctaveWriterCallable
- java.lang.Object
-
- eu.simuline.octave.exec.OctaveWriterCallable
-
final class OctaveWriterCallable extends Object implements Callable<Void>
Callable
that writes scripts to the octave process. Used inOctaveExec.evalRW(WriteFunctor, ReadFunctor)
only. This is complementary toOctaveReaderCallable
.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.apache.commons.logging.Log
LOG
(package private) static String
MSG_IOE_SPACER
(package private) static String
MSG_IOE_WRITE
private Writer
processWriter
The writer for scripts passed to octave.private String
spacer
A string essentially consisting of a unique hashvalue.private WriteFunctor
writeFunctor
The functor the writing task is delegated to.
-
Constructor Summary
Constructors Constructor Description OctaveWriterCallable(Writer processWriter, WriteFunctor writeFunctor, String spacer)
Creates a new OctaveWriterCallable with methodcall()
delegating writing
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Void
call()
Calling writes toprocessWriter
representing the octave process: first according towriteFunctor
, i.e. delegates toWriteFunctor.doWrites(Writer)
, then writesprintf
ofspacer
and then flush.
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
MSG_IOE_WRITE
static final String MSG_IOE_WRITE
- See Also:
- Constant Field Values
-
MSG_IOE_SPACER
static final String MSG_IOE_SPACER
- See Also:
- Constant Field Values
-
processWriter
private final Writer processWriter
The writer for scripts passed to octave. This is nothing butOctaveExec.processWriter
.
-
writeFunctor
private final WriteFunctor writeFunctor
The functor the writing task is delegated to.
-
spacer
private final String spacer
A string essentially consisting of a unique hashvalue. It is printed toprocessWriter
after having appliedwriteFunctor
. That way the accordingOctaveReaderCallable
detects the end of the read sequence from the octave process.
-
-
Constructor Detail
-
OctaveWriterCallable
OctaveWriterCallable(Writer processWriter, WriteFunctor writeFunctor, String spacer)
Creates a new OctaveWriterCallable with methodcall()
delegating writing- Parameters:
processWriter
- the writer used for writing.writeFunctor
- the functor the writing process is delegated to.spacer
- a string essentially consisting of a unique hashvalue printed after applying the write functor. This indicates the end of the sunbsequent according reading process inOctaveExec.evalRW(WriteFunctor, ReadFunctor)
.
-
-
Method Detail
-
call
public Void call()
Calling writes toprocessWriter
representing the octave process: first according towriteFunctor
, i.e. delegates toWriteFunctor.doWrites(Writer)
, then writesprintf
ofspacer
and then flush. That way,OctaveReaderCallable.call()
knows, that reading is completed, as soon as the spacer is detected. Exceptions are logged onLOG
.- Specified by:
call
in interfaceCallable<Void>
- Throws:
OctaveIOException
- if the underlyingwriteFunctor
orprocessWriter
throws anIOException
.
-
-