org.jdtaus.core.monitor
Class Task

java.lang.Object
  extended by org.jdtaus.core.monitor.Task
All Implemented Interfaces:
Serializable, Cloneable

public abstract class Task
extends Object
implements Cloneable, Serializable

A task of execution.

A task is a sequence of operations taking time. This class defines properties to be used by applications to query a task for information and for cancelling a task. Property indeterminate indicates if a task supports properties minimum, maximum and progress. Property cancelable indicates if a task may be cancelled by an application by setting property cancelled to true. Properties description and progressDescription hold presentation descriptions of a task itself and of the work currently performed by a task.

Version:
$Id: Task.java 8044 2009-07-02 01:29:05Z schulte2005 $
Author:
Christian Schulte
See Also:
TaskEvent, Serialized Form

Field Summary
static Comparator ASCENDING
          Comparator for sorting tasks in ascending order of creation time.
static Comparator DESCENDING
          Comparator for sorting tasks in descending order of creation time.
 
Constructor Summary
Task()
          Creates a new Task instance.
 
Method Summary
 Object clone()
          Creates and returns a copy of this object.
 boolean equals(Object o)
          Indicates whether some other object is equal to this one.
 Message getDescription()
          Getter for property description.
 int getMaximum()
          Gets the higher end of the progress value.
 int getMinimum()
          Gets the lower end of the progress value.
 int getProgress()
          Gets the progress of the task.
 Message getProgressDescription()
          Getter for property progressDescription.
 long getTimestamp()
          Getter for property timestamp.
 int hashCode()
          Returns a hash code value for this object.
 boolean isCancelable()
          Flag indicating that the task supports property cancelled.
 boolean isCancelled()
          Flag indicating that the task is cancelled.
 boolean isIndeterminate()
          Flag indicating if the task supports properties minimum, maximum and progress.
 void setCancelled(boolean value)
          Setter for property cancelled.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ASCENDING

public static final Comparator ASCENDING
Comparator for sorting tasks in ascending order of creation time.

Note:
This comparator imposes orderings that are inconsistent with equals.


DESCENDING

public static final Comparator DESCENDING
Comparator for sorting tasks in descending order of creation time.

Note:
This comparator imposes orderings that are inconsistent with equals.

Constructor Detail

Task

public Task()
Creates a new Task instance.

Method Detail

clone

public Object clone()
Creates and returns a copy of this object.

Overrides:
clone in class Object
Returns:
a clone of this instance.

equals

public final boolean equals(Object o)
Indicates whether some other object is equal to this one.

Tasks internally cary a UID which is created during instantiation. This UID is used for comparing o with the instance.

Overrides:
equals in class Object
Parameters:
o - the reference object with which to compare.
Returns:
true if this object is the same as o; false otherwise.
See Also:
UID

getDescription

public final Message getDescription()
Getter for property description.

Returns:
description of the task.

getMaximum

public final int getMaximum()
Gets the higher end of the progress value.

Returns:
an int representing the maximum value.
Throws:
IllegalStateException - if the task is indeterminate.

getMinimum

public final int getMinimum()
Gets the lower end of the progress value.

Returns:
an int representing the minimum value.
Throws:
IllegalStateException - if the task is indeterminate.

getProgress

public final int getProgress()
Gets the progress of the task.

Returns:
the progress of the task.
Throws:
IllegalStateException - if the task is indeterminate.

getProgressDescription

public final Message getProgressDescription()
Getter for property progressDescription.

Returns:
description of the progress of the task or null.

getTimestamp

public final long getTimestamp()
Getter for property timestamp.

Returns:
the timestamp this task got created.

hashCode

public final int hashCode()
Returns a hash code value for this object.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.

isCancelable

public final boolean isCancelable()
Flag indicating that the task supports property cancelled.

Returns:
true if the task supports property cancelled; false if property cancelled is ignored by the task.

isCancelled

public final boolean isCancelled()
Flag indicating that the task is cancelled.

Returns:
true if the task is cancelled; false else.
Throws:
IllegalStateException - if the task is not cancelable.

isIndeterminate

public final boolean isIndeterminate()
Flag indicating if the task supports properties minimum, maximum and progress.

Returns:
true if the operations performed by the task are of unknown length; false if properties minimum, maximum and progress hold progress information.

setCancelled

public final void setCancelled(boolean value)
Setter for property cancelled.

Applications may request cancellation of a Task by setting property cancelled to true. Implementations indicate theire support for task cancellation by property cancelable.

Parameters:
value - true to cancel the task; false else.
Throws:
IllegalStateException - if the task is not cancelable or is already cancelled.

toString

public String toString()
Returns a string representation of the object.

Overrides:
toString in class Object
Returns:
a string representation of the object.


Copyright © 2005-2009 jDTAUS. All Rights Reserved.