Package org.geotools.process
Class ProgressTask
Object
ProgressTask
An implementation of the Progress interface.
- Author:
- gdavis, Jody
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionProgressTask
(Process process, Map<String, Object> input) Creates a ProgressTask that will execute the given Process when run. -
Method Summary
Modifier and TypeMethodDescriptionboolean
cancel
(boolean mayInterruptIfRunning) protected void
done()
This protected method is invoked when this process transitions to state isDone (whether normally or via cancellation).get()
float
Amount of work completed.boolean
boolean
isDone()
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
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.
-
Constructor Details
-
ProgressTask
Creates a ProgressTask that will execute the given Process when run.- Parameters:
process
- the process to executeinput
- 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 interfaceProgress
- Returns:
- Percent completed, or WORKING if amount of work is unknown.
-
isCancelled
public boolean isCancelled()- Specified by:
isCancelled
in interfaceFuture<Map<String,
Object>>
-
isDone
public boolean isDone() -
cancel
public boolean cancel(boolean mayInterruptIfRunning) -
get
- Specified by:
get
in interfaceFuture<Map<String,
Object>> - Throws:
InterruptedException
ExecutionException
-
get
public Map<String,Object> get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
get
in interfaceFuture<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
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
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. -
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
-