ADK CVS

tryllian.afc.task
Class TaskState

java.lang.Object
  extended bytryllian.afc.task.TaskState
All Implemented Interfaces:
java.io.Serializable

public class TaskState
extends java.lang.Object
implements java.io.Serializable

State information for tasks. There is always one state associated with a task.

There are six basic states.

There is one substate of the Active state. . In addition, there are some derived states.

See Also:
Serialized Form

Field Summary
static int ACTIVE
          The task is performing.
static int FAILED
          The task has failed.
static int GOING_TO_FAIL
          The task has decided to fail, but no events are sent yet.
static int GOING_TO_SUCCEED
          The task has decided to succeed, but no events are sent yet.
static int JUST_CREATED
          The task has been created but it has not received any events yet.
static int JUST_STARTED
          The task is just (being) started.
static int SUCCEEDED
          The task has completed with success.
 
Constructor Summary
TaskState()
          Creates a new TaskState.
 
Method Summary
 boolean isActive()
          Returns true if the task is in the ACTIVE state or in the JUST_STARTED state, which is considered a substate of ACTIVE.
 boolean isFailed()
          Returns true if the task is in the FAILED state.
 boolean isFinished()
          Returns true if the task is either in the state SUCCEEDED or FAILED.
 boolean isGoingToFail()
          Returns true if the task is in the GOING_TO_FAIL state.
 boolean isGoingToFinish()
          Returns true if the task is either in the state GOING_TO_SUCCEED or GOING_TO_FAIL.
 boolean isGoingToSucceed()
          Returns true if the task is in the GOING_TO_SUCCEED state.
 boolean isIdle()
          Returns true if the task is either in the state JUST_CREATED or 'finished'.
 boolean isJustCreated()
          Returns true if the task is in the JUST_CREATED state.
 boolean isJustStarted()
          Returns true if the task is in the JUST_STARTED state.
 boolean isNoLongerActive()
          Returns true if it is past the ACTIVE state.
 boolean isSucceeded()
          Returns true if the task is in the SUCCEEDED state.
protected  void stateChanged(int oldState, int newState)
          This method is called when the state changes.
 void switchTo(int newState)
          Changes the state.
 java.lang.String toString()
          Returns a human-readable string of the state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JUST_CREATED

public static final int JUST_CREATED
The task has been created but it has not received any events yet.

See Also:
Constant Field Values

JUST_STARTED

public static final int JUST_STARTED
The task is just (being) started. The task is in this state during execution of the methods Task#taskStarted() and of TaskListener.taskStarted(TaskEvent).for listeners to this task.

See Also:
Constant Field Values

ACTIVE

public static final int ACTIVE
The task is performing.

See Also:
Constant Field Values

GOING_TO_SUCCEED

public static final int GOING_TO_SUCCEED
The task has decided to succeed, but no events are sent yet.

See Also:
Constant Field Values

GOING_TO_FAIL

public static final int GOING_TO_FAIL
The task has decided to fail, but no events are sent yet.

See Also:
Constant Field Values

SUCCEEDED

public static final int SUCCEEDED
The task has completed with success.

See Also:
Constant Field Values

FAILED

public static final int FAILED
The task has failed.

See Also:
Constant Field Values
Constructor Detail

TaskState

public TaskState()
Creates a new TaskState.

Method Detail

switchTo

public void switchTo(int newState)
Changes the state.

Parameters:
newState - one of the class's state constants.
Throws:
java.lang.IllegalArgumentException - if the state transition is invalid.

stateChanged

protected void stateChanged(int oldState,
                            int newState)
This method is called when the state changes. It does nothing, but can be overriden to do something useful.


isJustCreated

public boolean isJustCreated()
Returns true if the task is in the JUST_CREATED state.


isJustStarted

public boolean isJustStarted()
Returns true if the task is in the JUST_STARTED state.


isActive

public boolean isActive()
Returns true if the task is in the ACTIVE state or in the JUST_STARTED state, which is considered a substate of ACTIVE.


isSucceeded

public boolean isSucceeded()
Returns true if the task is in the SUCCEEDED state.


isFailed

public boolean isFailed()
Returns true if the task is in the FAILED state.


isGoingToSucceed

public boolean isGoingToSucceed()
Returns true if the task is in the GOING_TO_SUCCEED state.


isGoingToFail

public boolean isGoingToFail()
Returns true if the task is in the GOING_TO_FAIL state.


isFinished

public boolean isFinished()
Returns true if the task is either in the state SUCCEEDED or FAILED.


isGoingToFinish

public boolean isGoingToFinish()
Returns true if the task is either in the state GOING_TO_SUCCEED or GOING_TO_FAIL.


isIdle

public boolean isIdle()
Returns true if the task is either in the state JUST_CREATED or 'finished'.


isNoLongerActive

public boolean isNoLongerActive()
Returns true if it is past the ACTIVE state.


toString

public java.lang.String toString()
Returns a human-readable string of the state.


Copyright 2005, Tryllian Solutions B.V.