66package matlabcontrol ;
77
88import java .io .File ;
9+ import java .io .Writer ;
910import java .util .concurrent .atomic .AtomicLong ;
1011
1112import matlabcontrol .MatlabProxyFactory .CopyPasteCallback ;
@@ -32,6 +33,8 @@ public class MatlabProxyFactoryOptions {
3233 private final String _licenseFile ;
3334 private final boolean _useSingleCompThread ;
3435 private final int _port ;
36+ private final Writer _inputWriter ;
37+ private final Writer _errorWriter ;
3538
3639 private MatlabProxyFactoryOptions (Builder options ) {
3740 _matlabLocation = options ._matlabLocation ;
@@ -46,6 +49,8 @@ private MatlabProxyFactoryOptions(Builder options) {
4649 _licenseFile = options ._licenseFile ;
4750 _useSingleCompThread = options ._useSingleCompThread ;
4851 _port = options ._port ;
52+ _inputWriter = options ._inputWriter ;
53+ _errorWriter = options ._errorWriter ;
4954 }
5055
5156 String getMatlabLocation () {
@@ -95,6 +100,14 @@ boolean getUseSingleComputationalThread() {
95100 int getPort () {
96101 return _port ;
97102 }
103+
104+ public Writer getInputWriter () {
105+ return _inputWriter ;
106+ }
107+
108+ public Writer getErrorWriter () {
109+ return _errorWriter ;
110+ }
98111
99112 /**
100113 * Creates instances of {@link MatlabProxyFactoryOptions}. Any and all of these properties may be left unset, if so
@@ -127,6 +140,8 @@ public static class Builder {
127140 private volatile String _licenseFile = null ;
128141 private volatile boolean _useSingleCompThread = false ;
129142 private volatile int _port = 2100 ;
143+ private volatile Writer _inputWriter ;
144+ private volatile Writer _errorWriter ;
130145
131146 //Assigning to a long is not atomic, so use an AtomicLong so that a thread always sees an intended value
132147 private final AtomicLong _proxyTimeout = new AtomicLong (180000L );
@@ -386,6 +401,30 @@ public final Builder setPort(int port) {
386401
387402 return this ;
388403 }
404+
405+ /**
406+ * Sets the input writer where the standard output of the created matlab process is written to.
407+ * This is only used when an actual process is spawned for the matlab proxy instance.
408+ *
409+ * @param inputWriter
410+ */
411+ public final Builder setInputWriter (Writer inputWriter ){
412+ _inputWriter = inputWriter ;
413+
414+ return this ;
415+ }
416+
417+ /**
418+ * Sets the error writer where the error output of the created matlab process is written to.
419+ * This is only used when an actual process is spawned for the matlab proxy instance.
420+ *
421+ * @param inputWriter
422+ */
423+ public final Builder setErrorWriter (Writer errorWriter ){
424+ _errorWriter = errorWriter ;
425+
426+ return this ;
427+ }
389428
390429 /**
391430 * Builds a {@code MatlabProxyFactoryOptions} instance.
@@ -396,4 +435,5 @@ public final MatlabProxyFactoryOptions build() {
396435 return new MatlabProxyFactoryOptions (this );
397436 }
398437 }
438+
399439}
0 commit comments