public class Event
extends java.util.EventObject
Object
parameters) and
provides support for synchronous processing through the
waitUntilProcessed()
and notifyProcessed()
methods.
This class can be effectively used in combination with the
InputQueue
class to support a synchronization between an
external therad (posting events in the InputQueue
)
and the Agent thread (processing the events).InputQueue
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected int |
type
The type of this event.
|
Constructor and Description |
---|
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. |
Modifier and Type | Method and Description |
---|---|
void |
addParameter(java.lang.Object obj)
Add a parameter to this
Event object |
java.lang.Object |
getParameter(int index)
Retrieve an element of the event parameter list.
|
int |
getType()
Retrieve the type of this event.
|
void |
notifyProcessed(java.lang.Object result)
Wakes up threads waiting for the processing of this
Event
object within the waitUntilProcessed() method. |
void |
reset()
Reset the status of this
Event |
void |
resetProcessed()
Deprecated.
Use
reset() instead |
java.lang.Object |
waitUntilProcessed()
Blocks the calling thread until the
notifyProcessed()
method is called. |
java.lang.Object |
waitUntilProcessed(long timeout)
Blocks the calling thread until the
notifyProcessed()
method is called. |
public Event(int type, java.lang.Object source)
Event
of a given type produced by
the indicated sourcetype
- The type of the eventsource
- The source that generated the eventpublic Event(int type, java.lang.Object source, java.lang.Object info)
Event
of a given type produced by
the indicated source and carrying a given information.type
- The type of the eventsource
- The source that generated the eventinfo
- 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)
methodpublic int getType()
Event
objectpublic void addParameter(java.lang.Object obj)
Event
objectobj
- The parameter to be addedpublic java.lang.Object getParameter(int index)
index
- The index of the parameter to retrieve.Event
object.public java.lang.Object waitUntilProcessed() throws java.lang.InterruptedException
notifyProcessed()
method is called.Event
object as set by the notifyProcessed()
method.java.lang.InterruptedException
public java.lang.Object waitUntilProcessed(long timeout) throws java.lang.InterruptedException
notifyProcessed()
method is called.Event
object as set by the notifyProcessed()
method.java.lang.InterruptedException
- if the timeout expires or the Thread
executing this method is interrupted.public void notifyProcessed(java.lang.Object result)
Event
object within the waitUntilProcessed()
method.result
- The result of the processing. This value is passed
to the waked threads as the result of the waitUntilProcessed()
method.public void reset()
Event
public void resetProcessed()
reset()
insteadEvent