public class RegexpSinglelineJavaCheck extends AbstractCheck
A check for detecting single lines that match a supplied regular expression 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.
format - Specify the format of the regular expression to match.
Default value is "$.".
message - Specify the message which is used to notify about
violations, if empty then default (hard-coded) message is used.
Default value is null.
ignoreCase - Control whether to ignore case when searching.
Default value is false.
minimum - Specify the minimum number of matches required in each file.
Default value is 0.
maximum - Specify the maximum number of matches required in each file.
Default value is 0.
ignoreComments - Control whether to ignore text in comments when searching.
Default value is false.
To configure the check for calls to System.out.println, except in comments:
<module name="RegexpSinglelineJava">
<!-- . matches any character, so we need to
escape it and use \. to match dots. -->
<property name="format" value="System\.out\.println"/>
<property name="ignoreComments" value="true"/>
</module>
To configure the check to find case-insensitive occurrences of "debug":
<module name="RegexpSinglelineJava"> <property name="format" value="debug"/> <property name="ignoreCase" value="true"/> </module>
AutomaticBean.OutputStreamOptions| Constructor and Description |
|---|
RegexpSinglelineJavaCheck() |
| Modifier and Type | Method and 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(java.lang.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(java.lang.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.
|
clearMessages, destroy, finishTree, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokens, visitTokenfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfiguration, setupChildpublic RegexpSinglelineJavaCheck()
public int[] getDefaultTokens()
AbstractCheckgetDefaultTokens in class AbstractCheckTokenTypespublic int[] getAcceptableTokens()
AbstractCheckgetAcceptableTokens in class AbstractCheckTokenTypespublic int[] getRequiredTokens()
AbstractCheckgetRequiredTokens in class AbstractCheckTokenTypespublic void beginTree(DetailAST rootAST)
AbstractCheckbeginTree in class AbstractCheckrootAST - the root of the treepublic void setFormat(java.lang.String format)
format - the format of the regular expression to match.public void setMessage(java.lang.String message)
message - the message to report for a match.public void setMinimum(int minimum)
minimum - the minimum number of matches required in each file.public void setMaximum(int maximum)
maximum - the maximum number of matches required in each file.public void setIgnoreCase(boolean ignoreCase)
ignoreCase - whether to ignore case when searching.public void setIgnoreComments(boolean ignore)
ignore - whether to ignore text in comments when searching.Copyright © 2001-2019. All Rights Reserved.