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
018package org.apache.log4j.spi;
019
020import org.apache.log4j.Appender;
021
022import java.util.Enumeration;
023
024/**
025 * Interface for attaching appenders to objects.
026 */
027public interface AppenderAttachable {
028
029    /**
030     * Add an appender.
031     * @param newAppender The Appender to add.
032     */
033    void addAppender(Appender newAppender);
034
035    /**
036     * Get all previously added appenders as an Enumeration.
037     * @return The Enumeration of the Appenders.
038     */
039    Enumeration<Appender> getAllAppenders();
040
041    /**
042     * Get an appender by name.
043     * @param name The name of the Appender.
044     * @return The Appender.
045     */
046    Appender getAppender(String name);
047
048
049    /**
050     * Returns <code>true</code> if the specified appender is in list of
051     * attached attached, <code>false</code> otherwise.
052     * @param appender The Appender to check.
053     * @return true if the Appender is attached.
054     *
055     * @since 1.2
056     */
057    boolean isAttached(Appender appender);
058
059    /**
060     * Remove all previously added appenders.
061     */
062    void removeAllAppenders();
063
064
065    /**
066     * Remove the appender passed as parameter from the list of appenders.
067     * @param appender The Appender to remove.
068     */
069    void removeAppender(Appender appender);
070
071
072    /**
073     * Remove the appender with the name passed as parameter from the
074     * list of appenders.
075     * @param name The name of the Appender to remove.
076     */
077    void removeAppender(String name);
078}