Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.puppycrawl.tools.checkstyle.api
Class Check  view Check download Check.java

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

public abstract class Check
extends AbstractViolationReporter

The base class for checks.

Version:
1.0

Field Summary
private static int DEFAULT_TAB_WIDTH
          default tab width for column reporting
private  FileContents mFileContents
          the current file contents
private  java.lang.ClassLoader mLoader
          current class loader
private  LocalizedMessages mMessages
          the object for collecting messages.
private  int mTabWidth
          the tab width for column reporting
private  java.util.Set mTokens
          the tokens the check is interested in
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
 
Constructor Summary
Check()
           
 
Method Summary
 void beginTree(DetailAST aRootAST)
          Called before the starting to process a tree.
 void destroy()
          Destroy the check.
 void finishTree(DetailAST aRootAST)
          Called after finished processing a tree.
 int[] getAcceptableTokens()
          The configurable token set.
 java.lang.ClassLoader getClassLoader()
          Returns the class loader associated with the tree.
abstract  int[] getDefaultTokens()
          Returns the default token a check is interested in.
 FileContents getFileContents()
          Returns the file contents associated with the tree.
 java.lang.String[] getLines()
          Returns the lines associated with the tree.
 int[] getRequiredTokens()
          The tokens that this check must be registered for.
protected  int getTabWidth()
           
 java.util.Set getTokenNames()
          Returns the tokens registered for the check.
 void init()
          Initialse the check.
 void leaveToken(DetailAST aAST)
          Called after all the child nodes have been process.
protected  void log(int aLineNo, int aColNo, java.lang.String aKey, java.lang.Object[] aArgs)
          Helper method to log a LocalizedMessage.
protected  void log(int aLine, java.lang.String aKey, java.lang.Object[] aArgs)
          Log an error message.
 void setClassLoader(java.lang.ClassLoader aLoader)
          Set the class loader associated with the tree.
 void setFileContents(FileContents aContents)
          Set the file contents associated with the tree.
 void setMessages(LocalizedMessages aMessages)
          Set the global object used to collect messages.
 void setTabWidth(int aTabWidth)
          Set the tab width to report errors with.
 void setTokens(java.lang.String[] aStrRep)
          Adds a set of tokens the check is interested in.
 void visitToken(DetailAST aAST)
          Called to process a token.
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getMessageBundle, getMessageBundle, getSeverity, getSeverityLevel, 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
 

Field Detail

DEFAULT_TAB_WIDTH

private static final int DEFAULT_TAB_WIDTH
default tab width for column reporting

See Also:
Constant Field Values

mFileContents

private FileContents mFileContents
the current file contents


mTokens

private final java.util.Set mTokens
the tokens the check is interested in


mMessages

private LocalizedMessages mMessages
the object for collecting messages.


mTabWidth

private int mTabWidth
the tab width for column reporting


mLoader

private java.lang.ClassLoader mLoader
current class loader

Constructor Detail

Check

public Check()
Method Detail

getDefaultTokens

public abstract int[] getDefaultTokens()
Returns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.


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.


getRequiredTokens

public int[] getRequiredTokens()
The tokens that this check must be registered for.


setTokens

public final void setTokens(java.lang.String[] aStrRep)
Adds a set of tokens the check is interested in.


getTokenNames

public final java.util.Set getTokenNames()
Returns the tokens registered for the check.


setMessages

public final void setMessages(LocalizedMessages aMessages)
Set the global object used to collect messages.


init

public void init()
Initialse the check. This is the time to verify that the check has everything required to perform it job.


destroy

public void destroy()
Destroy the check. It is being retired from service.


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.


finishTree

public void finishTree(DetailAST aRootAST)
Called after finished processing a tree. Ideal place to report on information collected whilst processing a tree.


visitToken

public void visitToken(DetailAST aAST)
Called to process a token.


leaveToken

public void leaveToken(DetailAST aAST)
Called after all the child nodes have been process.


getLines

public final java.lang.String[] getLines()
Returns the lines associated with the tree.


setFileContents

public final void setFileContents(FileContents aContents)
Set the file contents associated with the tree.


getFileContents

public final FileContents getFileContents()
Returns the file contents associated with the tree.


setClassLoader

public final void setClassLoader(java.lang.ClassLoader aLoader)
Set the class loader associated with the tree.


getClassLoader

public final java.lang.ClassLoader getClassLoader()
Returns the class loader associated with the tree.


getTabWidth

protected final int getTabWidth()

setTabWidth

public final void setTabWidth(int aTabWidth)
Set the tab width to report errors with.


log

protected final void log(int aLine,
                         java.lang.String aKey,
                         java.lang.Object[] aArgs)
Log an error message.

Specified by:
log in class AbstractViolationReporter

log

protected final void log(int aLineNo,
                         int aColNo,
                         java.lang.String aKey,
                         java.lang.Object[] aArgs)
Helper method to log a LocalizedMessage.

Specified by:
log in class AbstractViolationReporter