Class AbstractNameCheck
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
-
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
-
- com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck
-
- All Implemented Interfaces:
Configurable
,Contextualizable
- Direct Known Subclasses:
AbstractAccessControlNameCheck
,AbstractTypeParameterNameCheck
,CatchParameterNameCheck
,ClassTypeParameterNameCheck
,InterfaceTypeParameterNameCheck
,LocalFinalVariableNameCheck
,LocalVariableNameCheck
,MethodTypeParameterNameCheck
,ParameterNameCheck
public abstract class AbstractNameCheck extends AbstractCheck
Abstract class for checking that names conform to a specified format.- Author:
- Rick Giles
-
-
Field Summary
Fields Modifier and Type Field Description static String
MSG_INVALID_PATTERN
Message key for invalid pattern error.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNameCheck(String format)
Creates a newAbstractNameCheck
instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract boolean
mustCheckName(DetailAST ast)
Decides whether the name of an AST should be checked against the format regexp.void
setFormat(Pattern pattern)
Set the format for the specified regular expression.void
visitToken(DetailAST ast)
Called to process a token.-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getDefaultTokens, getFileContents, getLine, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
-
-
-
-
Field Detail
-
MSG_INVALID_PATTERN
public static final String MSG_INVALID_PATTERN
Message key for invalid pattern error.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractNameCheck
protected AbstractNameCheck(String format)
Creates a newAbstractNameCheck
instance.- Parameters:
format
- format to check with
-
-
Method Detail
-
mustCheckName
protected abstract boolean mustCheckName(DetailAST ast)
Decides whether the name of an AST should be checked against the format regexp.- Parameters:
ast
- the AST to check.- Returns:
- true if the IDENT subnode of ast should be checked against the format regexp.
-
setFormat
public final void setFormat(Pattern pattern)
Set the format for the specified regular expression.- Parameters:
pattern
- the new pattern
-
visitToken
public void visitToken(DetailAST ast)
Description copied from class:AbstractCheck
Called to process a token.- Overrides:
visitToken
in classAbstractCheck
- Parameters:
ast
- the token to process
-
-