/** * Constructor initializing the event filter with a {@link org.xwiki.observation.event.filter.FixedNameEventFilter}, * meaning that this event will match only events of the same type affecting the same passed name. * * @param name a generic name that uniquely identifies an event type */ public AbstractFilterableEvent(String name) { this.eventFilter = new FixedNameEventFilter(name); }
@Override public int hashCode() { return new HashCodeBuilder(3, 125).append(getFilter()).toHashCode(); } }
@Override public boolean matches(EventFilter eventFilter) { Matcher matcher = this.pattern.matcher(eventFilter.getFilter()); return matcher.matches(); } }
/** * {@inheritDoc} * <p> * This type of events match only events of the same type, and only if the internal {@link #eventFilter}s also * {@link EventFilter#matches(EventFilter)} match. * </p> * * @see Event#matches(Object) * @see EventFilter#matches(EventFilter) */ @Override public boolean matches(Object otherEvent) { if (otherEvent == this) { return true; } boolean isMatching = false; if (this.getClass().isAssignableFrom(otherEvent.getClass())) { isMatching = getEventFilter().matches(((AbstractFilterableEvent) otherEvent).getEventFilter()); } return isMatching; }
/** * {@inheritDoc} * * @see org.xwiki.bridge.event.WikiEvent#getWikiId() */ public String getWikiId() { return getEventFilter().getFilter(); } }
/** * Constructor initializing the event filter with a {@link org.xwiki.observation.event.filter.FixedNameEventFilter}, * meaning that this event will match only comment events affecting the document matching the passed document name. * * @param documentName the name of the updated document to match * @param identifier the identifier of the annotation added/updated/deleted */ public AbstractAnnotationEvent(String documentName, String identifier) { // TODO refactor annotation event to take a document reference as constructor and depreciate this constructor super(new FixedNameEventFilter(documentName)); this.identifier = identifier; }
@Override public String getWikiId() { return getEventFilter().getFilter(); } }
/** * Constructor initializing the event filter with a {@link org.xwiki.observation.event.filter.FixedNameEventFilter}, * meaning that this event will match only comment events affecting the document matching the passed document name. * * @param documentName the name of the updated document to match * @param identifier the identifier of the comment added/updated/deleted */ public AbstractCommentEvent(String documentName, String identifier) { // TODO: depreciate this constructor and add a constructor taking a document reference instead super(new FixedNameEventFilter(documentName)); this.identifier = identifier; }
@Override public void onEvent(Event event, Object source, Object data) { this.cache.remove(((AbstractDocumentEvent) event).getEventFilter().getFilter()); }
/** * Constructor initializing the event filter with a {@link org.xwiki.observation.event.filter.FixedNameEventFilter}, * meaning that this event will match only attachment events affecting the document matching the passed document * name. * * @param documentName the name of the updated document to match * @param name the name of the attachment added/updated/deleted */ public AbstractAttachmentEvent(String documentName, String name) { // TODO: depreciate this constructor and add a constructor taking a document reference instead super(new FixedNameEventFilter(documentName)); this.name = name; }
@Override public void onEvent(Event event, Object source, Object data) { this.cache.remove(((AbstractDocumentEvent) event).getEventFilter().getFilter()); }