001////////////////////////////////////////////////////////////////////////////////
002// checkstyle: Checks Java source code for adherence to a set of rules.
003// Copyright (C) 2001-2018 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 * @author Richard Veach
029 */
030public interface RootModule extends Configurable {
031
032    /** Cleans up the object. **/
033    void destroy();
034
035    /**
036     * Processes a set of files.
037     * Once this is done, it is highly recommended to call for
038     * the destroy method to close and remove the listeners.
039     * @param files the list of files to be audited.
040     * @return the total number of errors 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     * @param listener the nosy thing
049     */
050    void addListener(AuditListener listener);
051
052    /**
053     * Sets the classloader used to load Checkstyle core and custom module
054     * classes when the module tree is being built up.
055     * If no custom ModuleFactory is being set for the root module then
056     * this module classloader must be specified.
057     * @param moduleClassLoader the classloader used to load module classes
058     */
059    void setModuleClassLoader(ClassLoader moduleClassLoader);
060
061}