public class RegexpCheck extends AbstractCheck
A check that makes sure that a specified pattern exists (or not) in the file.
An example of how to configure the check to make sure a copyright statement is included in the file (but without requirements on where in the file it should be):
<module name="RegexpCheck">
<property name="format" value="This code is copyrighted"/>
</module>
And to make sure the same statement appears at the beginning of the file.
<module name="RegexpCheck">
<property name="format" value="\AThis code is copyrighted"/>
</module>
AutomaticBean.OutputStreamOptions| Modifier and Type | Field and Description |
|---|---|
static String |
MSG_DUPLICATE_REGEXP
A key is pointing to the warning message text in "messages.properties"
file.
|
static String |
MSG_ILLEGAL_REGEXP
A key is pointing to the warning message text in "messages.properties"
file.
|
static String |
MSG_REQUIRED_REGEXP
A key is pointing to the warning message text in "messages.properties"
file.
|
| Constructor and Description |
|---|
RegexpCheck() |
| 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 |
setDuplicateLimit(int duplicateLimit)
Sets the maximum number of instances of required pattern allowed.
|
void |
setErrorLimit(int errorLimit)
Sets the limit on the number of errors to report.
|
void |
setFormat(Pattern pattern)
Set the format to the specified regular expression.
|
void |
setIgnoreComments(boolean ignoreComments)
Sets if matches within comments should be ignored.
|
void |
setIllegalPattern(boolean illegalPattern)
Sets if pattern is illegal, otherwise pattern is required.
|
void |
setMessage(String message)
Setter for message property.
|
clearMessages, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setClassLoader, setFileContents, setTabWidth, setTokens, visitTokenfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfiguration, setupChildpublic static final String MSG_ILLEGAL_REGEXP
public static final String MSG_REQUIRED_REGEXP
public static final String MSG_DUPLICATE_REGEXP
public RegexpCheck()
public void setMessage(String message)
message - custom message which should be used in report.public void setIgnoreComments(boolean ignoreComments)
ignoreComments - True if comments should be ignored.public void setIllegalPattern(boolean illegalPattern)
illegalPattern - True if pattern is not allowed.public void setErrorLimit(int errorLimit)
errorLimit - the number of errors to report.public void setDuplicateLimit(int duplicateLimit)
duplicateLimit - negative values mean no duplicate checking,
any positive value is used as the limit.public final void setFormat(Pattern pattern)
pattern - the new patternorg.apache.commons.beanutils.ConversionException - unable to parse formatpublic 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 treeCopyright © 2001–2018. All rights reserved.