com.puppycrawl.tools.checkstyle.checks.naming

Class MemberNameCheck

Implemented Interfaces:
Configurable, Contextualizable

public class MemberNameCheck
extends AbstractNameCheck

Checks that instance variable names conform to a format specified by the format property. The format is a regular expression and defaults to ^[a-z][a-zA-Z0-9]*$.

An example of how to configure the check is:

 <module name="MemberName"/>
 

An example of how to configure the check for names that begin with "m", followed by an upper case letter, and then letters and digits is:

 <module name="MemberName">
    <property name="format" value="^m[A-Z][a-zA-Z0-9]*$"/>
 </module>
 
Version:
1.0
Author:
Rick Giles

Constructor Summary

MemberNameCheck()
Creates a new MemberNameCheck instance.

Method Summary

boolean
getApplyToPackage()
boolean
getApplyToPrivate()
boolean
getApplyToProtected()
boolean
getApplyToPublic()
int[]
getDefaultTokens()
protected boolean
mustCheckName(DetailAST aAST)
void
setApplyToPackage(boolean aApplyTo)
Sets whether we should apply the check to package-private members.
void
setApplyToPrivate(boolean aApplyTo)
Sets whether we should apply the check to private members.
void
setApplyToProtected(boolean aApplyTo)
Sets whether we should apply the check to protected members.
void
setApplyToPublic(boolean aApplyTo)
Sets whether we should apply the check to public members.

Methods inherited from class com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck

mustCheckName, visitToken

Methods inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck

getFormat, getRegexp, setCompileFlags, setFormat

Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check

beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getDefaultTokens, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens, visitToken

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter

getId, getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, log, log, log, setId, setSeverity

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean

configure, contextualize, finishLocalSetup, getConfiguration, setupChild

Constructor Details

MemberNameCheck

public MemberNameCheck()
Creates a new MemberNameCheck instance.

Method Details

getApplyToPackage

public boolean getApplyToPackage()
Returns:
true if the check should be applied to package-private members.

getApplyToPrivate

public boolean getApplyToPrivate()
Returns:
true if the check should be applied to private members.

getApplyToProtected

public boolean getApplyToProtected()
Returns:
true if the check should be applied to protected members.

getApplyToPublic

public boolean getApplyToPublic()
Returns:
true if the check should be applied to public members.

getDefaultTokens

public int[] getDefaultTokens()
Overrides:
getDefaultTokens in interface Check

mustCheckName

protected final boolean mustCheckName(DetailAST aAST)
Overrides:
mustCheckName in interface AbstractNameCheck

setApplyToPackage

public void setApplyToPackage(boolean aApplyTo)
Sets whether we should apply the check to package-private members.
Parameters:
aApplyTo - new value of the property.

setApplyToPrivate

public void setApplyToPrivate(boolean aApplyTo)
Sets whether we should apply the check to private members.
Parameters:
aApplyTo - new value of the property.

setApplyToProtected

public void setApplyToProtected(boolean aApplyTo)
Sets whether we should apply the check to protected members.
Parameters:
aApplyTo - new value of the property.

setApplyToPublic

public void setApplyToPublic(boolean aApplyTo)
Sets whether we should apply the check to public members.
Parameters:
aApplyTo - new value of the property.