org.eclipse.ocl.examples.eventmanager
Interface EventManagerFactory

All Known Implementing Classes:
EventManagerFactoryImpl

public interface EventManagerFactory

Used to obtain an EventManager instance that listens to change Notifications occurring on zero or more ResourceSets. Additionally, an event manager factory offers factory methods for event filters.

Author:
Philipp Berger, Axel Uhl

Field Summary
static EventManagerFactory eINSTANCE
          The default instance implementing this interface
 
Method Summary
 EventFilter createAndFilterFor(EventFilter... eventFilters)
          Creates an AndFilter for incoming EventFilters.
 EventFilter createClassFilter(org.eclipse.emf.ecore.EClass clazz)
          Creates a filter that matches a Notification if the object that changed has clazz as its class.
 EventFilter createClassFilterIncludingSubclasses(org.eclipse.emf.ecore.EClass clazz)
          Creates a filter that matches a notification if its notifier's class equals the class passed to this filter's constructor or any subclasses thereof.
 EventFilter createContainmentFilter()
          Creates a filter that matches a notification that indicates a change in containment.
 EventManager createEventManager()
          Creates a new EventManager that initially does not receive change notifications from any resource set.
 EventManager createEventManagerFor(org.eclipse.emf.ecore.resource.ResourceSet set)
          Creates a new EventManager that receives all change notifications from all notifiers contained directly or indirectly by set.
 EventFilter createEventTypeFilter(int eventType)
          Filters for a Notification's event type, such as Notification.ADD or Notification.REMOVE.
 EventFilter createFilterForEAttribute(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EAttribute referredProperty)
          Constructs an AndFilter combining a ClassFilter for eClass and an PropertyFilter for referredProperty.
 EventFilter createFilterForElementInsertion(org.eclipse.emf.ecore.EClass cls)
          Creates an event filter that listens for events which indicate that an element of type cls has been added to the event manager's ResourceSet, either by directly assigning it to the immediate contents of a resource owned by the ResourceSet, or by assigning it to the containment reference of an element that is already part of the ResourceSet, or by adding a parent in the containment hierarchy to the ResourceSet.
 EventFilter createFilterForElementInsertionOrDeletion(org.eclipse.emf.ecore.EClass cls)
          Creates a filter tree, which will match if the given class get inserted or deleted by an event
 EventFilter createFilterForEReference(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EReference referredProperty)
          Constructs an AndFilter combining a ClassFilter for eClass and a PropertyFilter for referredProperty.
 EventFilter createNewValueClassFilter(org.eclipse.emf.ecore.EClass clazz)
          Creates a filter that matches an event's Notification.getNewValue() class.
 EventFilter createNewValueClassFilterIncludingSubclasses(org.eclipse.emf.ecore.EClass clazz)
          Creates a filter that matches an event's Notification.getNewValue() class to clazz and all subclasses thereof.
 EventFilter createNotFilter(EventFilter filter)
          Creates a filter that matches if and only if filter does not match.
 java.util.Collection<org.eclipse.emf.common.notify.Notification> createNotificationForComposites(org.eclipse.emf.common.notify.Notification event)
          If event indicates the setting/adding/removal of/to/from a containment reference, then it is expanded into a collection of event notifications that document the creation or, respectively, dismantling of the entire containment hierarchy.
 EventFilter createOldValueClassFilter(org.eclipse.emf.ecore.EClass clazz)
          Creates a filter that matches an event's Notification.getOldValue() class against clazz.
 EventFilter createOldValueClassFilterIncludingSubclasses(org.eclipse.emf.ecore.EClass clazz)
          Creates an filter that matches an event's Notification.getOldValue() class against clazz and all subclasses thereof.
 EventFilter createOrFilterFor(EventFilter... eventFilters)
          Shortcut, to create an OrFilter for incoming EventFilters
 EventFilter createStructuralFeatureFilter(org.eclipse.emf.ecore.EStructuralFeature feature)
          Creates a filter that matches a notification if its feature equals feature.
 EventManager getEventManagerFor(org.eclipse.emf.ecore.resource.ResourceSet set)
          Creates a new or re-uses an existing EventManager that was previously created by calling this operation (and not by createEventManagerFor(ResourceSet)).
 

Field Detail

eINSTANCE

static final EventManagerFactory eINSTANCE
The default instance implementing this interface

Method Detail

getEventManagerFor

