Class ProgressTask

Object
ProgressTask
All Implemented Interfaces:
Runnable, Future<Map<String,Object>>, Progress

public class ProgressTask extends Object implements Runnable, Progress
An implementation of the Progress interface.
Author:
gdavis, Jody
  • Field Summary

    Fields inherited from interface Progress

    WORKING
  • Constructor Summary

    Constructors
    Constructor
    Description
    ProgressTask(Process process, Map<String,Object> input)
    Creates a ProgressTask that will execute the given Process when run.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    cancel(boolean mayInterruptIfRunning)
     
    protected void
    This protected method is invoked when this process transitions to state isDone (whether normally or via cancellation).
    get()
     
    get(long timeout, TimeUnit unit)
     
    float
    Amount of work completed.
    boolean
     
    boolean
     
    void
    run()
    Sets this ProgressTask to the result of the computation unless it has been canceled.
    protected boolean
    Executes the process without setting its result, and then resets this ProgressTask to its initial state, failing to do so if the computation encounters an exception or is canceled.
    protected void
    set(Map<String,Object> value)
    Sets the result of this ProgressTask to the given value unless this ProgressTask has already been set or has been canceled.
    protected void
    Causes this ProgressTask to report an ExecutionException with the given throwable as its cause, unless this ProgressTask has already been set or has been canceled.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ProgressTask

      public ProgressTask(Process process, Map<String,Object> input)
      Creates a ProgressTask that will execute the given Process when run.
      Parameters:
      process - the process to execute
      input - the inputs to use when executing the process
      Throws:
      NullPointerException - if process is null
  • Method Details

    • getProgress

      public float getProgress()
      Description copied from interface: Progress
      Amount of work completed.
      Specified by:
      getProgress in interface Progress
      Returns:
      Percent completed, or WORKING if amount of work is unknown.
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface Future<Map<String,Object>>
    • isDone

      public boolean isDone()
      Specified by:
      isDone in interface Future<Map<String,Object>>
    • cancel

      public boolean cancel(boolean mayInterruptIfRunning)
      Specified by:
      cancel in interface Future<Map<String,Object>>
    • get

      Specified by:
      get in interface Future<Map<String,Object>>
      Throws:
      InterruptedException
      ExecutionException
    • get

      Specified by:
      get in interface Future<Map<String,Object>>
      Throws:
      InterruptedException
      ExecutionException
      TimeoutException
    • done

      protected void done()
      This protected method is invoked when this process transitions to state isDone (whether normally or via cancellation). The default implementation does nothing. Subclasses may override this method to invoke completion callbacks. You can query status inside the implementation of this method to determine whether this task has been canceled.
    • set

      protected void set(Map<String,Object> value)
      Sets the result of this ProgressTask to the given value unless this ProgressTask has already been set or has been canceled.
      Parameters:
      value - the value to set
    • setException

      protected void setException(Throwable t)
      Causes this ProgressTask to report an ExecutionException with the given throwable as its cause, unless this ProgressTask has already been set or has been canceled.
      Parameters:
      t - the cause of failure.
    • run

      public void run()
      Sets this ProgressTask to the result of the computation unless it has been canceled.
      Specified by:
      run in interface Runnable
    • runAndReset

      protected boolean runAndReset()
      Executes the process without setting its result, and then resets this ProgressTask to its initial state, failing to do so if the computation encounters an exception or is canceled. This is designed for use with processes that execute more than once.
      Returns:
      true if successfully run and reset