Class Options<O>

  • Type Parameters:
    O - The class of the received messages. Either String or byte[].

    public class Options<O>
    extends java.lang.Object
    This is class is a simple container for options given to the constructor of StdioBridge. The meaning of each option is explained at its setter method.
    • Constructor Detail

      • Options

        public Options​(java.lang.Class<O> resultType)
    • Method Detail

      • getTerminationSignalFromErrorStream

        public java.lang.String getTerminationSignalFromErrorStream()
      • setTerminationSignalFromErrorStream

        public void setTerminationSignalFromErrorStream​(java.lang.String terminationSignalFromErrorStream)
      • getExternalProgramReadySignal

        public java.lang.String getExternalProgramReadySignal()
      • setExternalProgramReadySignal

        public void setExternalProgramReadySignal​(java.lang.String externalProgramReadySignal)
      • isGzipSentData

        public boolean isGzipSentData()
      • setGzipSentData

        public void setGzipSentData​(boolean gzipSentData)
        Whether or not the data sent to the external program should be compressed in GZIP format or left untouched. This should be left at false because the compression introduces a large time overhead.
        Parameters:
        gzipSentData - If the sent data should be compressed.
      • isGzipReceivedData

        public boolean isGzipReceivedData()
      • setGzipReceivedData

        public void setGzipReceivedData​(boolean gzipReceivedData)
        Whether or not the data received from the external program should be decompressed from GZIP format or left untouched. This should be left at false, if possible, because the compression introduces a large time overhead.
        Parameters:
        gzipReceivedData - If the received data should be decompressed.
      • getResultType

        public java.lang.Class<O> getResultType()
      • getResultReshaper

        public java.util.function.Function<O,​O> getResultReshaper()
      • setResultReshaper

        public void setResultReshaper​(java.util.function.Function<O,​O> resultReshaper)
        The result reshaper is a method that takes the received line from the external process and transforms it into the final format. This is used to remove markers on the input line that indicate the line to be a result line in contrast to other program output. For example, lines could be prefixed with Output: to indicate lines that are meant for the Java program to read.
        Parameters:
        resultReshaper - The result reshaper.
      • getExecutable

        public java.lang.String getExecutable()
      • setExecutable

        public void setExecutable​(java.lang.String executable)
        The name of the external program to execute. For Python programs this would by python, for example, or even another version specific path like /usr/local/bin/python36.
        Parameters:
        executable - The path to the executable for the external program.
      • getResultLineIndicator

        public java.util.function.Predicate<O> getResultLineIndicator()
      • setResultLineIndicator

        public void setResultLineIndicator​(java.util.function.Predicate<O> resultLineIndicator)
        A Predicate that is used to find the actual output lines of the external program. This is useful when the external process might output not only result lines meant to receive by the Java side but also other messages. Then, the external program could indicate lines to actually be received with a prefix like Result:, for example. The predicate would then need to recognize lines beginning with this prefix to filter out undesired lines. No predicate has to be defined. However, without a predicate, the external program is only allowed to output exactly one line per request. Otherwise, we might miss the actual data lines we are interested in because we can never know when the external process has sent all data. With the predicate set, we will wait for each StdioBridge.receive() call for the next line to occur that is accepted by the predicate.
        Parameters:
        resultLineIndicator - A predicate to filter output lines, may be null.
      • getExternalProgramTerminationSignal

        public java.lang.String getExternalProgramTerminationSignal()
      • setExternalProgramTerminationSignal

        public void setExternalProgramTerminationSignal​(java.lang.String externalProgramTerminationSignal)
        To gracefully terminate the external process, some signal like quit or exit could be accepted by the external program as signal to end the application. If such a signal is accepted, provide it here. It is sent to the external process on StdioBridge.stop().
        Parameters:
        externalProgramTerminationSignal - A string that signals the external process to end.
      • getMultilineResponseDelimiter

        public java.lang.String getMultilineResponseDelimiter()
      • setMultilineResponseDelimiter

        public void setMultilineResponseDelimiter​(java.lang.String multilineResponseDelimiter)
        If the external program may respond with multiple lines per StdioBridge.send(String) call, there must be a signal to indicate that the response is complete. This signal is the multilineResponseDelimiter. Setting this field does activate the possibility to receive multiple lines of response for a single request.
        Parameters:
        multilineResponseDelimiter -