Interface CommandProcess

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
DefaultCommandProcess

public interface CommandProcess extends AutoCloseable
Process interface.
A process will define some methods to:
  • Read output until a condition returns false.
  • Send input stream to the opened process.
  • Check if process is closed or still opened.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Flush pending write operations.
    boolean
    Check if current process has been closed.
    boolean
    Check if current process is still opened.
    Read output until a null line is read.
    Read output until: A null line is read. Handler returns false when line is read. Since command process will not be closed, a simple string is returned (an exit status cannot be computed).
    void
    Write set of inputs to the current process.
    void
    write(String input, String... others)
    Write input string to the current process.

    Methods inherited from interface java.lang.AutoCloseable

    close
  • Method Details

    • read

      String read() throws IOException
      Read output until a null line is read.
      Since command process will not be closed, a simple string is returned (an exit status cannot be computed).
      Returns:
      Command result.
      Throws:
      IOException - If an error occurred during operation.
    • read

      String read(OutputHandler handler) throws IOException
      Read output until:
      • A null line is read.
      • Handler returns false when line is read.
      Since command process will not be closed, a simple string is returned (an exit status cannot be computed).
      Parameters:
      handler - Output handler.
      Returns:
      Full output.
      Throws:
      IOException - If an error occurred during operation.
    • write

      void write(String input, String... others) throws IOException
      Write input string to the current process.
      Parameters:
      input - Input.
      others - Other inputs.
      Throws:
      IOException - If an error occurred during operation.
    • write

      void write(Iterable<String> inputs) throws IOException
      Write set of inputs to the current process.
      Parameters:
      inputs - Collection of inputs.
      Throws:
      IOException - If an error occurred during operation.
    • flush

      void flush() throws IOException
      Flush pending write operations.
      Throws:
      IOException - If an error occurred during operation.
    • isRunning

      boolean isRunning()
      Check if current process is still opened. If this method returns true, then isClosed() should return false.
      Returns:
      true if process is open, false otherwise.
    • isClosed

      boolean isClosed()
      Check if current process has been closed. If this method returns true, then isRunning() should return false.
      Returns:
      true if process is closed, false otherwise.