Class OctaveExec


  • public final class OctaveExec
    extends Object
    The object connecting to the octave process.
    • Constructor Detail

      • OctaveExec

        public OctaveExec​(int numThreadsReuse,
                          Writer stdinLog,
                          Writer stderrLog,
                          Charset charset,
                          String[] cmdArray,
                          String[] environment,
                          File workingDir)
        Will start the octave process.
        Parameters:
        numThreadsReuse - the number of threads to be reused in a fixed thread pool. This is either positive or -1, which means that a cached thread pool is used instead of a fixed one.
        stdinLog - This writer will capture all that is written to the octave process via stdin, if null the data will not be captured.
        stderrLog - This writer will capture all that is written from the octave process on stderr, if null the data will not be captured.
        charset - the charset used for communication with the octave process.
        cmdArray - The array consisting of command and arguments: The 0th entry is either the path to the octave program, or the command found by looking at the built-in variable "paths" reconstructing the path. starting with the 1th entry, may follow the array of arguments to start the octave program with. CAUTION: allowed values depend on the octave version.
        environment - Either the environment for the octave process, i.e. the set of values of environment variables with each entry of the form name=value or null to make process, the process created, inherit the environment of the current process.
        workingDir - Either the working directory for the octave process, or null to make process, the process created, inherit the working directory of the current process.
        Throws:
        OctaveIOException - If execution
    • Method Detail

      • generateSpacer

        private String generateSpacer()
      • evalRW

        public void evalRW​(WriteFunctor input,
                           ReadFunctor output)
        Passes input to octave, get back output and throws according exceptions if reading or writing went wrong.
        Parameters:
        input - a write functor which represents the script to be executed in octave.
        output - the read functor which reads the result of octave execution. After evaluation of this method, the output is asked for the result.
      • getFromFuture

        private RuntimeException getFromFuture​(Future<Void> future)
        Completes computation on future and returns an exception thrown or null.
      • setDestroyed

        private void setDestroyed​(boolean destroyed)
        Sets destroyed to the parameter value given.
      • isDestroyed

        private boolean isDestroyed()
        Returns destroyed.
      • destroy

        public void destroy()
        Kill the octave process without remorse.
      • close

        public void close()
        Close the octave process in an orderly fashion: Send command exit and expect a single line in return, namely an empty one.
        Throws:
        OctaveIOException - if
      • setErrorWriter

        public void setErrorWriter​(Writer writer)
        Parameters:
        writer - the new writer to write the error output to