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.io.File;
023import java.util.List;
024
025/**
026 * The first module that is run as part of Checkstyle and controls its entire
027 * behavior and children.
028 */
029public interface RootModule extends Configurable {
030
031    /** Cleans up the object. **/
032    void destroy();
033
034    /**
035     * Processes a set of files.
036     * Once this is done, it is highly recommended to call for
037     * the destroy method to close and remove the listeners.
038     *
039     * @param files the list of files to be audited.
040     * @return the total number of audit events with error severity found
041     * @throws CheckstyleException if error condition within Checkstyle occurs
042     * @see #destroy()
043     */
044    int process(List<File> files) throws CheckstyleException;
045
046    /**
047     * Add the listener that will be used to receive events from the audit.
048     *
049     * @param listener the nosy thing
050     */
051    void addListener(AuditListener listener);
052
053    /**
054     * Sets the classloader used to load Checkstyle core and custom module
055     * classes when the module tree is being built up.
056     * If no custom ModuleFactory is being set for the root module then
057     * this module classloader must be specified.
058     *
059     * @param moduleClassLoader the classloader used to load module classes
060     */
061    void setModuleClassLoader(ClassLoader moduleClassLoader);
062
063}