net.openai.util.fsm
Class State

java.lang.Object
  |
  +--net.openai.util.fsm.State
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AgentState

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

State abstract class

See Also:
Serialized Form

Constructor Summary
State()
          Constructs a new State.
 
Method Summary
 void addStateListener(StateListener listener)
          Adds a StateListener to this State that we will deliver events to.
 void addTransition(Condition condition)
          Adds a Condition to this State.
 void addTransition(Condition condition, State targetState)
          Convenience method for adding a transition from this state to the next.
abstract  void enter(java.lang.Object input)
          This method is called when the state is entered.
abstract  java.lang.Object exit()
          This method is called when the state is exited via a transition to another state.
 boolean getEndStateFlag()
          Returns true if this state is an end state, false otherwise.
 java.lang.String getName()
          Returns the name of this state.
 boolean getStartStateFlag()
          Returns true if this state is a start state, false otherwise.
 java.util.Vector getTransitions()
          Returns a Vector of the current Conditions/Transitions for this State.
 void removeStateListener(StateListener listener)
          Removes a StateListener from this State.
 void removeTransition(Condition condition)
          Removes a Condition as a Transition from this State.
 void setEndStateFlag(boolean endState)
          Sets the value of this state's end state flag.
 void setName(java.lang.String name)
          Sets the name for this state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

State

public State()
Constructs a new State.

Method Detail

setName

public final void setName(java.lang.String name)
Sets the name for this state. If the name passed in is null, then a NullPointerException will be generated.

Parameters:
name - The new name for this state.

getName

public final java.lang.String getName()
Returns the name of this state.

Returns:
A String that represents the name of this state.

getStartStateFlag

public final boolean getStartStateFlag()
Returns true if this state is a start state, false otherwise.

Returns:
The value of this state's start state flag.

setEndStateFlag

public final void setEndStateFlag(boolean endState)
Sets the value of this state's end state flag.

Parameters:
endState - The new value of this state's end state flag.

getEndStateFlag

public final boolean getEndStateFlag()
Returns true if this state is an end state, false otherwise.

Returns:
The value of this state's end state flag.

addStateListener

public final void addStateListener(StateListener listener)
Adds a StateListener to this State that we will deliver events to.

Parameters:
listener - The StateListener to add.

removeStateListener

public final void removeStateListener(StateListener listener)
Removes a StateListener from this State.

Parameters:
listener - The StateListener to remove.

addTransition

public final void addTransition(Condition condition)
Adds a Condition to this State. If this is the current state in the machine when the machine is receiving input, then this state will iterate down the list of conditions to find the first one that is met by the input to the machine. Once the first condition that satisfies the input is found, then the condition's target state will be returned to the machine as the new curren state.

NOTE: Subsequent calls to this method with the same condition will put the condition at the end of the list of conditions to be checked.

Parameters:
condition - The new Condition to add.

addTransition

public final void addTransition(Condition condition,
                                State targetState)
Convenience method for adding a transition from this state to the next. This method simply calls addTransition() on this state and then calls setTargetState() the condition.

Parameters:
condition - The new Condition to add.
targetState - The target state for this transition.

removeTransition

public final void removeTransition(Condition condition)
Removes a Condition as a Transition from this State.

Parameters:
condition - The Condition/Transition to remove.

getTransitions

public final java.util.Vector getTransitions()
Returns a Vector of the current Conditions/Transitions for this State.

Returns:
The current list of Conditions for this State or null if there aren't any.

enter

public abstract void enter(java.lang.Object input)
This method is called when the state is entered.

Parameters:
input - Any output from a previous state will become the input for this state. If this is a start state, then input will be null.

exit

public abstract java.lang.Object exit()
This method is called when the state is exited via a transition to another state.

Returns:
Any output object that is to be fed into the next state.


Copyright - 2001 OpenAI Labs. All Rights Reserved.