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