Extension SDK 10.1.2

oracle.javatools.parser.util
Class AsyncTask

java.lang.Object
  extended byoracle.javatools.parser.util.AsyncTask
All Implemented Interfaces:
java.lang.Runnable

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

The AsyncTask is a part of a basic API to allow scheduling asynchronous tasks that support cancelling while the task is running. It is recommended that JSR 166 be used when it becomes available as part of the JDK later.


Field Summary
protected static java.lang.String CANCELLED_RESULT
          Tasks that are cancelled successfully in-progress should return this cancelled result, so that the task status can be updated accordingly.
static int STATUS_CANCELLED
          Constant for cancelled status.
static int STATUS_COMPLETED
          Constant for completed successfully status.
static int STATUS_FAILED
          Constant for completed w/ failed status due to RuntimeException.
static int STATUS_READY
          Constant for ready-to-run status.
static int STATUS_RUNNING
          Constant for currently running status.
 
Constructor Summary
protected AsyncTask()
          Set up the AsyncTask in ready-to-run mode.
 
Method Summary
 java.lang.Object getResult()
          Fetch the completed result of the task (if any).
 int getStatus()
          Fetches the current status of the task.
protected  void requestCancel()
          Request to cancel the task.
protected abstract  void requestCancelImpl()
          Request to cancel the task in-progress, to be implemented by the implementation.
 void run()
          Performs the task.
protected abstract  java.lang.Object runImpl()
          Implementation of the task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_READY

public static final int STATUS_READY
Constant for ready-to-run status.

See Also:
Constant Field Values

STATUS_RUNNING

public static final int STATUS_RUNNING
Constant for currently running status.

See Also:
Constant Field Values

STATUS_COMPLETED

public static final int STATUS_COMPLETED
Constant for completed successfully status. The return result of getResult() is the return result of runImpl().

See Also:
Constant Field Values

STATUS_FAILED

public static final int STATUS_FAILED
Constant for completed w/ failed status due to RuntimeException. The runtime exception can be retrieved w/ getResult().

See Also:
Constant Field Values

STATUS_CANCELLED

public static final int STATUS_CANCELLED
Constant for cancelled status. There is no guarantee as to whether the task was started or cancelled mid-progress. There is no return result.

See Also:
Constant Field Values

CANCELLED_RESULT

protected static final java.lang.String CANCELLED_RESULT
Tasks that are cancelled successfully in-progress should return this cancelled result, so that the task status can be updated accordingly.

See Also:
Constant Field Values
Constructor Detail

AsyncTask

protected AsyncTask()
Set up the AsyncTask in ready-to-run mode.

Method Detail

getStatus

public final int getStatus()
Fetches the current status of the task.

Returns:
the current status of the task

run

public final void run()
Performs the task. This sets up the status of the task, and delegates to runImpl().

Specified by:
run in interface java.lang.Runnable

runImpl

protected abstract java.lang.Object runImpl()
Implementation of the task. Implementation-specific return results can be returned here, and will be stored in the task result. If the task is cancelled successfully in-progress, the implementation should return CANCELLED_RESULT here.

Returns:
the implementation-specific return result (if any), or CANCELLED_RESULT if the operation is cancelled

requestCancel

protected final void requestCancel()
Request to cancel the task. The task will be cancelled if possible.


requestCancelImpl

protected abstract void requestCancelImpl()
Request to cancel the task in-progress, to be implemented by the implementation. If the task supports this, return CANCELLED_RESULT from runImpl().


getResult

public final java.lang.Object getResult()
Fetch the completed result of the task (if any).

Returns:
the task result

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.