EventManager getEventManagerFor(org.eclipse.emf.ecore.resource.ResourceSet set)
Creates a new or re-uses an existing EventManager that was previously created by calling this operation (and not by createEventManagerFor(ResourceSet)). The event manager receives all change notifications from all notifiers contained directly or indirectly by set. Those events matching the filters provided by listeners in their call to EventManager.subscribe(EventFilter, org.eclipse.emf.common.notify.Adapter) will be passed on to those listener Adapters.

Parameters:
set - if null, a null result will be returned
Returns:
a valid, non-null EventManager if and only if set!=null

createEventManager

EventManager createEventManager()
Creates a new EventManager that initially does not receive change notifications from any resource set. This is useful if you want to be able to already register adapters with the event manager without knowing the resource sets from which those adapters later shall receive their notifications. Well-suited for creating long-lived event managers.


createEventManagerFor

EventManager createEventManagerFor(org.eclipse.emf.ecore.resource.ResourceSet set)
Creates a new EventManager that receives all change notifications from all notifiers contained directly or indirectly by set. Those events matching the filters provided by listeners in their call to EventManager.subscribe(EventFilter, org.eclipse.emf.common.notify.Adapter) will be passed on to those listener Adapters. The event manager returned will never be returned by getEventManagerFor(ResourceSet). This is useful if you need to control which adapters subscribe to the event manager returned.


createEventTypeFilter

EventFilter createEventTypeFilter(int eventType)
Filters for a Notification's event type, such as Notification.ADD or Notification.REMOVE. EventTypeFilter#EventTypeFilter()


createNotFilter

EventFilter createNotFilter(EventFilter filter)
Creates a filter that matches if and only if filter does not match.


createStructuralFeatureFilter

EventFilter createStructuralFeatureFilter(org.eclipse.emf.ecore.EStructuralFeature feature)
Creates a filter that matches a notification if its feature equals feature.


createContainmentFilter

EventFilter createContainmentFilter()
Creates a filter that matches a notification that indicates a change in containment. This may be an EReference with its EReference.isContainer() or EReference.isContainment() set to true, or it may be a change in the containment of a Resource in a ResourceSet or of an EObject in a Resource.


createClassFilter

EventFilter createClassFilter(org.eclipse.emf.ecore.EClass clazz)
Creates a filter that matches a Notification if the object that changed has clazz as its class.


createClassFilterIncludingSubclasses

EventFilter createClassFilterIncludingSubclasses(org.eclipse.emf.ecore.EClass clazz)
Creates a filter that matches a notification if its notifier's class equals the class passed to this filter's constructor or any subclasses thereof.


createOldValueClassFilter

EventFilter createOldValueClassFilter(org.eclipse.emf.ecore.EClass clazz)
Creates a filter that matches an event's Notification.getOldValue() class against clazz. An exact match, not considering any inheritance relations, is required. If the new value is a collection, e.g., because several elements were removed from a many-feature at once, this filter matches if at least one of the elements' class is matched.

When several such filters are combined in an AndFilter, the AndFilter matches if all of its operand filters match. This does not require the individual OldValueClassFilters to match based on the same element in case the old value happens to be a collection. For example, assume there are two classes X and Y. Assume there is an AndFiter with two OldValueClassFilters inside, one matching X, the other matching Y. If there are two elements in the old value collection of the Notification, one of type X and the other of type Y, the first OldValueClassFilter matches because of the X element, and the second OldValueClassFilter matches because of the Y element and hence the AndFilter matches. However, no single element in the old value collection fulfills both criteria.


createOldValueClassFilterIncludingSubclasses

EventFilter createOldValueClassFilterIncludingSubclasses(org.eclipse.emf.ecore.EClass clazz)
Creates an filter that matches an event's Notification.getOldValue() class against clazz and all subclasses thereof. If the new value is a collection then this filter matches if at least one of the collection's elements is matched.

When several such filters are combined in an AndFilter, the AndFilter matches if all of its operand filters match. This does not require the individual OldValueClassFilterIncludingSubclasses s to match based on the same element in case the old value happens to be a collection. For example, assume there are two classes X and Y with a class Z that has both, X and Y as its superclasses (multiple inheritance). Assume there is an AndFiter with two OldValueClassFilterIncludingSubclassess inside, one matching X, the other matching Y. If only a single element is the old value of a Notification, the AndFilter matches the notification if and only if the old value conforms to both, X and Y, for example if its type is Z. However, if there are two elements in the old value collection of the Notification, one of type X and the other of type Y, the first OldValueClassFilterIncludingSubclasses matches because of the X element, and the second OldValueClassFilterIncludingSubclasses matches because of the Y element and hence the AndFilter matches. However, no single element in the old value collection fulfills both criteria.


