jade.util
Class Event

java.lang.Object
  |
  +--java.util.EventObject
        |
        +--jade.util.Event
Direct Known Subclasses:
JADEEvent

public class Event
extends java.util.EventObject

This class represents a generic event carrying some information (accessible in the form of Object parameters) and provides support for synchronous processing through the waitUntilProcessed() and notifyProcessed() methods.

Author:
Giovanni Caire - TILab
See Also:
Serialized Form

Field Summary
protected  int type
           
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
Event(int type, java.lang.Object source)
          Construct an Event of a given type produced by the indicated source
Event(int type, java.lang.Object source, java.lang.Object info)
          Construct an Event of a given type produced by the indicated source and carrying a given information.
 
Method Summary
 void addParameter(java.lang.Object obj)
          Add a parameter to this Event object
 java.lang.Object getParameter(int index)
           
 int getType()
           
 void notifyProcessed(java.lang.Object result)
          Wakes up threads waiting for the processing of this Event object within the waitUntilProcessed() method.
 void resetProcessed()
          Reset the "processed" status of this Event
 java.lang.Object waitUntilProcessed()
          Blocks the calling thread until the notifyProcessed() method is called.
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected int type
Constructor Detail

Event

public Event(int type,
             java.lang.Object source)
Construct an Event of a given type produced by the indicated source
Parameters:
type - The type of the event
source - The source that generated the event

Event

public Event(int type,
             java.lang.Object source,
             java.lang.Object info)
Construct an Event of a given type produced by the indicated source and carrying a given information.
Parameters:
type - The type of the event
source - The source that generated the event
info - The information associated to the event. This value is handled as the first parameter of the event and can be accessed using the getParameter(0) method
Method Detail

getType

public int getType()
Returns:
the type of this Event object

addParameter

public void addParameter(java.lang.Object obj)
Add a parameter to this Event object
Parameters:
obj - The parameter to be added

getParameter

public java.lang.Object getParameter(int index)
Returns:
the index-th parameter of this Event object

waitUntilProcessed

public java.lang.Object waitUntilProcessed()
                                    throws java.lang.InterruptedException
Blocks the calling thread until the notifyProcessed() method is called.
Returns:
the result of the processing of this Event object as set by the notifyProcessed() method.

notifyProcessed

public void notifyProcessed(java.lang.Object result)
Wakes up threads waiting for the processing of this Event object within the waitUntilProcessed() method.
Parameters:
result - The result of the processing. This value is passed to the waked threads as the result of the waitUntilProcessed() method.

resetProcessed

public void resetProcessed()
Reset the "processed" status of this Event