com.puppycrawl.tools.checkstyle.checks.usage
Class AbstractUsageCheck

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.usage.AbstractUsageCheck
All Implemented Interfaces:
Configurable, Contextualizable
Direct Known Subclasses:
OneMethodPrivateFieldCheck, UnusedLocalVariableCheck, UnusedParameterCheck, UnusedPrivateFieldCheck, UnusedPrivateMethodCheck

public abstract class AbstractUsageCheck
extends Check

Performs a usage check for fields, methods, parameters, variables.

Author:
Rick Giles

Constructor Summary
AbstractUsageCheck()
          Constructs an AbstractUsageCheck.
 
Method Summary
 void applyTo(java.util.Set aNodes)
          Applies this check to a set of nodes.
 void beginTree(DetailAST aRootAST)
          Called before the starting to process a tree.
 void finishTree(DetailAST aAST)
          Called after finished processing a tree.
protected  com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.ASTManager getASTManager()
          Gets the manager for AST nodes.
abstract  java.lang.String getErrorKey()
          Returns the key for the Checkstyle error message.
 java.lang.String getIgnoreFormat()
           
 org.apache.regexp.RE getRegexp()
           
 void logError(java.lang.Exception aException)
          Logs an exception.
abstract  boolean mustCheckReferenceCount(DetailAST aAST)
          Determines whether the reference count of an aAST is required.
 void setIgnoreFormat(java.lang.String aFormat)
          Set the ignore format to the specified regular expression.
 void visitToken(DetailAST aAST)
          Called to process a token.
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
destroy, getAcceptableTokens, getClassLoader, getDefaultTokens, 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

AbstractUsageCheck

public AbstractUsageCheck()
Constructs an AbstractUsageCheck.

Method Detail

setIgnoreFormat

public void setIgnoreFormat(java.lang.String aFormat)
                     throws org.apache.commons.beanutils.ConversionException
Set the ignore format to the specified regular expression.

Parameters:
aFormat - a String value
Throws:
org.apache.commons.beanutils.ConversionException - unable to parse aFormat

getRegexp

public org.apache.regexp.RE getRegexp()
Returns:
the regexp to match against

getIgnoreFormat

public java.lang.String getIgnoreFormat()
Returns:
the regexp format

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

finishTree

public void finishTree(DetailAST aAST)
Description copied from class: Check
Called after finished processing a tree. Ideal place to report on information collected whilst processing a tree.

Overrides:
finishTree in class Check
Parameters:
aAST - the root of the tree
See Also:
Check

logError

public void logError(java.lang.Exception aException)
Logs an exception.

Parameters:
aException - the exception to log.

getErrorKey

public abstract java.lang.String getErrorKey()
Returns the key for the Checkstyle error message.

Returns:
the key for the Checkstyle error message.

mustCheckReferenceCount

public abstract boolean mustCheckReferenceCount(DetailAST aAST)
Determines whether the reference count of an aAST is required.

Parameters:
aAST - the node to check.
Returns:
true if the reference count of aAST is required.

applyTo

public void applyTo(java.util.Set aNodes)
Applies this check to a set of nodes.

Parameters:
aNodes - the nodes to check.

getASTManager

protected com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.ASTManager getASTManager()
Gets the manager for AST nodes.

Returns:
the AST manager.

Back to the Checkstyle Home Page