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

com.ibm.conversation.base
Class BasicCpStateMachine

java.lang.Object
  |
  +--com.ibm.conversation.base.BasicCpStateMachine
All Implemented Interfaces:
CpStateMachine

public class BasicCpStateMachine
extends java.lang.Object
implements CpStateMachine

The BasicCpStateMachine class is a straightforward, vanilla-Java implementation of the CpStateMachine interface.


Constructor Summary
BasicCpStateMachine()
          Constructs a BasicSpStateMachine object.
 
Method Summary
 void addRole(java.lang.String newRole)
          Adds the given role to the set of roles supported by the policy.
 void addState(CpState newState)
          Adds the given state to the policy state machine.
 void clear()
          Removes all roles, states, and transitions that have been added to this state machine.
 CpState getInitialState()
          Returns the initial state of the policy.
 java.lang.String getInitialStateName()
          Returns the name of the policy's initial state.
 int getNumStates()
          Returns the number of states in the policy state machine.
 java.lang.String getPolicyName()
          Returns the name of the policy.
 java.util.Collection getRoles()
          Returns a Collection containing the roles supported by the policy.
 CpState getState(java.lang.String name)
          Returns the state with the given name
 java.util.Collection getStates()
          Returns a Collection containing all the states in the poliy state machine.
 CpStateTransition getTransition(java.lang.String stateName, java.lang.String transitionName)
          Returns the transition with the given transitionName whose source is the given stateName.
static void main(java.lang.String[] args)
          Unit test of BasicCpStateMachine.
 CpState newState(int stateType)
          Creates and returns a new CpState of the given state type.
 CpStateTransition newTransition(int transitionType)
          Creates and returns a new CpStateTransition of the given transition type.
 void setInitialStateName(java.lang.String newName)
          Sets the name of the policy's initial state
 void setPolicyName(java.lang.String newName)
          Sets the name of the policy.
 java.lang.String toString()
          Returns a human-readable String representation of the state machine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicCpStateMachine

public BasicCpStateMachine()
Constructs a BasicSpStateMachine object.
Method Detail

getPolicyName

public java.lang.String getPolicyName()
Description copied from interface: CpStateMachine
Returns the name of the policy.

Specified by:
getPolicyName in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Returns:
The policy's name, of null if undefined.

setPolicyName

public void setPolicyName(java.lang.String newName)
Description copied from interface: CpStateMachine
Sets the name of the policy.

Specified by:
setPolicyName in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Parameters:
newName - The new name of the policy.

getRoles

public java.util.Collection getRoles()
Description copied from interface: CpStateMachine
Returns a Collection containing the roles supported by the policy.

Each entry in the Collection is a String.

Specified by:
getRoles in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Returns:
The roles defined by the policy.

addRole

public void addRole(java.lang.String newRole)
Description copied from interface: CpStateMachine
Adds the given role to the set of roles supported by the policy.

Specified by:
addRole in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Parameters:
newRole - The role to be added.

getInitialState

public CpState getInitialState()
Description copied from interface: CpStateMachine
Returns the initial state of the policy.

Specified by:
getInitialState in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Returns:
The initial state of the policy, or null if undefined.

getInitialStateName

public java.lang.String getInitialStateName()
Description copied from interface: CpStateMachine
Returns the name of the policy's initial state.

Specified by:
getInitialStateName in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Returns:
The name of the policy's initial state, or null if undefined.

setInitialStateName

public void setInitialStateName(java.lang.String newName)
Description copied from interface: CpStateMachine
Sets the name of the policy's initial state

Specified by:
setInitialStateName in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Parameters:
newName - The name of the new initial state.

getNumStates

public int getNumStates()
Description copied from interface: CpStateMachine
Returns the number of states in the policy state machine.

Specified by:
getNumStates in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Returns:
The number of states in the policy.

getStates

public java.util.Collection getStates()
Description copied from interface: CpStateMachine
Returns a Collection containing all the states in the poliy state machine.

Each entry in the Collection is a CpState.

Specified by:
getStates in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Returns:
The states in the policy.

getState

public CpState getState(java.lang.String name)
Description copied from interface: CpStateMachine
Returns the state with the given name

Specified by:
getState in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Parameters:
name - The state's name.
Returns:
The state with the given name, or null if not found.

addState

public void addState(CpState newState)
Description copied from interface: CpStateMachine
Adds the given state to the policy state machine.

Specified by:
addState in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Parameters:
newState - The state to be added.

getTransition

public CpStateTransition getTransition(java.lang.String stateName,
                                       java.lang.String transitionName)
Description copied from interface: CpStateMachine
Returns the transition with the given transitionName whose source is the given stateName.

Specified by:
getTransition in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Parameters:
stateName - The name of the source state.
transitionName - The name of the transition.
Returns:
The transition matching the args, or null if not found.

clear

public void clear()
Description copied from interface: CpStateMachine
Removes all roles, states, and transitions that have been added to this state machine.
Specified by:
clear in interface CpStateMachine

newState

public CpState newState(int stateType)
Description copied from interface: CpStateMachine
Creates and returns a new CpState of the given state type.

Specified by:
newState in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Parameters:
stateType - The state type.
Returns:
The new state.
See Also:
for possible state types.

newTransition

public CpStateTransition newTransition(int transitionType)
Description copied from interface: CpStateMachine
Creates and returns a new CpStateTransition of the given transition type.

See CpStateTransition for possible transition types.

Specified by:
newTransition in interface CpStateMachine
Following copied from interface: com.ibm.conversation.CpStateMachine
Parameters:
transitionType - The transition type.
Returns:
The new transition.

toString

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

This is defined for debugging porposes only. It uses BasicCpStateMachineWriter to create the String.

Overrides:
toString in class java.lang.Object
Returns:
The String representation of the state machine.

main

public static void main(java.lang.String[] args)
Unit test of BasicCpStateMachine.

Reads a cpXML filename from the command line, parses the file using CpXmlParser, builds a BasicCpStateMachine, and prints its String representation to standard output.

Parameters:
args - The command-line arguments. args[0] should be the cpXML filename.

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

(C) Copyright IBM Corporation 1999, 2003