001///////////////////////////////////////////////////////////////////////////////////////////////
002// checkstyle: Checks Java source code and other text files for adherence to a set of rules.
003// Copyright (C) 2001-2026 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;
021
022import com.puppycrawl.tools.checkstyle.api.DetailAST;
023import com.puppycrawl.tools.checkstyle.api.FileContents;
024import com.puppycrawl.tools.checkstyle.api.Violation;
025
026/**
027 * Raw {@code TreeWalker} event for audit.
028 *
029 * @param fileContents contents of the file associated with the event
030 * @param fileName file associated with the event
031 * @param violation the actual violation
032 * @param rootAst root AST element {@link DetailAST} of the file
033 */
034public record TreeWalkerAuditEvent(
035        FileContents fileContents,
036        String fileName,
037        Violation violation,
038        DetailAST rootAst) {
039
040    /**
041     * Return the line number on the source file where the event occurred.
042     * This may be 0 if there is no relation to a file content.
043     *
044     * @return an integer representing the line number in the file source code.
045     */
046    public int getLine() {
047        return violation.getLineNo();
048    }
049
050    /**
051     * Return the violation associated to the event.
052     *
053     * @return the violation message
054     */
055    public String getMessage() {
056        return violation.getViolation();
057    }
058
059    /**
060     * Gets the column associated with the violation.
061     *
062     * @return the column associated with the violation
063     */
064    public int getColumn() {
065        return violation.getColumnNo();
066    }
067
068    /**
069     * Gets the column char index associated with the violation.
070     *
071     * @return the column char index associated with the violation
072     */
073    public int getColumnCharIndex() {
074        return violation.getColumnCharIndex();
075    }
076
077    /**
078     * Returns id of module.
079     *
080     * @return the identifier of the module that generated the event. Can return
081     *         null.
082     */
083    public String getModuleId() {
084        return violation.getModuleId();
085    }
086
087    /**
088     * Gets the name of the source for the violation.
089     *
090     * @return the name of the source for the violation
091     */
092    public String getSourceName() {
093        return violation.getSourceName();
094    }
095
096    /**
097     * Gets the token type of the violation.
098     *
099     * @return the token type of the violation
100     */
101    public int getTokenType() {
102        return violation.getTokenType();
103    }
104
105}