| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--org.jutil.event.EventSourceSupport
This class is a support class for event sources. A source of events can delegate registration, deregistration and notification of listeners for a particular kind of event to an object of this class.
The actual source of the events should have delegation methods for all the add and removal method of this class with the correct static type for the Listener.
For adding and removing listeners to the set, equals() is used.
isValidEvent(EventListener) is used as an abstract type
   invariant and as an abstract precondition in add(EventListener).
   This makes it possible to transport information about the listeners
   available in subtypes, thru add(EventListener) and fireEvent(EventObject, Notifier) to the Notifier that will
   take care of the actual dispatch of an event to a listener.
| Class Specifications | 
| public invariant listeners != null; public invariant !listeners.has(null); public invariant ( \forall Object o; listeners.has(o); o instanceof EventListener); public invariant ( \forall EventListener l; listeners.has(l); isValidListener(l)); | 
| Model Field Summary | |
|  org.jmlspecs.models.JMLObjectSet | listeners | 
| Field Summary | |
| static java.lang.String | CVS_REVISION | 
| Constructor Summary | |
| EventSourceSupport() | |
| Method Summary | |
|  void | add(java.util.EventListener listener)Add an event Listener to the listeners to be notified by this. | 
|  void | fireEvent(java.util.EventObject event,
          Notifier notifier)Calls #notifyEventListener(EventListener, EventObject)on all
   listeners with the given event.
 The model inspector {#isValidListener(EventListener)} can be
   used to transport information about the registered listeners, thru
   this method, to the actual dispatch method in | 
|  boolean | isEmpty() | 
| static boolean | isModelFor(org.jmlspecs.models.JMLObjectSet jmlSet,
           java.util.Set javaSet) | 
|  boolean | isValidListener(java.util.EventListener listener)This model inspector can be used as an abstract precondition in methods using EventLister arguments, limiting which instances are acceptable. It can be used to transport information about listeners from the type invariants to the implementation of the method that uses it as a precondition. // JDJDJD // Adding listener != null here would result in \result <== listener != null;, // because the postcondition needs to be open for strengthening in subtypes. | 
|  void | remove(java.util.EventListener listener)Remove an event EventListener from the listeners to be notified by this. | 
|  java.lang.String | toString()A String representation of this. | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Model Field Detail | 
public org.jmlspecs.models.JMLObjectSet listeners
| Field Detail | 
public static final java.lang.String CVS_REVISION
| Constructor Detail | 
public EventSourceSupport()
| Method Detail | 
public boolean isValidListener(java.util.EventListener listener)
ListenerValidityThis model inspector can be used as an abstract precondition in methods using EventLister arguments, limiting which instances are acceptable.
It can be used to transport information about listeners from the type invariants to the implementation of the method that uses it as a precondition.
// JDJDJD // Adding listener != null here would result in \result <== listener != null;, // because the postcondition needs to be open for strengthening in subtypes. // This extra information doesn't help us.A typical subtype specification would say that the listener is of a given subtype of java.util.EventListener. E.g.:
... /*@
public final boolean isEmpty()
public final void add(java.util.EventListener listener)
listener - The Listener which is to be added to the list of listeners.public final void remove(java.util.EventListener listener)
listener - The EventListener which is to be removed from the list of listeners.
public static boolean isModelFor(org.jmlspecs.models.JMLObjectSet jmlSet,
                                 java.util.Set javaSet)
public final void fireEvent(java.util.EventObject event,
                            Notifier notifier)
Calls #notifyEventListener(EventListener, EventObject) on all
   listeners with the given event.
The model inspector {#isValidListener(EventListener)} can be
   used to transport information about the registered listeners, thru
   this method, to the actual dispatch method in
   
event - The event to be sent to all registered listeners.notifier - The notifier that will dispatch the event to the registered
         listeners.public java.lang.String toString()
| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||