ABLE 2.0.0 07/02/2003 10:25:01

com.ibm.able.conversation
Class StateMachine

java.lang.Object
  |
  +--com.ibm.able.conversation.StateMachine
All Implemented Interfaces:
java.io.Serializable, StateMachineInterface

public class StateMachine
extends java.lang.Object
implements StateMachineInterface, java.io.Serializable

Represents a state-machine view of a conversation. A conversation is viewed as a set of states and trnasitions between these states. There exist two roles in the conversation of which only one is active for a particular state-machine.

OLD VERSION -- TO BE DELETED Replaced by com.ibm.conversation.base.BasicCpStateMachine

Supports a property change listener for the current state of execution of the state machine. The identifier for the listener is "currentStateName"

See Also:
Serialized Form

Field Summary
protected  java.beans.PropertyChangeSupport propertySupport
          Firing property change support
protected static long serialVersionUID
          Serialized version identifier in form YYYYMMDDVerRelModxx
 
Fields inherited from interface com.ibm.able.conversation.StateMachineInterface
CURRENT_STATE_PROPERTY
 
Constructor Summary
StateMachine(ConversationParser cp)
          Constructor for StateMachine - Uses a ConversationParser to obtain data associated with the conversation - namely the name, states, transitions and the initial state name
 
Method Summary
 void addPropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener newListener)
          Adds the property chage listener for the given property
 java.lang.String getActiveRole()
          Returns the active role of the state-machine
 java.util.Enumeration getAllStateIds()
          Returns an enumeration of String ids of all states in the state machine
 java.util.Enumeration getAllTransitionNames(java.lang.String stateId)
          Returns an enumeration of all transition names from the state identified by the state id.
 State getCurrentState()
          Returns the current state name of the statemachine
 java.lang.String getCurrentStateId()
          Return the current state id of the state-machine (conversation) during execution
 java.lang.String getCurrentStateName()
          Returns the name of the current state during the execution of the state-machine
 java.lang.String getEvent(java.lang.String stateId, java.lang.String transitionName)
          Returns the event name associated with the transition from a particular state
 java.lang.String getInitialStateId()
          Return the initial state id of the state-machine (conversation)
 java.lang.String getInitialStateName()
          Returns the name of the initial state of the state-machine
 java.lang.String getName()
          Returns the name of the state-machine(conversation)
 java.util.Vector getRoles()
          Returns the set of roles in the conversation
 State getState(java.lang.String stateName)
          Get a particular state given the state name
 java.util.Enumeration getStateNames()
          Returns an enumeration of names of states in the state-machine
 java.util.Enumeration getStates()
          Returns an enumeration of states in the state-machine
 java.lang.String getTargetStateId(java.lang.String sourceStateId, java.lang.String transitionName)
          Returns the identifier of the state reached from a state by making a particular transition.
 Transition getTransition(java.lang.String transitionName)
          Returns the transition object for the given transition name(id)
 java.util.Enumeration getTransitionNames(java.lang.String stateName)
          Returns the names(ids) of all transitions from the given state
 java.util.Enumeration getTransitions(java.lang.String stateName)
          Returns the set of all transitions from the given state(name)
 boolean isActiveInState(State state)
          Finds if the state machine is active in the given state
 boolean isActiveInState(java.lang.String stateName)
          Finds if the state machine is active in the given state (name)
 boolean isLoadChildState(java.lang.String stateId)
          Checks if a particular state is a state where a new child CP is loaded
 boolean isTerminalState(java.lang.String stateId)
          Checks if a particular state is a terminal state
 void reset()
          Set the current-state to the initial state of the state-machine effectively resetting the state-machine
 void setActiveRole(java.lang.String role)
          Sets the active role of the state-machine
 void setCurrentStateName(java.lang.String name)
          Set the current state of the state-machine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

protected static final long serialVersionUID
Serialized version identifier in form YYYYMMDDVerRelModxx

propertySupport

protected transient java.beans.PropertyChangeSupport propertySupport
Firing property change support
Constructor Detail

StateMachine

public StateMachine(ConversationParser cp)
Constructor for StateMachine - Uses a ConversationParser to obtain data associated with the conversation - namely the name, states, transitions and the initial state name

Parameters:
cp - ConversationParser object that parses the cp-xml to obtain the relevant information
Method Detail

getName

public java.lang.String getName()
Returns the name of the state-machine(conversation)

Returns:
name of the state-machine

getRoles

public java.util.Vector getRoles()
Returns the set of roles in the conversation

Specified by:
getRoles in interface StateMachineInterface
Returns:
(two-element)vector of roles in the conversation

getInitialStateName

public java.lang.String getInitialStateName()
Returns the name of the initial state of the state-machine

Returns:
name of the initial state of the state-machine

getInitialStateId

public java.lang.String getInitialStateId()
Description copied from interface: StateMachineInterface
Return the initial state id of the state-machine (conversation)

Specified by:
getInitialStateId in interface StateMachineInterface
See Also:
StateMachineInterface.getInitialStateId()

getCurrentStateName

