Class SuppressionCommentFilter.Tag
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.filters.SuppressionCommentFilter.Tag
-
- All Implemented Interfaces:
Comparable<SuppressionCommentFilter.Tag>
- Enclosing class:
- SuppressionCommentFilter
private static final class SuppressionCommentFilter.Tag extends Object implements Comparable<SuppressionCommentFilter.Tag>
A Tag holds a suppression comment and its location, and determines whether the suppression turns checkstyle reporting on or off.
-
-
Field Summary
Fields Modifier and Type Field Description private int
column
The column number of the tag.private int
line
The line number of the tag.private Pattern
tagCheckRegexp
The parsed check regexp, expanded for the text of this tag.private Pattern
tagIdRegexp
The parsed check ID regexp, expanded for the text of this tag.private Pattern
tagMessageRegexp
The parsed message regexp, expanded for the text of this tag.private SuppressionCommentFilter.TagType
tagType
Determines whether the suppression turns checkstyle reporting on.private String
text
The text of the tag.
-
Constructor Summary
Constructors Modifier Constructor Description private
Tag(int line, int column, String text, SuppressionCommentFilter.TagType tagType, SuppressionCommentFilter filter)
Constructs a tag.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(SuppressionCommentFilter.Tag object)
Compares the position of this tag in the file with the position of another tag.boolean
equals(Object other)
Indicates whether some other object is "equal to" this one.int
getColumn()
Determines the column number of the tag in the source file.int
getLine()
Returns line number of the tag in the source file.SuppressionCommentFilter.TagType
getTagType()
Determines whether the suppression turns checkstyle reporting on or off.int
hashCode()
private boolean
isCheckMatch(TreeWalkerAuditEvent event)
Checks whetherTreeWalkerAuditEvent
source name matches the check format.private boolean
isIdMatch(TreeWalkerAuditEvent event)
Checks whether theTreeWalkerAuditEvent
module ID matches the ID format.boolean
isMatch(TreeWalkerAuditEvent event)
Determines whether the source of an audit event matches the text of this tag.private boolean
isMessageMatch(TreeWalkerAuditEvent event)
Checks whether theTreeWalkerAuditEvent
message matches the message format.String
toString()
-
-
-
Field Detail
-
line
private final int line
The line number of the tag.
-
column
private final int column
The column number of the tag.
-
tagType
private final SuppressionCommentFilter.TagType tagType
Determines whether the suppression turns checkstyle reporting on.
-
tagCheckRegexp
private final Pattern tagCheckRegexp
The parsed check regexp, expanded for the text of this tag.
-
tagMessageRegexp
private final Pattern tagMessageRegexp
The parsed message regexp, expanded for the text of this tag.
-
tagIdRegexp
private final Pattern tagIdRegexp
The parsed check ID regexp, expanded for the text of this tag.
-
-
Constructor Detail
-
Tag
private Tag(int line, int column, String text, SuppressionCommentFilter.TagType tagType, SuppressionCommentFilter filter)
Constructs a tag.- Parameters:
line
- the line number.column
- the column number.text
- the text of the suppression.tagType
-ON
if the tag turns checkstyle reporting.filter
- theSuppressionCommentFilter
with the context- Throws:
IllegalArgumentException
- if unable to parse expanded text.
-
-
Method Detail
-
getLine
public int getLine()
Returns line number of the tag in the source file.- Returns:
- the line number of the tag in the source file.
-
getColumn
public int getColumn()
Determines the column number of the tag in the source file. Will be 0 for all lines of multiline comment, except the first line.- Returns:
- the column number of the tag in the source file.
-
getTagType
public SuppressionCommentFilter.TagType getTagType()
Determines whether the suppression turns checkstyle reporting on or off.- Returns:
ON
if the suppression turns reporting on.
-
compareTo
public int compareTo(SuppressionCommentFilter.Tag object)
Compares the position of this tag in the file with the position of another tag.- Specified by:
compareTo
in interfaceComparable<SuppressionCommentFilter.Tag>
- Parameters:
object
- the tag to compare with this one.- Returns:
- a negative number if this tag is before the other tag, 0 if they are at the same position, and a positive number if this tag is after the other tag.
-
equals
public boolean equals(Object other)
Indicates whether some other object is "equal to" this one. Suppression on enumeration is needed so code stays consistent.
-
isMatch
public boolean isMatch(TreeWalkerAuditEvent event)
Determines whether the source of an audit event matches the text of this tag.- Parameters:
event
- theTreeWalkerAuditEvent
to check.- Returns:
- true if the source of event matches the text of this tag.
-
isCheckMatch
private boolean isCheckMatch(TreeWalkerAuditEvent event)
Checks whetherTreeWalkerAuditEvent
source name matches the check format.- Parameters:
event
-TreeWalkerAuditEvent
instance.- Returns:
- true if the
TreeWalkerAuditEvent
source name matches the check format.
-
isIdMatch
private boolean isIdMatch(TreeWalkerAuditEvent event)
Checks whether theTreeWalkerAuditEvent
module ID matches the ID format.- Parameters:
event
-TreeWalkerAuditEvent
instance.- Returns:
- true if the
TreeWalkerAuditEvent
module ID matches the ID format.
-
isMessageMatch
private boolean isMessageMatch(TreeWalkerAuditEvent event)
Checks whether theTreeWalkerAuditEvent
message matches the message format.- Parameters:
event
-TreeWalkerAuditEvent
instance.- Returns:
- true if the
TreeWalkerAuditEvent
message matches the message format.
-
-