org.jutil.event
Interface Notifier

All Known Subinterfaces:
ApplicabilityNotifier
All Known Implementing Classes:
ChainNotifier

public interface Notifier

Notifier instances are used to call the correct call-back method defined in a listener type when EventSourceSupport fires events. The method EventSourceSupport.fireEvent(EventObject, Notifier) presents the event to the notifier for each listener that is registered in the EventSourceSupport instance. This technique is similar to the well-known double-dispatch.

Abstract preconditions are used to transport information about the listener and the event from clients, over type invariants, to the implementation of notifyEventListener(EventListener, EventObject). An abstract postcondition makes it possible for EventSourceSupport to specify that notifyEventListener(EventListener, EventObject) is actually called.

Most often, this interface is implemented in an inner class of the actual event source that used the EventSourceSupport instance. A typical implementation looks like this:

 ...
 static final private Notifier _eventNameNotifier =
     new Notifier() {

            /**
             * also
             *   public behavior
             *     post \result <==> (event != null) && (event instanceof EventNameEvent);
             * public model boolean isValidEvent(EventObject event);

Version:
$Revision: 1.3 $
Author:
Jan Dockx

Field Summary
static java.lang.String CVS_REVISION
           
 
Method Summary
 void notifyEventListener(java.util.EventListener listener, java.util.EventObject event)
          public behavior
pre listener != null;
pre isValidListener(listener);
pre isValidEvent(event);
assignable \fields_of(\reach(listener)), \fields_of(\reach(event)),
\fields_of(\reach(this));
post notifyEventListenerCalled(listener, event);
 

Field Detail

CVS_REVISION

public static final java.lang.String CVS_REVISION
Method Detail

notifyEventListener

public void notifyEventListener(java.util.EventListener listener,
                                java.util.EventObject event)
public behavior
pre listener != null;
pre isValidListener(listener);
pre isValidEvent(event);
assignable \fields_of(\reach(listener)), \fields_of(\reach(event)),
\fields_of(\reach(this));
post notifyEventListenerCalled(listener, event);

Subclasses need to overwrite this method to call the call-back method defined in listenerType with event.

The postcondition is abstract. This is used in EventSourceSupport to specify that this method will indeed be called by EventSourceSupport.fireEvent(EventObject, Notifier).