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 *      https://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.commons.io.input;
019
020/**
021 * Listens to events from a {@link Tailer}.
022 *
023 * @since 2.0
024 */
025public interface TailerListener {
026
027    /**
028     * Called if the tailed file is not found.
029     * <p>
030     * <strong>Note:</strong> this is called from the tailer thread.
031     * </p>
032     */
033    void fileNotFound();
034
035    /**
036     * Called if a file rotation is detected.
037     *
038     * This method is called before the file is reopened, and fileNotFound may be called if the new file has not yet been created.
039     * <p>
040     * <strong>Note:</strong> Called from the tailer thread.
041     * </p>
042     */
043    void fileRotated();
044
045    /**
046     * Called when an Exception is thrown.
047     * <p>
048     * <strong>Note:</strong> Called from the tailer thread.
049     * </p>
050     *
051     * @param e the exception.
052     */
053    void handle(Exception e);
054
055    /**
056     * Called when a line is read.
057     * <p>
058     * <strong>Note:</strong> Called from the tailer thread.
059     * </p>
060     *
061     * @param line the line.
062     */
063    void handle(String line);
064
065    /**
066     * Called during construction, giving the listener a method of stopping the tailer.
067     *
068     * @param tailer the tailer.
069     */
070    void init(Tailer tailer);
071}