001///////////////////////////////////////////////////////////////////////////////////////////////
002// checkstyle: Checks Java source code and other text files for adherence to a set of rules.
003// Copyright (C) 2001-2024 the original author or authors.
004//
005// This library is free software; you can redistribute it and/or
006// modify it under the terms of the GNU Lesser General Public
007// License as published by the Free Software Foundation; either
008// version 2.1 of the License, or (at your option) any later version.
009//
010// This library is distributed in the hope that it will be useful,
011// but WITHOUT ANY WARRANTY; without even the implied warranty of
012// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013// Lesser General Public License for more details.
014//
015// You should have received a copy of the GNU Lesser General Public
016// License along with this library; if not, write to the Free Software
017// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018///////////////////////////////////////////////////////////////////////////////////////////////
019
020package com.puppycrawl.tools.checkstyle.api;
021
022import java.util.EventListener;
023
024/**
025 * Listener in charge of receiving events from the Checker.
026 * Typical events sequence is:
027 * <pre>
028 * auditStarted
029 *   (fileStarted
030 *     (addError)*
031 *   fileFinished )*
032 * auditFinished
033 * </pre>
034 */
035public interface AuditListener
036    extends EventListener {
037
038    /**
039     * Notify that the audit is about to start.
040     *
041     * @param event the event details
042     */
043    void auditStarted(AuditEvent event);
044
045    /**
046     * Notify that the audit is finished.
047     *
048     * @param event the event details
049     */
050    void auditFinished(AuditEvent event);
051
052    /**
053     * Notify that audit is about to start on a specific file.
054     *
055     * @param event the event details
056     */
057    void fileStarted(AuditEvent event);
058
059    /**
060     * Notify that audit is finished on a specific file.
061     *
062     * @param event the event details
063     */
064    void fileFinished(AuditEvent event);
065
066    /**
067     * Notify that an audit error was discovered on a specific file.
068     *
069     * @param event the event details
070     */
071    void addError(AuditEvent event);
072
073    /**
074     * Notify that an exception happened while performing audit.
075     *
076     * @param event the event details
077     * @param throwable details of the exception
078     */
079    void addException(AuditEvent event, Throwable throwable);
080
081}