Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.puppycrawl.tools.checkstyle.checks
Class AbstractTypeAwareCheck

    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.AbstractTypeAwareCheck

All Implemented Interfaces:
  Configurable, Contextualizable

Direct Known Subclasses:
  JavadocMethodCheck, RedundantThrowsCheck

public abstract class AbstractTypeAwareCheck
extends Check

Abstract class that endeavours to maintain type information for the Java file being checked. It provides helper methods for performing type information functions.

Version:
  1.0
Author:
  Oliver Burn

Nested Class Summary
`protected class` | `AbstractTypeAwareCheck.ClassInfo` Contains class's `FullIdent` and `Class` object if we can load it.

Constructor Summary
`AbstractTypeAwareCheck()`

Method Summary
`void` | `beginTree(DetailAST aRootAST)` Called before the starting to process a tree.
`protected boolean` | `isSameType(java.lang.String aFirst, java.lang.String aSecond)` Return if two Strings represent the same type, inspecting the import statements if necessary
`protected boolean` | `isShortName(java.lang.String aShortName, java.lang.String aFullName)` Calculate if one type name is a shortname for another type name.
`protected boolean` | `isSubclass(java.lang.Class aChild, java.lang.Class aParent)` Checks if one class is subclass of another
`protected boolean` | `isUnchecked(java.lang.Class aException)` Is exception is unchecked (subclass of `RuntimeException` or `Error`
`protected abstract void` | `logLoadError(FullIdent aIdent)` Logs error if unable to load class information.
`protected abstract void` | `processAST(DetailAST aAST)` Called to process an AST when visiting it.
`protected java.lang.Class` | `resolveClass(java.lang.String aClassName)` Attempts to resolve the Class for a specified name.
`protected java.lang.Class` | `tryLoadClass(FullIdent aIdent)` Tries to load class.
`void` | `visitToken(DetailAST aAST)` Called to process a token.

Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
`destroy, finishTree, 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

### AbstractTypeAwareCheck

    public AbstractTypeAwareCheck()

Method Detail

### processAST

    protected abstract void processAST(DetailAST aAST)

  Called to process an AST when visiting it.

  Parameters:
    `aAST` - the AST to process. Guaranteed to not be PACKAGE_DEF or IMPORT tokens.

### 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 final 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`

### isShortName

    protected boolean isShortName(java.lang.String aShortName,
                                  java.lang.String aFullName)

  Calculate if one type name is a shortname for another type name.

  Parameters:
    `aShortName` - a shorthand, such as `IOException`
    `aFullName` - a full name, such as `java.io.IOException`
  Returns:
    true iff aShortName represents the same type as aFullName

### isUnchecked

    protected boolean isUnchecked(java.lang.Class aException)

  Is exception is unchecked (subclass of `RuntimeException` or `Error`

  Parameters:
    `aException` - `Class` of exception to check
  Returns:
    true if exception is unchecked false if exception is checked

### isSubclass

    protected boolean isSubclass(java.lang.Class aChild,
                                 java.lang.Class aParent)

  Checks if one class is subclass of another

  Parameters:
    `aChild` - `Class` of class which should be child
    `aParent` - `Class` of class which should be parent
  Returns:
    true if aChild is subclass of aParent false otherwise

### isSameType

    protected boolean isSameType(java.lang.String aFirst,
                                 java.lang.String aSecond)

  Return if two Strings represent the same type, inspecting the import statements if necessary

  Parameters:
    `aFirst` - first type declared in throws clause
    `aSecond` - second type declared in thros tag
  Returns:
    true iff type names represent the same type

### resolveClass

    protected final java.lang.Class resolveClass(java.lang.String aClassName)

  Attempts to resolve the Class for a specified name.

  Parameters:
    `aClassName` - name of the class to resolve
  Returns:
    the resolved class or `null` if unable to resolve the class.

### tryLoadClass

    protected final java.lang.Class tryLoadClass(FullIdent aIdent)

  Tries to load class. Logs error if unable.

  Parameters:
    `aIdent` - name of class which we try to load.
  Returns:
    `Class` for a ident.

### logLoadError

    protected abstract void logLoadError(FullIdent aIdent)

  Logs error if unable to load class information. Abstract, should be overrided in subclasses.

  Parameters:
    `aIdent` - class name for which we can no load class.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Back to the Checkstyle Home Page
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD