com.puppycrawl.tools.checkstyle.checks.coding
Class IllegalTokenTextCheck

java.lang.Object
  extended bycom.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended bycom.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended bycom.puppycrawl.tools.checkstyle.api.Check
              extended bycom.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck
                  extended bycom.puppycrawl.tools.checkstyle.checks.GenericIllegalRegexpCheck
                      extended bycom.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenTextCheck
All Implemented Interfaces:
Configurable, Contextualizable

public class IllegalTokenTextCheck
extends GenericIllegalRegexpCheck

Checks for illegal token text.

An example of how to configure the check to forbid String literals containing "a href" is:

 <module name="IllegalTokenText">
     <property name="tokens" value="STRING_LITERAL"/>
     <property name="format" value="a href"/>
 </module>
 

An example of how to configure the check to forbid leading zeros in an integer literal, other than zero and a hex literal is:

 <module name="IllegalTokenText">
     <property name="tokens" value="NUM_INT,NUM_LONG"/>
     <property name="format" value="^0[^lx]"/>
     <property name="ignoreCase" value="true"/>
 </module>
 

Author:
Rick Giles

Constructor Summary
IllegalTokenTextCheck()
           
 
Method Summary
 void beginTree(DetailAST aRootAST)
          Called before the starting to process a tree.
 int[] getAcceptableTokens()
          The configurable token set.
 void visitToken(DetailAST aAST)
          Called to process a token.
 
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.GenericIllegalRegexpCheck
getDefaultTokens, getMessage, getRegexp, setIgnoreCase, setIgnoreComments, setMessage
 
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck
getFormat, setFormat
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
destroy, finishTree, getClassLoader, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, log, setSeverity
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IllegalTokenTextCheck

public IllegalTokenTextCheck()
Method Detail

beginTree

public void beginTree(DetailAST aRootAST)
Description copied from class: Check
Called before the starting to process a tree. Ideal place to initialise information that is to be collected whilst processing a tree.

Overrides:
beginTree in class GenericIllegalRegexpCheck
See Also:
Check

getAcceptableTokens

public int[] getAcceptableTokens()
Description copied from class: Check
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.

Overrides:
getAcceptableTokens in class Check
Returns:
the token set this check is designed for.
See Also:
Check

visitToken

public void visitToken(DetailAST aAST)
Description copied from class: Check
Called to process a token.

Overrides:
visitToken in class Check
Parameters:
aAST - the token to process
See Also:
Check

Back to the Checkstyle Home Page