Package 

Class Shell.Job


  • 
    public abstract class Shell.Job
    
                        

    Represents a shell Job that could later be executed or submitted to background threads.

    All operations added in add and add will beexecuted in the order of addition.

    • Method Summary

      Modifier and Type Method Description
      abstract Shell.Job to(@Nullable() List<String> stdout) Store output of STDOUT to a specific list.
      abstract Shell.Job to(@Nullable() List<String> stdout, @Nullable() List<String> stderr) Store output of STDOUT and STDERR to specific lists.
      abstract Shell.Job add(@NonNull() Array<String> cmds) Add a new operation running commands.
      abstract Shell.Job add(@NonNull() InputStream in) Add a new operation serving an InputStream to STDIN.
      abstract Shell.Result exec() Execute the job immediately and returns the result.
      final void submit() Submit the job to an internal queue to run in the background.The result will be omitted.
      final void submit(@Nullable() Shell.ResultCallback cb) Submit the job to an internal queue to run in the background.The result will be returned with a callback running on the main thread.
      abstract void submit(@Nullable() Executor executor, @Nullable() Shell.ResultCallback cb) Submit the job to an internal queue to run in the background.The result will be returned with a callback executed by the provided executor.
      abstract Future<Shell.Result> enqueue() Submit the job to an internal queue to run in the background.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • add

        @NonNull() abstract Shell.Job add(@NonNull() InputStream in)

        Add a new operation serving an InputStream to STDIN.

        This is NOT executing the script like {@code sh script.sh}.This is similar to sourcing the script ({@code . script.sh}) as theraw content of the script is directly fed into STDIN. If you call {@code exit} in the script, the shell will be killed and thisshell instance will no longer be alive!

        Parameters:
        in - the InputStream to serve to STDIN.The stream will be closed after consumption.
      • submit

         final void submit()

        Submit the job to an internal queue to run in the background.The result will be omitted.

      • submit

         final void submit(@Nullable() Shell.ResultCallback cb)

        Submit the job to an internal queue to run in the background.The result will be returned with a callback running on the main thread.

        Parameters:
        cb - the callback to receive the result of the job.
      • submit

         abstract void submit(@Nullable() Executor executor, @Nullable() Shell.ResultCallback cb)

        Submit the job to an internal queue to run in the background.The result will be returned with a callback executed by the provided executor.

        Parameters:
        executor - the executor used to handle the result callback event.
        cb - the callback to receive the result of the job.