public java.lang.String getCurrentStateName()
Returns the name of the current state during the execution of the state-machine

Returns:
name of current state of the state-machine

getCurrentStateId

public java.lang.String getCurrentStateId()
Description copied from interface: StateMachineInterface
Return the current state id of the state-machine (conversation) during execution

Specified by:
getCurrentStateId in interface StateMachineInterface
See Also:
StateMachineInterface.getCurrentStateId()

setCurrentStateName

public void setCurrentStateName(java.lang.String name)
Set the current state of the state-machine. Also, if there are registered listeners to changes in current state name, fires an event to indicate the change of the property value

Parameters:
name - Name of the state to be set as the current state

getCurrentState

public State getCurrentState()
Returns the current state name of the statemachine

Returns:
the current state name of the state-machine

getStates

public java.util.Enumeration getStates()
Returns an enumeration of states in the state-machine

Returns:
Enumeration of State objects in the state-machine

getStateNames

public java.util.Enumeration getStateNames()
Returns an enumeration of names of states in the state-machine

Returns:
Enumeration of names of states in the statemachine

getAllStateIds

public java.util.Enumeration getAllStateIds()
Description copied from interface: StateMachineInterface
Returns an enumeration of String ids of all states in the state machine

Specified by:
getAllStateIds in interface StateMachineInterface
See Also:
StateMachineInterface.getAllStateIds()

getActiveRole

public java.lang.String getActiveRole()
Returns the active role of the state-machine

Returns:
the active role of the state-machine

setActiveRole

public void setActiveRole(java.lang.String role)
Sets the active role of the state-machine

Parameters:
role - the active role to be assumed by the state-machine

reset

public void reset()
Set the current-state to the initial state of the state-machine effectively resetting the state-machine

getState

public State getState(java.lang.String stateName)
Get a particular state given the state name

Parameters:
stateName - the name of the required state

Returns:
State object corresponding to the state name or null if there exists no such state

getTransitions

public java.util.Enumeration getTransitions(java.lang.String stateName)
Returns the set of all transitions from the given state(name)

Parameters:
stateName - The name of a state

Returns:
Enumeration of Transition objects representing transitions possible from the state or null if its a non-existent state name

getTransitionNames

public java.util.Enumeration getTransitionNames(java.lang.String stateName)
Returns the names(ids) of all transitions from the given state

Parameters:
stateName - The name of the state

Returns:
Enumeration of names(ids) transitions possible from the state or null if its a non-existent state

getAllTransitionNames

public java.util.Enumeration getAllTransitionNames(java.lang.String stateId)
Description copied from interface: StateMachineInterface
Returns an enumeration of all transition names from the state identified by the state id.

Specified by:
getAllTransitionNames in interface StateMachineInterface
See Also:
StateMachineInterface.getAllTransitionNames(String)

getTransition

public Transition getTransition(java.lang.String transitionName)
Returns the transition object for the given transition name(id)

WARNING: Could return unexpected results if different transitions from different states are allowed to have the same name(id)

Parameters:
transitionName - The name of the transition

Returns:
Transition object for the given transition name or null if its an invalid transition name(id)

isActiveInState

public boolean isActiveInState(java.lang.String stateName)
Finds if the state machine is active in the given state (name)

Parameters:
stateName - name of the state

return true if the state-machine is active in the state, false otherwise


isActiveInState

public boolean isActiveInState(State state)
Finds if the state machine is active in the given state

Parameters:
state - the state

return true if the state-machine is active in the state, false otherwise


addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String property,
                                      java.beans.PropertyChangeListener newListener)
Adds the property chage listener for the given property

Specified by:
addPropertyChangeListener in interface StateMachineInterface
Parameters:
property - Name of the property

newListener - The property change listener

getTargetStateId

public java.lang.String getTargetStateId(java.lang.String sourceStateId,
                                         java.lang.String transitionName)
Description copied from interface: StateMachineInterface
Returns the identifier of the state reached from a state by making a particular transition.

Specified by:
getTargetStateId in interface StateMachineInterface
See Also:
StateMachineInterface.getTargetStateId(String,String)

isTerminalState

public boolean isTerminalState(java.lang.String stateId)
Description copied from interface: StateMachineInterface
Checks if a particular state is a terminal state

Specified by:
isTerminalState in interface StateMachineInterface
See Also:
StateMachineInterface.isTerminalState(String)

isLoadChildState

public boolean isLoadChildState(java.lang.String stateId)
Description copied from interface: StateMachineInterface
Checks if a particular state is a state where a new child CP is loaded

Specified by:
isLoadChildState in interface StateMachineInterface
See Also:
StateMachineInterface.isLoadChildState(String)

getEvent

public java.lang.String getEvent(java.lang.String stateId,
                                 java.lang.String transitionName)
Description copied from interface: StateMachineInterface
Returns the event name associated with the transition from a particular state

Specified by:
getEvent in interface StateMachineInterface
See Also:
StateMachineInterface.getEvent(String,String)

ABLE 2.0.0 07/02/2003 10:25:01

(C) Copyright IBM Corporation 1999, 2003