?? condition.java
字號(hào):
/***************************************************************************** * net.openai.fsm.Condition ***************************************************************************** * @author JC on E * @date 9/18/2000 * 2001 OpenAI Labs *****************************************************************************/package net.openai.util.fsm;import java.util.Vector;import java.io.Serializable;/** * This is the base class for all Conditions */public abstract class Condition implements Serializable { /** A handle to our target State. */ private State targetState; /** A handle to our source States. */ private Vector sourceStates = new Vector(); /** * Constructs a new Condition object. */ public Condition() { } /** * Constructs a new Condition with the given target state. * * @param targetState The target state for this Condition. */ public Condition(State targetState) { setTargetState(targetState); } /** * Sets the target state for this Condition. This is the state that * will be the current state in the machine if this Condition is met. * <br><br> * NOTE: If the target state is null whenever this condition is being * checked by the machine and it passes, then the result will * be an UnhandledConditionException being thrown by the machine. * Setting this to null is allowed because it will be necessary * within a Graphical Building tool such as bean box or the * planned extensions to the net.openai.gui.graph package. * * @param targetState The new target state. */ public final void setTargetState(State targetState) { this.targetState = targetState; } /** * Returns a handle to this Condition's current target state. * * @return This Condition's target state. */ public final State getTargetState() { return targetState; } /** * Returns a handle to the source States of this Condition. The source * States are the State that will check this Condition to see if it meets * the criterial passed in and then go on to the target State. * * @return The source states of this Condition or null if there are none. */ public final Vector getSourceStates() { Vector returnValue = null; synchronized(sourceStates) { returnValue = (Vector)sourceStates.clone(); } return returnValue; } /** * Adds a source state to this Condition. * * @param state The state to add. */ void addSourceState(State state) { if(state == null) throw new NullPointerException("Cannot add null source state."); synchronized(sourceStates) { if(!sourceStates.contains(state)) sourceStates.addElement(state); } } /** * Removes a source state from this Condition. * * @param state The state to remove. */ void removeSourceState(State state) { if(state == null) return; synchronized(sourceStates) { sourceStates.removeElement(state); } } /** * Called to check if the conditional meets the criteria defined by this * state. This is the only method to implement in order to used this * interface. * * @param conditional The object to check. * @return Implementors should return <code>true</code> if this condition * is met by the Object <code>conditional</code> and * <code>false</code> otherwise. */ public abstract boolean satisfiedBy(Object conditional);}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -