View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  /*
19   */
20  package org.apache.log4j.rule;
21  
22  import org.apache.log4j.spi.LoggingEvent;
23  
24  import java.beans.PropertyChangeListener;
25  import java.util.Map;
26  
27  
28  /***
29   * A Rule evaluates to true of false given a LoggingEvent object, and can notify
30   * listeners when the underlying implementation of this Rule has it's
31   * criteria changed by using the standard PropertyChangeListener infrastructure.
32   *
33   * @author Paul Smith (psmith@apache.org)
34   * @author Scott Deboy (sdeboy@apache.org)
35   */
36  public interface Rule {
37    /***
38     * Returns true if this implementation of the rule accepts the LoggingEvent,
39     * or false if not.
40     *
41     * <p>What True/False means can be client-specific.
42     *
43     * @param e LoggingEvent this instance will evaluate
44     * @param matches a Map of event field keys to Sets of matching strings (may be null) which will be
45     * updated during execution of this method to include field and string matches based on the rule
46     * evaluation results 
47     * @return true if this Rule instance accepts the event, otherwise false.
48     */
49    boolean evaluate(LoggingEvent e, Map matches);
50  
51    /***
52     * Adds a PropertyChangeListener to this instance, which is notified when
53     * underlying Rule information has changed.
54     * (there are no specific property name events).
55     * @param listener listener
56     */
57    void addPropertyChangeListener(PropertyChangeListener listener);
58  
59    /***
60     * Removes a known PropertyChangeListener from this Rule.
61     * @param listener listener
62     */
63    void removePropertyChangeListener(PropertyChangeListener listener);
64  }