Package jade.proto.states
Class HandlerSelector
- java.lang.Object
-
- jade.core.behaviours.Behaviour
-
- jade.core.behaviours.CompositeBehaviour
-
- jade.core.behaviours.SerialBehaviour
-
- jade.core.behaviours.FSMBehaviour
-
- jade.proto.states.HandlerSelector
-
- All Implemented Interfaces:
Serializable,Serializable
public abstract class HandlerSelector extends FSMBehaviour
This class implements a selector of handler (i.e.jade.core.behaviours.Behaviour) A number of handlers can be registered with thisHandlerSelector, each handler bound to a different key. The abstract methodgetSelectionKeyis then called that must return the key to select one of the registered handlers. The selected handler is finally scheduled for execution.- Version:
- $Date$ $Revision$
- Author:
- Giovanni Caire - TILab Torino
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jade.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
-
-
Field Summary
Fields Modifier and Type Field Description static intSELECTION_NOKValue returned byonEndmethod if no handler was found mapped to the keystatic intSELECTION_OKValue returned byonEndmethod if an handler was found mapped to the key-
Fields inherited from class jade.core.behaviours.FSMBehaviour
currentName, lastStates
-
Fields inherited from class jade.core.behaviours.CompositeBehaviour
currentExecuted
-
Fields inherited from class jade.core.behaviours.Behaviour
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING
-
-
Constructor Summary
Constructors Constructor Description HandlerSelector(Agent a, DataStore s, Object accessKey)Constructor for this HandlerSelector.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ObjectgetSelectionKey(Object selectionVar)Subclasses must provide a concrete implementation for this method.voidregisterHandler(Object key, Behaviour h)Register the bounding between an handler and a key.-
Methods inherited from class jade.core.behaviours.FSMBehaviour
checkTermination, deregisterDefaultTransition, deregisterState, deregisterTransition, forceTransitionTo, getChildren, getCurrent, getLastExitValue, getName, getPrevious, getState, handleInconsistentFSM, handleStateEntered, hasDefaultTransition, onEnd, registerDefaultTransition, registerDefaultTransition, registerFirstState, registerLastState, registerState, registerTransition, registerTransition, reset, resetStates, scheduleFirst, scheduleNext, stringifyTransitionTable
-
Methods inherited from class jade.core.behaviours.SerialBehaviour
handle
-
Methods inherited from class jade.core.behaviours.CompositeBehaviour
action, done, handleBlockEvent, handleRestartEvent, registerAsChild, resetChildren, setAgent
-
Methods inherited from class jade.core.behaviours.Behaviour
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, isRunnable, onStart, restart, root, setBehaviourName, setDataStore, setExecutionState
-
-
-
-
Field Detail
-
SELECTION_OK
public static final int SELECTION_OK
Value returned byonEndmethod if an handler was found mapped to the key- See Also:
- Constant Field Values
-
SELECTION_NOK
public static final int SELECTION_NOK
Value returned byonEndmethod if no handler was found mapped to the key- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HandlerSelector
public HandlerSelector(Agent a, DataStore s, Object accessKey)
Constructor for this HandlerSelector.- Parameters:
a- is a reference to the Agent objects- is the DataStore where the object can be retrieved fromaccessKey- is the key to get the proper object from the DataStore, this is the object that will be later passed as argument to the methodgetSelectionKey- See Also:
getSelectionKey(Object)
-
-
Method Detail
-
getSelectionKey
protected abstract Object getSelectionKey(Object selectionVar)
Subclasses must provide a concrete implementation for this method. It must return the key to which the handler was bound.- Parameters:
selectionVar- the object retrieved from the datastore at theaccessKeypassed in the constructor- Returns:
- the key to which the handler was bound
-
-