|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.millstone.base.event.ListenerMethod
One registered event listener. This class contains the listener object reference, listened event type, the trigger method to call when the event fires, and the optional argument list to pass to the method and the index of the argument to replace with the event object. It provides several constructors that allow omission of the optional arguments, and giving the listener method directly, or having the constructor to reflect it using merely the name of the method.
It should be pointed out that the method
receiveEvent(EventObject event)
is the one that filters out the
events that do not match with the given event type and thus do not result
in calling of the trigger method.
Nested Class Summary | |
class |
ListenerMethod.MethodException
Exception that wraps an exception thrown by an invoked method. |
Constructor Summary | |
ListenerMethod(java.lang.Class eventType,
java.lang.Object object,
java.lang.reflect.Method method)
Constructs a new event listener from a trigger method. |
|
ListenerMethod(java.lang.Class eventType,
java.lang.Object object,
java.lang.reflect.Method method,
java.lang.Object[] arguments)
Constructs a new event listener from the trigger method and it's arguments. |
|
ListenerMethod(java.lang.Class eventType,
java.lang.Object object,
java.lang.reflect.Method method,
java.lang.Object[] arguments,
int eventArgumentIndex)
Constructs a new event listener from a trigger method, it's arguments and the argument index specifying which one is replaced with the event object when the trigger method is called. |
|
ListenerMethod(java.lang.Class eventType,
java.lang.Object object,
java.lang.String methodName)
Constructs a new event listener from a trigger method name. |
|
ListenerMethod(java.lang.Class eventType,
java.lang.Object object,
java.lang.String methodName,
java.lang.Object[] arguments)
Constructs a new event listener from a trigger method name and it's arguments. |
|
ListenerMethod(java.lang.Class eventType,
java.lang.Object object,
java.lang.String methodName,
java.lang.Object[] arguments,
int eventArgumentIndex)
Constructs a new event listener from a trigger method name, it's arguments and the argument index specifying which one is replaced with the event object. |
Method Summary | |
boolean |
matches(java.lang.Class eventType,
java.lang.Object target)
Checks if the given object and event match with the ones stored in this listener. |
boolean |
matches(java.lang.Class eventType,
java.lang.Object target,
java.lang.reflect.Method method)
Checks if the given object, event and method match with the ones stored in this listener. |
void |
receiveEvent(java.util.EventObject event)
Receives one event from the EventRouter and calls the trigger method if it matches with the criteria defined for the listener. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ListenerMethod(java.lang.Class eventType, java.lang.Object object, java.lang.reflect.Method method, java.lang.Object[] arguments, int eventArgumentIndex) throws java.lang.IllegalArgumentException
Constructs a new event listener from a trigger method, it's arguments and the argument index specifying which one is replaced with the event object when the trigger method is called.
This constructor gets the trigger method as a parameter so it does not need to reflect to find it out.
eventType
- The event type that is listener listens to. All
events of this kind (or its subclasses) result in calling the trigger
method.object
- The object instance that contains the trigger methodmethod
- the trigger methodarguments
- arguments to be passed to the trigger methodeventArgumentIndex
- An index to the argument list. This index
points out the argument that is replaced with the event object before
the argument set is passed to the trigger method. If
eventArgumentIndex
is negative, the triggering event
object will not be passed to the trigger method, though it is still
called.
java.lang.IllegalArgumentException
- if method
is not a member of object
.public ListenerMethod(java.lang.Class eventType, java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments, int eventArgumentIndex) throws java.lang.IllegalArgumentException
Constructs a new event listener from a trigger method name, it's
arguments and the argument index specifying which one is replaced
with the event object. The actual trigger method is reflected from
object
, and
java.lang.IllegalArgumentException
is thrown unless
exactly one match is found.
eventType
- The event type that is listener listens to. All
events of this kind (or its subclasses) result in calling the trigger
method.object
- The object instance that contains the trigger methodmethodName
- The name of the trigger method. If
object
does not contain the method or it contains more
than one matching methods
java.lang.IllegalArgumentException
is thrown.arguments
- arguments to be passed to the trigger methodeventArgumentIndex
- An index to the argument list. This index
points out the argument that is replaced with the event object before
the argument set is passed to the trigger method. If
eventArgumentIndex
is negative, the triggering event
object will not be passed to the trigger method, though it is still
called.
java.lang.IllegalArgumentException
- unless exactly one match
methodName
is found in object
.public ListenerMethod(java.lang.Class eventType, java.lang.Object object, java.lang.reflect.Method method, java.lang.Object[] arguments) throws java.lang.IllegalArgumentException
Constructs a new event listener from the trigger method and it's arguments. Since the the index to the replaced parameter is not specified the event triggering this listener will not be passed to the trigger method.
This constructor gets the trigger method as a parameter so it does not need to reflect to find it out.
eventType
- The event type that is listener listens to. All
events of this kind (or its subclasses) result in calling the trigger
method.object
- The object instance that contains the trigger methodmethod
- the trigger methodarguments
- arguments to be passed to the trigger method
java.lang.IllegalArgumentException
- if method
is not a member of object
.public ListenerMethod(java.lang.Class eventType, java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments) throws java.lang.IllegalArgumentException
Constructs a new event listener from a trigger method name and it's arguments. Since the the index to the replaced parameter is not specified the event triggering this listener will not be passed to the trigger method.
The actual trigger method is reflected from object
,
and java.lang.IllegalArgumentException
is thrown unless
exactly one match is found.
eventType
- The event type that is listener listens to. All
events of this kind (or its subclasses) result in calling the trigger
method.object
- The object instance that contains the trigger methodmethodName
- The name of the trigger method. If
object
does not contain the method or it contains more
than one matching methods
java.lang.IllegalArgumentException
is thrown.arguments
- arguments to be passed to the trigger method
java.lang.IllegalArgumentException
- unless exactly one match
methodName
is found in object
.public ListenerMethod(java.lang.Class eventType, java.lang.Object object, java.lang.reflect.Method method) throws java.lang.IllegalArgumentException
Constructs a new event listener from a trigger method. Since the argument list is unspecified no parameters are passed to the trigger method when the listener is triggered.
This constructor gets the trigger method as a parameter so it does not need to reflect to find it out.
eventType
- The event type that is listener listens to. All
events of this kind (or its subclasses) result in calling the trigger
method.object
- The object instance that contains the trigger methodmethod
- the trigger method
java.lang.IllegalArgumentException
- if method
is not a member of object
.public ListenerMethod(java.lang.Class eventType, java.lang.Object object, java.lang.String methodName) throws java.lang.IllegalArgumentException
Constructs a new event listener from a trigger method name. Since the argument list is unspecified no parameters are passed to the trigger method when the listener is triggered.
The actual trigger method is reflected from object
,
and java.lang.IllegalArgumentException
is thrown unless
exactly one match is found.
eventType
- The event type that is listener listens to. All
events of this kind (or its subclasses) result in calling the trigger
method.object
- The object instance that contains the trigger methodmethodName
- The name of the trigger method. If
object
does not contain the method or it contains more
than one matching methods
java.lang.IllegalArgumentException
is thrown.
java.lang.IllegalArgumentException
- unless exactly one match
methodName
is found in object
.Method Detail |
public void receiveEvent(java.util.EventObject event)
event
- The fired event. Unless the trigger method's
argument list and the index to the to be replaced argument is
specified, this event will not be passed to the trigger method.public boolean matches(java.lang.Class eventType, java.lang.Object target)
target
- object to be matched against the object stored by this
listenereventType
- type to be tested for equality against the type
stored by this listener
true
if target
is the same object
as the one stored in this object and eventType
equals
the event type stored in this object.public boolean matches(java.lang.Class eventType, java.lang.Object target, java.lang.reflect.Method method)
target
- object to be matched against the object stored by this
listenereventType
- type to be tested for equality against the type
stored by this listenermethod
- method to be tested for equality against the method
stored by this listener
true
if target
is the same object
as the one stored in this object, eventType
equals
with the event type stored in this object and method
equals with the method stored in this object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |