1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.observation.event.filter

File EventFilter.java

 

Code metrics

0
0
0
1
61
6
0
-
-
0
-

Classes

Class Line # Actions
EventFilter 35 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.observation.event.filter;
21   
22    /**
23    * Allows writing complex Event matching algorithms for the {@link org.xwiki.observation.event.Event#matches(Object)}
24    * method.
25    * <p>
26    * For example, this allows writing {@link org.xwiki.observation.event.filter.RegexEventFilter} that can be used to
27    * easily match several documents at once. The following will match all Documents which are saved which have a name
28    * matching the {@code .*Doc.*} regex:
29    * <pre>{@code
30    * new DocumentSaveEvent(new RegexEventFilter(".*Doc.*"))
31    * }</pre>
32    *
33    * @version $Id: 50a76d50345156c733765cda1f30b14526d372a0 $
34    */
 
35    public interface EventFilter
36    {
37    /**
38    * Provides access to the filter's criterion.
39    *
40    * @return the filter used in the {@link #matches(EventFilter)} method to verify if a passed event filter matches
41    * it.
42    * @see #matches(EventFilter)
43    */
44    String getFilter();
45   
46    /**
47    * Compares two event filters to see if they <em>match</em>, meaning that the "contexts" of two events are
48    * compatible. For example, a {@link FixedNameEventFilter} matches another filter only if they both have the same
49    * name set as the filter, while an {@link AlwaysMatchingEventFilter} matches any other event filter. A listener
50    * that registered to receive notifications <em>like</em> <code>referenceEvent</code> and with
51    * <code>referenceEventFilter</code>, will be notified of any occuring event for which
52    * <code>referenceEvent.matches(occuringEvent)</code> will return <code>true</code> and
53    * <code>referenceEvent.getEventFilter().matches(occurringEvent.getEventFilter())</code>.
54    *
55    * @param eventFilter the event filter to compare to the filter value
56    * @return <code>true</code> if both event filters match. The matching algorithm is left to the filter event
57    * implementation. For example the {@link RegexEventFilter Regex event filter} will match another filter if
58    * that other filter matches the regex.
59    */
60    boolean matches(EventFilter eventFilter);
61    }