Class ProcessResult

java.lang.Object
org.refcodes.runtime.ProcessResult
All Implemented Interfaces:
org.refcodes.mixin.ResultAccessor<String,​RuntimeException>

public class ProcessResult
extends Object
implements org.refcodes.mixin.ResultAccessor<String,​RuntimeException>
Retrieves the Result of the given process as String.
  • Constructor Details

    • ProcessResult

      public ProcessResult​(Process aProcess) throws IOException
      Constructs a ProcessResult instance which will synchronously return the process' result via getResult() (and toString() accordingly).
      Parameters:
      aProcess - The Process from which to retrieve the result.
      Throws:
      IOException - Thrown in case there were problems retrieving the result. If possible, the error stream of the process is captured in the exception's message.
    • ProcessResult

      public ProcessResult​(Process aProcess, int aTimeoutMillis) throws InterruptedException, IOException
      Constructs a ProcessResult instance which will synchronously return the process' result via getResult() (and toString() accordingly).
      Parameters:
      aProcess - The Process from which to retrieve the result.
      aTimeoutMillis - The time to wait till to terminate with an InterruptedException.
      Throws:
      IOException - Thrown in case there were problems retrieving the result. If possible, the error stream of the process is captured
      InterruptedException - Thrown in case the timeout has exceeded before process' termination.
  • Method Details

    • getResult

      public String getResult()
      Specified by:
      getResult in interface org.refcodes.mixin.ResultAccessor<String,​RuntimeException>
    • hasResult

      public boolean hasResult()
      Specified by:
      hasResult in interface org.refcodes.mixin.ResultAccessor<String,​RuntimeException>
    • toString

      public String toString()
      Overrides:
      toString in class Object