org.xwiki.observation.event
Class AbstractFilterableEvent

java.lang.Object
  extended by org.xwiki.observation.event.AbstractFilterableEvent
All Implemented Interfaces:
Serializable, Event, FilterableEvent
Direct Known Subclasses:
AbstractCancelableEvent

public abstract class AbstractFilterableEvent
extends Object
implements FilterableEvent, Serializable

A generic Event implementation to extend for all Events that want to support EventFilters.

Since:
2.4M2
Version:
$Id: 6c843fb96eb3c34d4af1d30bcec36cfa05a62aed $
See Also:
Serialized Form

Constructor Summary
AbstractFilterableEvent()
          Constructor initializing the event filter with an AlwaysMatchingEventFilter, meaning that this event will match any other event of the same type.
AbstractFilterableEvent(EventFilter eventFilter)
          Constructor using a custom EventFilter.
AbstractFilterableEvent(String name)
          Constructor initializing the event filter with a FixedNameEventFilter, meaning that this event will match only events of the same type affecting the same passed name.
 
Method Summary
 boolean equals(Object object)
           
 EventFilter getEventFilter()
          Retrieves the filter used to match this event against other events, used in Event.matches(Object).
 int hashCode()
           
 boolean matches(Object otherEvent)
          Compares two events to see if they match, meaning that a listener that registered to receive notifications like referenceEvent will be notified of any occuring event for which referenceEvent.matches(occuringEvent) will return true.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractFilterableEvent

public AbstractFilterableEvent()
Constructor initializing the event filter with an AlwaysMatchingEventFilter, meaning that this event will match any other event of the same type.


AbstractFilterableEvent

public AbstractFilterableEvent(String name)
Constructor initializing the event filter with a FixedNameEventFilter, meaning that this event will match only events of the same type affecting the same passed name.

Parameters:
name - a generic name that uniquely identifies an event type

AbstractFilterableEvent

public AbstractFilterableEvent(EventFilter eventFilter)
Constructor using a custom EventFilter.

Parameters:
eventFilter - the filter to use for matching events
Method Detail

getEventFilter

public EventFilter getEventFilter()
Description copied from interface: FilterableEvent
Retrieves the filter used to match this event against other events, used in Event.matches(Object).

Specified by:
getEventFilter in interface FilterableEvent
Returns:
the event's filter

matches

public boolean matches(Object otherEvent)
Compares two events to see if they match, meaning that a listener that registered to receive notifications like referenceEvent will be notified of any occuring event for which referenceEvent.matches(occuringEvent) will return true. The matching algorithm depends on the event implementation. For example for Document events two events match if they implement the same event class and if their EventFilter match. Note that the implementation is left open in order to cater for all the possible ways this Observation component can be used.

This type of events match only events of the same type, and only if the internal eventFilters also match.

Specified by:
matches in interface Event
Parameters:
otherEvent - the occuring event matched against the current object
Returns:
true if the passed event matches this event, false otherwise.
See Also:
Event.matches(Object), EventFilter.matches(EventFilter)

equals

public boolean equals(Object object)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2004-2013 XWiki. All Rights Reserved.