Class OctaveEngineFactory


  • public final class OctaveEngineFactory
    extends Object
    Factory that creates OctaveEngines. First of all, create an OctaveEngineFactory using the default constructor OctaveEngineFactory() then, optionally, change parameters and finally create an Octave Engine using getScriptEngine() with the current parameters. To set a parameter, use the various setter methods. In the documentation of each setter method, also the default value is documented which is used to create an OctaveEngine if the setter method is not invoked. Note that setter methods return the factory after modification and so setter methods may be queued also.
    • Field Detail

      • PROPERTY_EXECUTABLE

        public static final String PROPERTY_EXECUTABLE
        The custom system property which determines where the executable is found if octaveProgramFile is not set. A custom property is set when invoking the runtime with the option -D For example java -Deu.simuline.octave.executable=myoctave Application runs class Application setting the system property eu.simuline.octave.executable to
        See Also:
        Constant Field Values
      • octaveInputLog

        private Writer octaveInputLog
        If this is not null, the octave engine created writes the output to that log writer also. By default, this is null. The according setter method is setOctaveInputLog(Writer).
      • charset

        public Charset charset
        The character set used to transform input stream , output stream and error stream for 'octave process'. The default value is StandardCharsets.UTF_8 which is the only value for octave TBD: reference.
      • octaveProgramFile

        private File octaveProgramFile
        The file containing the octave program or is null. In the latter case, the name of the octave program command is determined as described for octaveProgramCmd. By default, this is null. The according setter method is setOctaveProgramFile(File).
      • argsArray

        private String[] argsArray
        The array of arguments of the octave engines created. For details, see octave user manual, version 5.2.0, Section 2.1.1.

        Default value of this field is default value for octave engines created. The default value consists of the following components:

        • --silent: prevents octave from printing the usual greeting and version message at startup.
        • --no-init-file, --no-site-file prevents octave from reading the initialization files ~/.octaverc, .octaverc and site-wide octaverc.
        The only mandatory argument is --silent: If not set this, octave's greeting message causes an exception. Option --no-init-file makes the result independent of user input, whereas --no-init-file and --no-site-file makes it independent of initialization files. Since this is used to create scripting engines, line editing and history seem superfluous and so --no-line-editing and --no-history seem appropriate. Note that --no-init-file and --no-site-file may be appropriate or not. Instead of combining --no-init-file and --no-site-file equivalently one can specify --norc. As this is the default, --no-gui? is not needed. TBD: discuss --no-window-system Note that this array may be empty but can never be null.
      • environment

        private String[] environment
        An array of strings of the form name=value representing the environment, i.e. the set of environment variables or null. In the latter case, the environment is inherited from the current process. This field is initialized with null.
      • workingDir

        private File workingDir
        The file representing the working directory or null. In the latter case, the working directory is inherited from the current process. By default, this is null.
      • numThreadsReuse

        private int numThreadsReuse
        The number of threads to be reused or -1 if there is no limit. By default, this is 2.
    • Constructor Detail

      • OctaveEngineFactory

        public OctaveEngineFactory()
        Default constructor creating a factory with default parameters.
    • Method Detail

      • getScriptEngine

        public OctaveEngine getScriptEngine()
        Returns a script engine with the parameters set for this factory.
        Returns:
        a new OctaveEngine with the current parameters.
      • setOctaveInputLog

        public OctaveEngineFactory setOctaveInputLog​(Writer octaveInputLog)
        Setter method for octaveInputLog.
        Parameters:
        octaveInputLog - the octave input log to set or null if no such log is wanted.
        Returns:
        this octave engine factory after modification.
      • setErrorWriter

        public OctaveEngineFactory setErrorWriter​(Writer errWriter)
        Setter method for errWriter.
        Parameters:
        errWriter - the errWriter to set This may be null TBC
        Returns:
        this octave engine factory after modification.
      • setOctaveProgramFile

        public OctaveEngineFactory setOctaveProgramFile​(File octaveProgramFile)
        Setter method for octaveProgramFile.
        Parameters:
        octaveProgramFile - the octaveProgramFile to set or null.
        Returns:
        this octave engine factory after modification.
      • setArgsArray

        public OctaveEngineFactory setArgsArray​(String[] argsArray)
        Sets an array of arguments argsArray used when creating an OctaveEngine. The validity of the argument string is not proved. Note that subsequent changes on the array argsArray do not have any influence on this factory. The default options and a discussion of necessary options are documented with argsArray.
        Parameters:
        argsArray - the arguments as an array to set
        Returns:
        this octave engine factory after modification.
        Throws:
        NullPointerException - if argsArray is null or contains a null entry.
      • setCharset

        public OctaveEngineFactory setCharset​(Charset charset)
        Sets the encoding of input, output and error stream of the 'octave process'. The appropriate value for octave seems to be StandardCharsets.UTF_8 so this method may be used rarely.
        Parameters:
        charset - the new charset.
        Returns:
        this octave engine factory after modification.
        Throws:
        NullPointerException - if charset is null.
      • setEnvironment

        public OctaveEngineFactory setEnvironment​(String[] environment)
        Setter method for environment. Note that subsequent changes on the array environment do not have any influence on this factory. The details are documented with environment.
        Parameters:
        environment - the environment
        • as an array of entries of the form name=value
        • or null signifying that the environment is inherited from the invoking process.
        Returns:
        this octave engine factory after modification.
      • setWorkingDir

        public OctaveEngineFactory setWorkingDir​(File workingDir)
        Setter method for workingDir.
        Parameters:
        workingDir - the working directory to set or null signifying the current directory.
        Returns:
        this octave engine factory after modification.
      • setNumThreadsReuse

        public OctaveEngineFactory setNumThreadsReuse​(int numThreadsReuse)
        Sets the number of threads to be reused or -1 which indicates no limit. The default value is 2 but this can be speed optimized depending on the hardware. The number of threads to be created shall be positive or -1 otherwise throwing an exception.
        Parameters:
        numThreadsReuse - the number of threads for reuse which is positive or -1
        Returns:
        this octave engine factory after modification.