Class RegexpSinglelineJavaCheck
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
-
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
-
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
-
- com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck
-
- All Implemented Interfaces:
Configurable
,Contextualizable
public class RegexpSinglelineJavaCheck extends AbstractCheck
Checks that a specified pattern matches a single-line in Java files.This class is variation on RegexpSingleline for detecting single-lines that match a supplied regular expression in Java files. It supports suppressing matches in Java comments.
-
Property
format
- Specify the format of the regular expression to match. Type isjava.util.regex.Pattern
. Default value is"$."
. -
Property
ignoreCase
- Control whether to ignore case when searching. Type isboolean
. Default value isfalse
. -
Property
ignoreComments
- Control whether to ignore text in comments when searching. Type isboolean
. Default value isfalse
. -
Property
maximum
- Specify the maximum number of matches required in each file. Type isint
. Default value is0
. -
Property
message
- Specify the message which is used to notify about violations, if empty then default (hard-coded) message is used. Type isjava.lang.String
. Default value isnull
. -
Property
minimum
- Specify the minimum number of matches required in each file. Type isint
. Default value is0
.
Parent is
com.puppycrawl.tools.checkstyle.TreeWalker
Violation Message Keys:
-
regexp.exceeded
-
regexp.minimum
- Since:
- 6.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions
-
-
Field Summary
Fields Modifier and Type Field Description private String
format
Specify the format of the regular expression to match.private boolean
ignoreCase
Control whether to ignore case when searching.private boolean
ignoreComments
Control whether to ignore text in comments when searching.private int
maximum
Specify the maximum number of matches required in each file.private String
message
Specify the message which is used to notify about violations, if empty then default (hard-coded) message is used.private int
minimum
Specify the minimum number of matches required in each file.
-
Constructor Summary
Constructors Constructor Description RegexpSinglelineJavaCheck()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginTree(DetailAST rootAST)
Called before the starting to process a tree.int[]
getAcceptableTokens()
The configurable token set.int[]
getDefaultTokens()
Returns the default token a check is interested in.int[]
getRequiredTokens()
The tokens that this check must be registered for.void
setFormat(String format)
Setter to specify the format of the regular expression to match.void
setIgnoreCase(boolean ignoreCase)
Setter to control whether to ignore case when searching.void
setIgnoreComments(boolean ignore)
Setter to control whether to ignore text in comments when searching.void
setMaximum(int maximum)
Setter to specify the maximum number of matches required in each file.void
setMessage(String message)
Setter to specify the message which is used to notify about violations, if empty then default (hard-coded) message is used.void
setMinimum(int minimum)
Setter to specify the minimum number of matches required in each file.-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
clearViolations, destroy, finishTree, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokens, visitToken
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
-
Methods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
configure, contextualize, getConfiguration, setupChild
-
-
-
-
Field Detail
-
message
private String message
Specify the message which is used to notify about violations, if empty then default (hard-coded) message is used.
-
minimum
private int minimum
Specify the minimum number of matches required in each file.
-
maximum
private int maximum
Specify the maximum number of matches required in each file.
-
ignoreCase
private boolean ignoreCase
Control whether to ignore case when searching.
-
ignoreComments
private boolean ignoreComments
Control whether to ignore text in comments when searching.
-
-
Constructor Detail
-
RegexpSinglelineJavaCheck
public RegexpSinglelineJavaCheck()
-
-
Method Detail
-
getDefaultTokens
public int[] getDefaultTokens()
Description copied from class:AbstractCheck
Returns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.- Specified by:
getDefaultTokens
in classAbstractCheck
- Returns:
- the default tokens
- See Also:
TokenTypes
-
getAcceptableTokens
public int[] getAcceptableTokens()
Description copied from class:AbstractCheck
The configurable token set. Used to protect Checks against malicious users who specify an unacceptable token set in the configuration file. The default implementation returns the check's default tokens.- Specified by:
getAcceptableTokens
in classAbstractCheck
- Returns:
- the token set this check is designed for.
- See Also:
TokenTypes
-
getRequiredTokens
public int[] getRequiredTokens()
Description copied from class:AbstractCheck
The tokens that this check must be registered for.- Specified by:
getRequiredTokens
in classAbstractCheck
- Returns:
- the token set this must be registered for.
- See Also:
TokenTypes
-
beginTree
public void beginTree(DetailAST rootAST)
Description copied from class:AbstractCheck
Called before the starting to process a tree. Ideal place to initialize information that is to be collected whilst processing a tree.- Overrides:
beginTree
in classAbstractCheck
- Parameters:
rootAST
- the root of the tree
-
setFormat
public void setFormat(String format)
Setter to specify the format of the regular expression to match.- Parameters:
format
- the format of the regular expression to match.- Since:
- 5.0
-
setMessage
public void setMessage(String message)
Setter to specify the message which is used to notify about violations, if empty then default (hard-coded) message is used.- Parameters:
message
- the message to report for a match.- Since:
- 6.0
-
setMinimum
public void setMinimum(int minimum)
Setter to specify the minimum number of matches required in each file.- Parameters:
minimum
- the minimum number of matches required in each file.- Since:
- 5.0
-
setMaximum
public void setMaximum(int maximum)
Setter to specify the maximum number of matches required in each file.- Parameters:
maximum
- the maximum number of matches required in each file.- Since:
- 5.0
-
setIgnoreCase
public void setIgnoreCase(boolean ignoreCase)
Setter to control whether to ignore case when searching.- Parameters:
ignoreCase
- whether to ignore case when searching.- Since:
- 5.0
-
setIgnoreComments
public void setIgnoreComments(boolean ignore)
Setter to control whether to ignore text in comments when searching.- Parameters:
ignore
- whether to ignore text in comments when searching.- Since:
- 5.0
-
-