org.netbeans.microedition.util
Class SimpleCancellableTask

java.lang.Object
  extended by org.netbeans.microedition.util.SimpleCancellableTask
All Implemented Interfaces:
java.lang.Runnable, CancellableTask

public class SimpleCancellableTask
extends java.lang.Object
implements CancellableTask

A simple implementation of CancellableTask. This implementation uses a supplied Runnable object, which is being run when this task starts.


Constructor Summary
SimpleCancellableTask()
          Creates a new instance of SimpleCancellableTask
SimpleCancellableTask(Executable executable)
          Creates a new instance of SimpleCancellableTask with supplied executable object
 
Method Summary
 boolean cancel()
          Cancel this task.
 java.lang.String getFailureMessage()
          Gets the failure message of the failed task.
 boolean hasFailed()
          Checks whether the task has failed.
 void run()
          Implementation of run method.
 void setExecutable(Executable executable)
          Sets the executable object for this task.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleCancellableTask

public SimpleCancellableTask()
Creates a new instance of SimpleCancellableTask


SimpleCancellableTask

public SimpleCancellableTask(Executable executable)
Creates a new instance of SimpleCancellableTask with supplied executable object

Parameters:
executable - Executable to be used for execution.
Method Detail

setExecutable

public void setExecutable(Executable executable)
Sets the executable object for this task. Also resets the failure message and the failure state.

Parameters:
executable - Executable to be used for execution.

cancel

public boolean cancel()
Cancel this task. In this implementation this method does not cancel the runnable task, this it always returns false.

Specified by:
cancel in interface CancellableTask
Returns:
always returns false

getFailureMessage

public java.lang.String getFailureMessage()
Gets the failure message of the failed task. Since this implementation considers as a failure an exception from the Runnable object (more exactly run() method), this methods returns a message from this exception.

Specified by:
getFailureMessage in interface CancellableTask
Returns:
Message from failure exception

hasFailed

public boolean hasFailed()
Checks whether the task has failed. In this implementation this means the the execute() method of the supplied Executable object has thrown an exception.

Specified by:
hasFailed in interface CancellableTask
Returns:
true when the task has failed.

run

public void run()
Implementation of run method. This method basically calls execute() method from the suplied Executable object.

Specified by:
run in interface java.lang.Runnable