org.jutil.event
Class TypeApplicabilityNotifier

java.lang.Object
  |
  +--org.jutil.event.TypeApplicabilityNotifier
All Implemented Interfaces:
ApplicabilityNotifier, Notifier

public abstract class TypeApplicabilityNotifier
extends java.lang.Object
implements ApplicabilityNotifier

A support class for optional notifiers that depend on the type of the listener and the event to be processed.

Most often a ChainNotifier will be used in the case where the EventSourceSupport contains listeners of different types, or when different call-back methods of the listeners need to be called depending on the type of the event fired. This class implements the ApplicabilityNotifier.isApplicable(EventListener, EventObject) method to check whether the type of the listener and the event is compatible with a given listener type and event type.

Note that we do not demand this type to be pure (see JML), although all the methods we offer are.

Version:
$Revision: 1.3 $
Author:
Jan Dockx

Field Summary
static java.lang.String CVS_REVISION
           
 
Constructor Summary
TypeApplicabilityNotifier(java.lang.Class listenerType)
          public behavior
pre listenerType != null;
pre Class.forName("java.util.EventListener").isAssignableFrom(listenerType);
assignable listenerType, eventType;
post this.listenerType == listenerType;
post this.eventType == Class.forName("java.util.EventObject");
TypeApplicabilityNotifier(java.lang.Class listenerType, java.lang.Class eventType)
          public behavior
pre listenerType != null;
pre Class.forName("java.util.EventListener").isAssignableFrom(listenerType);
pre eventType != null;
pre Class.forName("java.util.EventObject").isAssignableFrom(eventType);
assignable listenerType, eventType;
post this.listenerType == listenerType;
post this.eventType == eventType;
 
Method Summary
 java.lang.Class getEventType()
          public behavior
post \result == eventType;
 java.lang.Class getListenerType()
          public behavior
post \result == listenerType;
 boolean isApplicable(java.util.EventListener listener, java.util.EventObject event)
          also
public behavior
pre listener != null;
post \result ==>
(listenerType.isInstance(listener) &&
((event == null) || eventType.isInstance(event)));
// remember that isInstance would be false when event == null
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jutil.event.Notifier
notifyEventListener
 

Field Detail

CVS_REVISION

public static final java.lang.String CVS_REVISION
Constructor Detail

TypeApplicabilityNotifier

public TypeApplicabilityNotifier(java.lang.Class listenerType,
                                 java.lang.Class eventType)
public behavior
pre listenerType != null;
pre Class.forName("java.util.EventListener").isAssignableFrom(listenerType);
pre eventType != null;
pre Class.forName("java.util.EventObject").isAssignableFrom(eventType);
assignable listenerType, eventType;
post this.listenerType == listenerType;
post this.eventType == eventType;

TypeApplicabilityNotifier

public TypeApplicabilityNotifier(java.lang.Class listenerType)
public behavior
pre listenerType != null;
pre Class.forName("java.util.EventListener").isAssignableFrom(listenerType);
assignable listenerType, eventType;
post this.listenerType == listenerType;
post this.eventType == Class.forName("java.util.EventObject");
Method Detail

isApplicable

public boolean isApplicable(java.util.EventListener listener,
                            java.util.EventObject event)
also
public behavior
pre listener != null;
post \result ==>
(listenerType.isInstance(listener) &&
((event == null) || eventType.isInstance(event)));
// remember that isInstance would be false when event == null
Specified by:
isApplicable in interface ApplicabilityNotifier

getListenerType

public final java.lang.Class getListenerType()
public behavior
post \result == listenerType;

getEventType

public final java.lang.Class getEventType()
public behavior
post \result == eventType;