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 package org.apache.log4j.spi; 18 19 /** 20 * @since 0.9.0 21 */ 22 public abstract class Filter { 23 24 /** 25 * The log event must be dropped immediately without consulting 26 * with the remaining filters, if any, in the chain. 27 */ 28 public static final int DENY = -1; 29 30 /** 31 * This filter is neutral with respect to the log event. The 32 * remaining filters, if any, should be consulted for a final decision. 33 */ 34 public static final int NEUTRAL = 0; 35 36 /** 37 * The log event must be logged immediately without consulting with 38 * the remaining filters, if any, in the chain. 39 */ 40 public static final int ACCEPT = 1; 41 42 /** 43 * Points to the next filter in the filter chain. 44 * 45 * @deprecated As of 1.2.12, use {@link #getNext} and {@link #setNext} instead 46 */ 47 @Deprecated 48 public Filter next; 49 50 /** 51 * Usually filters options become active when set. We provide a 52 * default do-nothing implementation for convenience. 53 */ 54 public void activateOptions() { 55 } 56 57 58 /** 59 * <p>If the decision is <code>DENY</code>, then the event will be 60 * dropped. If the decision is <code>NEUTRAL</code>, then the next 61 * filter, if any, will be invoked. If the decision is ACCEPT then 62 * the event will be logged without consulting with other filters in 63 * the chain. 64 * 65 * @param event The LoggingEvent to decide upon. 66 * @return decision The decision of the filter. 67 */ 68 public abstract int decide(LoggingEvent event); 69 70 /** 71 * Set the next filter pointer. 72 * @param next The next Filter. 73 */ 74 public void setNext(final Filter next) { 75 this.next = next; 76 } 77 78 /** 79 * Return the pointer to the next filter. 80 * @return The next Filter. 81 */ 82 public Filter getNext() { 83 return next; 84 } 85 86 }