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  
26  
27  /***
28   * A Rule evaluates to true of false given a LoggingEvent object, and can notify
29   * listeners when the underlying implementation of this Rule has it's
30   * criteria changed by using the standard PropertyChangeListener infrastructure.
31   *
32   * @author Paul Smith (psmith@apache.org)
33   * @author Scott Deboy (sdeboy@apache.org)
34   */
35  public interface Rule {
36    /***
37     * Returns true if this implementation of the rule accepts the LoggingEvent,
38     * or false if not.
39     *
40     * <p>What True/False means can be client-specific.
41     *
42     * @param e LoggingEvent this instance will evaluate
43     * @return true if this Rule instance accepts the event, otherwise false.
44     */
45    boolean evaluate(LoggingEvent e);
46  
47    /***
48     * Adds a PropertyChangeListener to this instance, which is notified when
49     * underlying Rule information has changed.
50     * (there are no specific property name events).
51     * @param listener listener
52     */
53    void addPropertyChangeListener(PropertyChangeListener listener);
54  
55    /***
56     * Removes a known PropertyChangeListener from this Rule.
57     * @param listener listener
58     */
59    void removePropertyChangeListener(PropertyChangeListener listener);
60  }