org.eclipse.emf.transaction
Class NotificationFilter
java.lang.Object
org.eclipse.emf.transaction.NotificationFilter
-
Direct Known Subclasses:
-
NotificationFilter.Custom
-
public abstract class NotificationFilter
- extends
Object
A filter that determines which
Notification
s will be passed to
ResourceSetListener
s. Filters can be combined using simple
boolean operations.
The default filter for listeners that do not otherwise declare one is
NOT_TOUCH
.
Note that
ResourceSetListener
s never receive
Notification.REMOVING_ADAPTER
notifications because these are
intended only to inform an adapter that it is being removed; they are
not broadcast to all adapters of an object. Besides which, resource set
listeners are not adapters.
Since the EMF Transaction 1.3 release, clients can implement arbitrary
filter criteria by specializing the
NotificationFilter.Custom
class.
-
See Also:
-
ResourceSetListener
,
Notification
Methods inherited from class java.lang.
Object
|
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
|
ANY
public static final
NotificationFilter ANY
- As its name implies, this filter matches any notification.
NOT_TOUCH
public static final
NotificationFilter NOT_TOUCH
- Matches only notifications that are not "touches."
-
See Also:
-
Notification.isTouch()
READ
public static final
NotificationFilter READ
- Matches any notification that can occur during the normal course of
a read-only transaction. These include:
- proxy resolution
- any change to the
resources
list of a resource set
- any change to the
isLoaded
, isModified
,
URI
, errors
, warnings
, and
resourceSet
features of a resource
- any change to the
contents
of
a resource while it is loading or unloading
RESOURCE_LOADED
public static final
NotificationFilter RESOURCE_LOADED
- A filter matching "resource loaded" events.
RESOURCE_UNLOADED
public static final
NotificationFilter RESOURCE_UNLOADED
- A filter matching "resource unloaded" events.
createResourceContentTypeFilter
public static
NotificationFilter createResourceContentTypeFilter(
String contentType)
- Creates a filter matches any notification from a resource of the
specified content type. Because the determination of a resource's
content type is costly, it is cached on the resource via an adapter and
is cleared on any change to the resource's contents or other properties.
-
-
Parameters:
-
contentType
- the content type identifier to match
-
Returns:
- the filter
-
Throws:
-
IllegalArgumentException
- if the specified content type is not
defined -
See Also:
-
IContentType
createNotifierFilter
public static
NotificationFilter createNotifierFilter(
Object notifier)
- Creates a filter matching any notification from the specified notifier.
-
-
Parameters:
-
notifier
- a notifier (usually an
EObject
,
Resource
,
or
ResourceSet
-
Returns:
- the filter
createEventTypeFilter
public static
NotificationFilter createEventTypeFilter(int eventType)
- Creates a filter matching any notification of the specified type.
-
-
Parameters:
-
eventType
- the notification type (as defined by the
Notification
interface)
-
Returns:
- the filter
createFeatureFilter
public static
NotificationFilter createFeatureFilter(
EStructuralFeature feature)
- Creates a filter matching any notification from the specified feature.
-
-
Parameters:
-
feature
- a structural feature meta-object
-
Returns:
- the filter
createFeatureFilter
public static
NotificationFilter createFeatureFilter(
Class<?> ownerType,
int featureId)
- Creates a filter matching any notification from the specified feature.
This variant is useful for notifiers that are not modeled via Ecore.
-
-
Parameters:
-
ownerType
- the notifier type as a Java class or interface -
featureId
- the feature's numeric ID
-
Returns:
- the filter
createFeatureFilter
public static
NotificationFilter createFeatureFilter(
EClassifier ownerType,
int featureId)
- Creates a filter matching any notification from the specified feature.
This variant is useful for notifiers that are not modeled as
EClass
es. For example, this supports the features of the
Resource
data type.
-
-
Parameters:
-
ownerType
- the notifier type as an Ecore classifier -
featureId
- the feature's numeric ID
-
Returns:
- the filter
createNotifierTypeFilter
public static
NotificationFilter createNotifierTypeFilter(
Class<?> type)
- Creates a filter matching notifications from any instance of the
specified type. This variant is useful for notifiers that are not
modeled via Ecore.
-
-
Parameters:
-
type
- the notifier type as a Java class or interface
-
Returns:
- the filter
createNotifierTypeFilter
public static
NotificationFilter createNotifierTypeFilter(
EClassifier type)
- Creates a filter matching notifications from any instance of the
specified type. This variant is useful for notifiers that are
modeled via Ecore.
-
-
Parameters:
-
type
- the notifier type as an Ecore classifier
-
Returns:
- the filter
and
public final
NotificationFilter and(
NotificationFilter other)
- Creates a new filter combining me with another as a boolean conjunction.
The "and" operation short-circuits; the
other
filter is not
consulted when I (the first filter) do not match.
-
-
Parameters:
-
other
- another filter (must not be null
)
-
Returns:
- a new "and" filter
or
public final
NotificationFilter or(
NotificationFilter other)
- Creates a new filter combining me with another as a boolean disjunction.
The "or" operation short-circuits; the
other
filter is not
consulted when I (the first filter) match.
-
-
Parameters:
-
other
- another filter (must not be null
)
-
Returns:
- a new "or" filter
negated
public final
NotificationFilter negated()
- Creates a new filter that is the boolean negation of me.
-
-
Returns:
- the opposite of me
matches
public abstract boolean matches(
Notification notification)
- Determines whether a notification matches my filtering criteria.
Notifications that match are passed to the listener for which I am
filtering.
-
-
Parameters:
-
notification
- a notification
-
Returns:
-
true
if the notification should be passed to my
listener; false
, otherwise