org.enhydra.shark.api.client.wfmc.wapi
Class WMObjectState

java.lang.Object
  extended byorg.enhydra.shark.api.client.wfmc.wapi.WMObjectState
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
WMActivityInstanceState, WMProcessDefinitionState, WMProcessInstanceState, WMWorkItemState

public abstract class WMObjectState
extends java.lang.Object
implements java.io.Serializable

Abstract base that represents the state of an object.

Author:
Adrian Price
See Also:
Serialized Form

Field Summary
protected  int _state
          The object state code.
static int DEFAULT_INT
          Signifies that the object remains in its current state.
static int FORCED_ACTION
          Action is illegal to API caller, but is being forced by the engine.
static int ILLEGAL_ACTION
          Action is invalid for the current state.
static int NO_ACTION
          Action does not cause a state transition.
 
Constructor Summary
  WMObjectState()
           
protected WMObjectState(int state)
          Construct a new WMObjectState.
 
Method Summary
 int checkTransition(int newState, boolean throwException)
          Returns the action required to transition to a specified state.
 int checkTransition(WMObjectState newState, boolean throwException)
          Returns the action required to transition to a specified state.
 boolean equals(java.lang.Object obj)
          Tests for object identity.
 int get_state()
           
protected abstract  int[] getActionsByState()
          Returns the transitions from the current state, indexed by new state.
 WMObjectState[] getStates()
          Returns the list of states to which legal transitions are possible.
protected abstract  int[] getStatesByAction()
          Returns the transitions from the current state, indexed by action.
protected abstract  java.lang.String[] getTags()
          Returns the list of all state tags applicable to this instance's class.
 int getValue()
          JavaBean-compliant property accessor, synonym for value().
protected abstract  WMObjectState[] getValues()
          Returns the list of all state values applicable to this instance's class.
 int hashCode()
          Equal objects must have equal hash codes.
protected  java.lang.Object readResolve()
           
 void set_state(int _state)
           
protected  int stateFromAction(int action)
          Returns the state that would result from a specified action.
 java.lang.String stringValue()
          Returns the object state as a string.
 java.lang.String toString()
           
 int value()
          Returns the object state as an integer.
protected static WMObjectState valueOf(java.lang.String[] tags, WMObjectState[] values, java.lang.String state)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_INT

public static final int DEFAULT_INT
Signifies that the object remains in its current state.

See Also:
Constant Field Values

NO_ACTION

public static final int NO_ACTION
Action does not cause a state transition.

See Also:
Constant Field Values

ILLEGAL_ACTION

public static final int ILLEGAL_ACTION
Action is invalid for the current state.

See Also:
Constant Field Values

FORCED_ACTION

public static final int FORCED_ACTION
Action is illegal to API caller, but is being forced by the engine.

See Also:
Constant Field Values

_state

protected int _state
The object state code.

Constructor Detail

WMObjectState

protected WMObjectState(int state)
Construct a new WMObjectState. The array type parameters are references to arrays statically defined in the calling subclass.

Parameters:
state - The integer code for this state.

WMObjectState

public WMObjectState()
Method Detail

valueOf

protected static WMObjectState valueOf(java.lang.String[] tags,
                                       WMObjectState[] values,
                                       java.lang.String state)

getStates

public final WMObjectState[] getStates()
Returns the list of states to which legal transitions are possible.

Returns:
List of legal states.

stateFromAction

protected final int stateFromAction(int action)
                             throws WMTransitionNotAllowedException
Returns the state that would result from a specified action.

Parameters:
action - Action code.
Returns:
State code.
Throws:
WMTransitionNotAllowedException - if the specified action is inapplicable to the current state.

checkTransition

public final int checkTransition(WMObjectState newState,
                                 boolean throwException)
                          throws WMTransitionNotAllowedException
Returns the action required to transition to a specified state.

Parameters:
newState - The new state required.
throwException - Causes an exception to be thrown if the transition would be illegal.
Returns:
Action code.
Throws:
WMTransitionNotAllowedException - if a transition from the current state to the new state would be illegal.

checkTransition

public final int checkTransition(int newState,
                                 boolean throwException)
                          throws WMTransitionNotAllowedException
Returns the action required to transition to a specified state.

Parameters:
newState - The new state required.
throwException - Causes an exception to be thrown if the transition would be illegal.
Returns:
Action code.
Throws:
WMTransitionNotAllowedException - if a transition from the current state to the new state would be illegal.

getTags

protected abstract java.lang.String[] getTags()
Returns the list of all state tags applicable to this instance's class. The array is indexed by state code. This is be a reference to a final array defined statically in the instance's subclass.

Returns:
Array of state tags.

getValues

protected abstract WMObjectState[] getValues()
Returns the list of all state values applicable to this instance's class. This is a reference to a final array defined statically in the instance's subclass.

Returns:
Array of state objects.

getStatesByAction

protected abstract int[] getStatesByAction()
Returns the transitions from the current state, indexed by action. Illegal transitions are marked by the array element value ILLEGAL_ACTION.

Returns:
Array of state codes. This is a reference to a final array defined statically in the instance's subclass.

getActionsByState

protected abstract int[] getActionsByState()
Returns the transitions from the current state, indexed by new state. Illegal transitions are marked by the array element value ILLEGAL_ACTION.

Returns:
Array of action codes. This is a reference to a final array defined statically in the instance's subclass.

equals

public final boolean equals(java.lang.Object obj)
Tests for object identity. Only one instance of each ordinal value can ever exist.

Parameters:
obj - The with which to compare object this instance.
Returns:
true if the two references point to the same object.

hashCode

public final int hashCode()
Equal objects must have equal hash codes.

Returns:
The hash code.

value

public final int value()
Returns the object state as an integer. This ordinal state number is how the state is represented in persistent storage.

Returns:
Ordinal state number, as defined in subclasses.

getValue

public final int getValue()
JavaBean-compliant property accessor, synonym for value().


readResolve

protected final java.lang.Object readResolve()
                                      throws java.io.ObjectStreamException
Throws:
java.io.ObjectStreamException

stringValue

public final java.lang.String stringValue()
Returns the object state as a string.

Returns:
The object state.

toString

public final java.lang.String toString()

get_state

public int get_state()

set_state

public void set_state(int _state)