createNewValueClassFilter

EventFilter createNewValueClassFilter(org.eclipse.emf.ecore.EClass clazz)
Creates a filter that matches an event's Notification.getNewValue() class. An exact match, not considering any inheritance relations, is required. If the new value is a collection, e.g., because several elements were assigned to a many-feature at once, this filter matches if at least one of the elements' class is matched.

When several such filters are combined in an AndFilter, the AndFilter matches if all of its operand filters match. This does not require the individual NewValueClassFilters to match based on the same element in case the new value happens to be a collection. For example, assume there are two classes X and Y. Assume there is an AndFiter with two NewValueClassFilters inside, one matching X, the other matching Y. If there are two elements in the new value collection of the Notification, one of type X and the other of type Y, the first NewValueClassFilter matches because of the X element, and the second NewValueClassFilter matches because of the Y element and hence the AndFilter matches. However, no single element in the new value collection fulfills both criteria.


createNewValueClassFilterIncludingSubclasses

EventFilter createNewValueClassFilterIncludingSubclasses(org.eclipse.emf.ecore.EClass clazz)
Creates a filter that matches an event's Notification.getNewValue() class to clazz and all subclasses thereof. If the new value is a collection then this filter matches if at least one of the collection's elements is matched.

When several such filters are combined in an AndFilter, the AndFilter matches if all of its operand filters match. This does not require the individual NewValueClassFilterIncludingSubclasses s to match based on the same element in case the new value happens to be a collection. For example, assume there are two classes X and Y with a class Z that has both, X and Y as its superclasses (multiple inheritance). Assume there is an AndFiter with two NewValueClassFilterIncludingSubclassess inside, one matching X, the other matching Y. If only a single element is the new value of a Notification, the AndFilter matches the notification if and only if the new value conforms to both, X and Y, for example if its type is Z. However, if there are two elements in the new value collection of the Notification, one of type X and the other of type Y, the first NewValueClassFilterIncludingSubclasses matches because of the X element, and the second NewValueClassFilterIncludingSubclasses matches because of the Y element and hence the AndFilter matches. However, no single element in the new value collection fulfills both criteria.


createFilterForEReference

EventFilter createFilterForEReference(org.eclipse.emf.ecore.EClass eClass,
                                      org.eclipse.emf.ecore.EReference referredProperty)
Constructs an AndFilter combining a ClassFilter for eClass and a PropertyFilter for referredProperty.


createFilterForEAttribute

EventFilter createFilterForEAttribute(org.eclipse.emf.ecore.EClass eClass,
                                      org.eclipse.emf.ecore.EAttribute referredProperty)
Constructs an AndFilter combining a ClassFilter for eClass and an PropertyFilter for referredProperty.


createFilterForElementInsertion

EventFilter createFilterForElementInsertion(org.eclipse.emf.ecore.EClass cls)
Creates an event filter that listens for events which indicate that an element of type cls has been added to the event manager's ResourceSet, either by directly assigning it to the immediate contents of a resource owned by the ResourceSet, or by assigning it to the containment reference of an element that is already part of the ResourceSet, or by adding a parent in the containment hierarchy to the ResourceSet.


createFilterForElementInsertionOrDeletion

EventFilter createFilterForElementInsertionOrDeletion(org.eclipse.emf.ecore.EClass cls)
Creates a filter tree, which will match if the given class get inserted or deleted by an event

Parameters:
cls - class to listen for
Returns:
the new filter tree

createOrFilterFor

EventFilter createOrFilterFor(EventFilter... eventFilters)
Shortcut, to create an OrFilter for incoming EventFilters

Parameters:
eventFilters - filter to combine with an OR
Returns:
the created OrFilter

createAndFilterFor

EventFilter createAndFilterFor(EventFilter... eventFilters)
Creates an AndFilter for incoming EventFilters. The resulting filter matches a Notification if and only if the Notification is matched by all eventFilters.

Parameters:
eventFilters - filter to combine with an and
Returns:
the created AndFilter

createNotificationForComposites

java.util.Collection<org.eclipse.emf.common.notify.Notification> createNotificationForComposites(org.eclipse.emf.common.notify.Notification event)
If event indicates the setting/adding/removal of/to/from a containment reference, then it is expanded into a collection of event notifications that document the creation or, respectively, dismantling of the entire containment hierarchy.

In any case, event is part of the collection returned.