net.sourceforge.pmd.rules.sunsecure

Class AbstractSunSecureRule

public abstract class AbstractSunSecureRule extends AbstractRule

Utility methods for the package

Author: mgriffa

Method Summary
protected StringgetFirstNameImage(SimpleNode n)
Gets the image of the first ASTName node found by {@link SimpleNode#getFirstChildOfType(Class)}
protected StringgetReturnedVariableName(ASTReturnStatement ret)
Gets the name of the variable returned.
protected booleanisField(String varName, ASTTypeDeclaration typeDeclaration)
Tells if the type declaration has a field with varName.
protected booleanisLocalVariable(String vn, ASTMethodDeclaration node)
TODO modify usages to use symbol table Tells if the variable name is a local variable declared in the method.

Method Detail

getFirstNameImage

protected String getFirstNameImage(SimpleNode n)
Gets the image of the first ASTName node found by {@link SimpleNode#getFirstChildOfType(Class)}

Parameters: n the node to search

Returns: the image of the first ASTName or null

getReturnedVariableName

protected final String getReturnedVariableName(ASTReturnStatement ret)
Gets the name of the variable returned. Some examples:
for this.foo returns foo
for foo returns foo
for foo.bar returns foo.bar

Parameters: ret a return statement to evaluate

Returns: the name of the variable associated or null if it cannot be detected

isField

protected final boolean isField(String varName, ASTTypeDeclaration typeDeclaration)
Tells if the type declaration has a field with varName.

Parameters: varName the name of the field to search typeDeclaration the type declaration

Returns: true if there is a field in the type declaration named varName, false in other case

isLocalVariable

protected boolean isLocalVariable(String vn, ASTMethodDeclaration node)
TODO modify usages to use symbol table Tells if the variable name is a local variable declared in the method.

Parameters: vn the variable name node the ASTMethodDeclaration where the local variable name will be searched

Returns: true if the method declaration contains any local variable named vn and false in other case