Package muntjac :: Package event :: Module listener_method :: Class ListenerMethod
[hide private]
[frames] | no frames]

Class ListenerMethod

source code

         object --+    
                  |    
util.IEventListener --+
                      |
                     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.

This Class 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 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.


Authors:
Vaadin Ltd., Richard Lincoln

Version: 1.1.2

Instance Methods [hide private]
 
writeObject(self, out) source code
 
readObject(self, in_) source code
 
__init__(self, eventType, target, method, arguments=None, eventArgumentIndex=None)
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.
source code
 
receiveEvent(self, event)
Receives one event from the EventRouter and calls the trigger method if it matches with the criteria defined for the listener.
source code
 
matches(self, eventType, target, method=None)
Checks if the given object and event match with the ones stored in this listener.
source code
 
__hash__(self)
hash(x)
source code
 
__eq__(self, obj) source code
 
isType(self, eventType)
Compares the type of this ListenerMethod to the given type
source code
 
isOrExtendsType(self, eventType)
Compares the type of this ListenerMethod to the given type
source code
 
getTarget(self)
Returns the target object which contains the trigger method.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
findHighestMethod(cls, klass, method, paramTypes) source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, eventType, target, method, arguments=None, eventArgumentIndex=None)
(Constructor)

source code 

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.

Parameters:
  • eventType - the event type that is listener listens to. All events of this kind (or its subclasses) result in calling the trigger method.
  • target - the object instance that contains the trigger method
  • method - the trigger method or the name of the trigger method. If the object does not contain the method a ValueError is thrown.
  • arguments - the arguments to be passed to the trigger method
  • eventArgumentIndex - 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 the eventArgumentIndex is negative, the triggering event object will not be passed to the trigger method, though it is still called.
Raises:
  • ValueError - if method is not a member of target
Overrides: object.__init__

receiveEvent(self, event)

source code 

Receives one event from the EventRouter and calls the trigger method if it matches with the criteria defined for the listener. Only the events of the same or subclass of the specified event class result in the trigger method to be called.

Parameters:
  • 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.

matches(self, eventType, target, method=None)

source code 

Checks if the given object and event match with the ones stored in this listener.

Parameters:
  • target - the object to be matched against the object stored by this listener.
  • eventType - the type to be tested for equality against the type stored by this listener.
  • method - the method to be tested for equality against the method stored by this listener.
Returns:
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

__hash__(self)
(Hashing function)

source code 

hash(x)

Overrides: object.__hash__
(inherited documentation)

isType(self, eventType)

source code 

Compares the type of this ListenerMethod to the given type

Parameters:
  • eventType - The type to compare with
Returns:
true if this type of this ListenerMethod matches the given type, false otherwise

isOrExtendsType(self, eventType)

source code 

Compares the type of this ListenerMethod to the given type

Parameters:
  • eventType - The type to compare with
Returns:
true if this event type can be assigned to the given type, false otherwise

getTarget(self)

source code 

Returns the target object which contains the trigger method.

Returns:
The target object