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

Quick Search    Search Deep

com.puppycrawl.tools.checkstyle.checks.design
Class MutableExceptionCheck  view MutableExceptionCheck download MutableExceptionCheck.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
              extended bycom.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck
                  extended bycom.puppycrawl.tools.checkstyle.checks.design.MutableExceptionCheck
All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable

public final class MutableExceptionCheck
extends com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck

Ensures that exceptions (defined as any class name conforming to some regular expression) are immutable. That is, have only final fields.

Rationale: Exception instances should represent an error condition. Having non final fields not only allows the state to be modified by accident and therefore mask the original condition but also allows developers to accidentally forget to initialise state thereby leading to code catching the exception to draw incorrect conclusions based on the state.


Field Summary
private static java.lang.String DEFAULT_FORMAT
          Default value for format property.
private  boolean mChecking
          Should we check current class or not.
private  java.util.Stack mCheckingStack
          Stack of checking information for classes.
 
Fields inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.Check
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
 
Constructor Summary
MutableExceptionCheck()
          Creates new instance of the check.
 
Method Summary
 int[] getDefaultTokens()
          Returns the default token a check is interested in.
 int[] getRequiredTokens()
          The tokens that this check must be registered for.
private  boolean isExceptionClass(java.lang.String aClassName)
           
private  void leaveClassDef()
          Called when we leave class definition.
 void leaveToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Called after all the child nodes have been process.
private  void visitClassDef(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Called when we start processing class definition.
 void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Called to process a token.
private  void visitVariableDef(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Checks variable definition.
 
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck
getFormat, getRegexp, setFormat
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLines, getTabWidth, getTokenNames, init, 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, 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_FORMAT

private static final java.lang.String DEFAULT_FORMAT
Default value for format property.

See Also:
Constant Field Values

mCheckingStack

private final java.util.Stack mCheckingStack
Stack of checking information for classes.


mChecking

private boolean mChecking
Should we check current class or not.

Constructor Detail

MutableExceptionCheck

public MutableExceptionCheck()
Creates new instance of the check.

Method Detail

getDefaultTokens

public int[] getDefaultTokens()
Description copied from class: com.puppycrawl.tools.checkstyle.api.Check
Returns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.


getRequiredTokens

public int[] getRequiredTokens()
Description copied from class: com.puppycrawl.tools.checkstyle.api.Check
The tokens that this check must be registered for.


visitToken

public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Description copied from class: com.puppycrawl.tools.checkstyle.api.Check
Called to process a token.


leaveToken

public void leaveToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Description copied from class: com.puppycrawl.tools.checkstyle.api.Check
Called after all the child nodes have been process.


visitClassDef

private void visitClassDef(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Called when we start processing class definition.


leaveClassDef

private void leaveClassDef()
Called when we leave class definition.


visitVariableDef

private void visitVariableDef(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Checks variable definition.


isExceptionClass

private boolean isExceptionClass(java.lang.String aClassName)