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:
- java.io.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
this HandlerSelector
, each handler bound to a different key.
The abstract method getSelectionKey is then called that
must return the key to select one of the registered handlers.
The selected handler is finally scheduled for execution.
- Version:
- $Date: 2005-09-16 15:54:46 +0200 (Fri, 16 Sep 2005) $ $Revision: 5780 $
- Author:
- Giovanni Caire - TILab Torino
- See Also:
- Serialized Form
Field Summary |
static int |
SELECTION_NOK
Value returned by onEnd method if
no handler was found mapped to the key |
static int |
SELECTION_OK
Value returned by onEnd method if
an handler was found mapped to the key |
Method Summary |
protected abstract java.lang.Object |
getSelectionKey(java.lang.Object selectionVar)
Subclasses must provide a concrete implementation for this method.
|
void |
registerHandler(java.lang.Object key,
Behaviour h)
Register the bounding between an handler and a key. |
Methods inherited from class jade.core.behaviours.FSMBehaviour |
checkTermination, deregisterState, forceTransitionTo, getChildren, getCurrent, getLastExitValue, getName, getPrevious, getState, handleInconsistentFSM, handleStateEntered, onEnd, registerDefaultTransition, registerDefaultTransition, registerFirstState, registerLastState, registerState, registerTransition, registerTransition, reset, resetStates, scheduleFirst, scheduleNext |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SELECTION_OK
public static final int SELECTION_OK
- Value returned by
onEnd
method if
an handler was found mapped to the key
- See Also:
- Constant Field Values
SELECTION_NOK
public static final int SELECTION_NOK
- Value returned by
onEnd
method if
no handler was found mapped to the key
- See Also:
- Constant Field Values
HandlerSelector
public HandlerSelector(Agent a,
DataStore s,
java.lang.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
method getSelectionKey
- See Also:
getSelectionKey(Object)
getSelectionKey
protected abstract java.lang.Object getSelectionKey(java.lang.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
the accessKey
passed in the constructor
- Returns:
- the key to which the handler was bound
registerHandler
public void registerHandler(java.lang.Object key,
Behaviour h)
- Register the bounding between an handler and a key.
- Parameters:
key
- this is the key that must be later returned by
the method getSelectionKey
when the passed
Behaviour must be selectedh
- the handler for this key
JADE