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         * Points to the next filter in the filter chain.
026         *
027         * @deprecated As of 1.2.12, use {@link #getNext} and {@link #setNext} instead
028         */
029        public Filter next;
030    
031        /**
032         * The log event must be dropped immediately without consulting
033         * with the remaining filters, if any, in the chain.
034         */
035        public static final int DENY = -1;
036    
037        /**
038         * This filter is neutral with respect to the log event. The
039         * remaining filters, if any, should be consulted for a final decision.
040         */
041        public static final int NEUTRAL = 0;
042    
043        /**
044         * The log event must be logged immediately without consulting with
045         * the remaining filters, if any, in the chain.
046         */
047        public static final int ACCEPT = 1;
048    
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        abstract public int decide(LoggingEvent event);
069    
070        /**
071         * Set the next filter pointer.
072         */
073        public void setNext(Filter next) {
074            this.next = next;
075        }
076    
077        /**
078         * Return the pointer to the next filter;
079         */
080        public Filter getNext() {
081            return next;
082        }
083    
084    }