au.com.prunge.util
Interface ProgressObservable

All Known Implementing Classes:
LocalDeleteItemOperation, LocalFastCopyItemOperation

public interface ProgressObservable

An interface to allow the monitoring of progress of operations.

Users of operations and any other classes that require progress observation may test whether the operation allows its progress to be observed by testing with the instanceof operator. e.g.

 if (operation instanceof ProgressObservable)
 {
     ProgressObservable progObs = (ProgressObservable)operation;
     ... (code to observe progress in another thread)
 }
 

Version:
1.0
Author:
Peter Runge

Method Summary
 float getProgress()
          Returns the progress of the operation.
 

Method Detail

getProgress

public float getProgress()
Returns the progress of the operation.

getProgress() returns a value between zero (not started) and one (completed) that indicates the progress of the operation. This method may also return NaN, which means that the progress of the operation cannot be determined.

Typically progress monitoring of operations will be performed from a different thread to the one executing the operation. The progress observer can poll this method and indicate to the user the progress of the operation.

It is important that this method not be compuatationally expensive to execute. This method is quite likely to be executed on the AWT event dispatch thread in a GUI. Typically the operation will update a variable indicating the progress and this method should only return the value of the variable.

The progress value returned from this method may not be exact. For example, if the operation has finished it does not mean that this method is guarenteed to return exactly 1.0.

Returns:
a value between zero (not started) to one (completed) indicating the progress of the operation, or NaN.