kiwi.util
Class Task

java.lang.Object
  |
  +--kiwi.util.Task
All Implemented Interfaces:
java.lang.Runnable

public abstract class Task
extends java.lang.Object
implements java.lang.Runnable

This class represents an asynchronous task whose progress can be tracked by a ProgressObserver.

Author:
Mark Lindner, PING Software Group
See Also:
ProgressObserver, kiwi.ui.dialog.ProgressDialog, Runnable

Field Summary
private  java.util.Vector observers
           
 
Constructor Summary
Task()
          Construct a new Task.
 
Method Summary
 void addProgressObserver(ProgressObserver observer)
          Add a progress observer to this task's list of observers.
protected  void notifyObservers(int percent)
          Notify all observers about the percentage of the task completed.
 void removeProgressObserver(ProgressObserver observer)
          Remove a progress observer from this task's list of observers.
abstract  void run()
          Run the task.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

observers

private java.util.Vector observers
Constructor Detail

Task

public Task()
Construct a new Task.
Method Detail

run

public abstract void run()
Run the task. This method is the body of the thread for this task.
Specified by:
run in interface java.lang.Runnable

addProgressObserver

public final void addProgressObserver(ProgressObserver observer)
Add a progress observer to this task's list of observers. Observers are notified by the task of progress made.
Parameters:
observer - The observer to add.

removeProgressObserver

public final void removeProgressObserver(ProgressObserver observer)
Remove a progress observer from this task's list of observers.
Parameters:
observer - The observer to remove.

notifyObservers

protected final void notifyObservers(int percent)
Notify all observers about the percentage of the task completed.
Parameters:
percent - The percentage of the task completed, an integer value between 0 and 100 inclusive. Values outside of this range are silently clipped.