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

    java.lang.Object
      com.puppycrawl.tools.checkstyle.api.AutomaticBean
          com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
              com.puppycrawl.tools.checkstyle.api.Check
                  com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck
                      com.puppycrawl.tools.checkstyle.checks.GenericIllegalRegexpCheck
                          com.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, setIgnoreCase, setIgnoreComments, setMessage`

Methods inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck
`getFormat, getRegexp, setCompileFlags, 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
`getId, getMessageBundle, getSeverity, getSeverityLevel, 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`

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)

  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`
  Parameters:
    `aRootAST` - the root of the tree

### getAcceptableTokens

    public int[] getAcceptableTokens()

  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:
    `TokenTypes`

### visitToken

    public void visitToken(DetailAST aAST)

  Called to process a token.

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

Back to the Checkstyle Home Page