001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache license, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the license for the specific language governing permissions and 015 * limitations under the license. 016 */ 017 package org.apache.log4j.spi; 018 019 /** 020 * @since 0.9.0 021 */ 022 public abstract class Filter { 023 024 /** 025 * The log event must be dropped immediately without consulting 026 * with the remaining filters, if any, in the chain. 027 */ 028 public static final int DENY = -1; 029 030 /** 031 * This filter is neutral with respect to the log event. The 032 * remaining filters, if any, should be consulted for a final decision. 033 */ 034 public static final int NEUTRAL = 0; 035 036 /** 037 * The log event must be logged immediately without consulting with 038 * the remaining filters, if any, in the chain. 039 */ 040 public static final int ACCEPT = 1; 041 042 /** 043 * Points to the next filter in the filter chain. 044 * 045 * @deprecated As of 1.2.12, use {@link #getNext} and {@link #setNext} instead 046 */ 047 @Deprecated 048 public Filter next; 049 050 /** 051 * Usually filters options become active when set. We provide a 052 * default do-nothing implementation for convenience. 053 */ 054 public void activateOptions() { 055 } 056 057 058 /** 059 * <p>If the decision is <code>DENY</code>, then the event will be 060 * dropped. If the decision is <code>NEUTRAL</code>, then the next 061 * filter, if any, will be invoked. If the decision is ACCEPT then 062 * the event will be logged without consulting with other filters in 063 * the chain. 064 * 065 * @param event The LoggingEvent to decide upon. 066 * @return decision The decision of the filter. 067 */ 068 public abstract int decide(LoggingEvent event); 069 070 /** 071 * Set the next filter pointer. 072 * @param next The next Filter. 073 */ 074 public void setNext(final Filter next) { 075 this.next = next; 076 } 077 078 /** 079 * Return the pointer to the next filter. 080 * @return The next Filter. 081 */ 082 public Filter getNext() { 083 return next; 084 } 085 086 }