Class DefaultCommandProcess

java.lang.Object
com.thebuzzmedia.exiftool.process.executor.DefaultCommandProcess
All Implemented Interfaces:
CommandProcess, AutoCloseable

public class DefaultCommandProcess extends Object implements CommandProcess
Default implementation for CommandProcess interface.
This implementation used instance of InputStream to handle read operation and instance of OutputStream to handle write operation. These streams may come from instance of Process for instance.
Note: This implementation is not thread safe.
  • Constructor Details

    • DefaultCommandProcess

      public DefaultCommandProcess(InputStream is, OutputStream os, InputStream err)
      Create process.
      Parameters:
      is - Input stream.
      os - Output stream.
      err - Error stream.
  • Method Details

    • read

      public String read() throws IOException
      Description copied from interface: CommandProcess
      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).
      Specified by:
      read in interface CommandProcess
      Returns:
      Command result.
      Throws:
      IOException - If an error occurred during operation.
    • read

      public String read(OutputHandler handler) throws IOException
      Description copied from interface: CommandProcess
      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).
      Specified by:
      read in interface CommandProcess
      Parameters:
      handler - Output handler.
      Returns:
      Full output.
      Throws:
      IOException - If an error occurred during operation.
    • write

      public void write(String input, String... others) throws IOException
      Description copied from interface: CommandProcess
      Write input string to the current process.
      Specified by:
      write in interface CommandProcess
      Parameters:
      input - Input.
      others - Other inputs.
      Throws:
      IOException - If an error occurred during operation.
    • write

      public void write(Iterable<String> inputs) throws IOException
      Description copied from interface: CommandProcess
      Write set of inputs to the current process.
      Specified by:
      write in interface CommandProcess
      Parameters:
      inputs - Collection of inputs.
      Throws:
      IOException - If an error occurred during operation.
    • flush

      public void flush() throws IOException
      Description copied from interface: CommandProcess
      Flush pending write operations.
      Specified by:
      flush in interface CommandProcess
      Throws:
      IOException - If an error occurred during operation.
    • isRunning

      public boolean isRunning()
      Description copied from interface: CommandProcess
      Check if current process is still opened. If this method returns true, then CommandProcess.isClosed() should return false.
      Specified by:
      isRunning in interface CommandProcess
      Returns:
      true if process is open, false otherwise.
    • isClosed

      public boolean isClosed()
      Description copied from interface: CommandProcess
      Check if current process has been closed. If this method returns true, then CommandProcess.isRunning() should return false.
      Specified by:
      isClosed in interface CommandProcess
      Returns:
      true if process is closed, false otherwise.
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception