com.puppycrawl.tools.checkstyle.checks.j2ee
Class Utils

java.lang.Object
  extended bycom.puppycrawl.tools.checkstyle.checks.j2ee.Utils

public class Utils
extends java.lang.Object

J2EE check utility methods.

Author:
Rick Giles

Constructor Summary
Utils()
           
 
Method Summary
static java.lang.String constructDottedName(DetailAST aAST)
          Builds the dotted name String representation of the object contained within an AST.
static boolean equalTypes(DetailAST aTypeAST1, DetailAST aTypeAST2)
          Tests whether two type AST nodes have the same type.
static boolean hasExtends(DetailAST aAST, java.lang.String aClassOrInterface)
          Determines whether an AST node declares an extension of a class or interface.
static boolean hasImplements(DetailAST aAST, java.lang.String aInterface)
          Determines whether an AST node declares an implementation of an interface.
static boolean hasPublicConstructor(DetailAST aAST, int aParameterCount)
          Determines whether an AST defines a class with a public constructor with a given number of parameters.
static boolean hasPublicMethod(DetailAST aAST, java.lang.String aName)
          Determines whether an AST node has a definition of a public method.
static boolean hasPublicMethod(DetailAST aAST, java.lang.String aName, boolean aIsVoid)
          Determines whether an AST node has a definition of a public method.
static boolean hasPublicMethod(DetailAST aAST, java.lang.String aName, boolean aIsVoid, int aParameterCount)
          Determines whether an AST node has a definition of a public method.
static boolean hasThrows(DetailAST aAST, java.lang.String aException)
          Determines whether an AST node declares a throw of an Exception.
static boolean implementsEntityBean(DetailAST aAST)
          Determines whether an AST node is in the definition of a class that implements javax.ejb.EntityBean.
static boolean implementsSessionBean(DetailAST aAST)
          Determines whether an AST node is in the definition of a class that implements javax.ejb.SessionBean.
static boolean isAbstract(DetailAST aAST)
          Determines whether an AST defines an abstract element.
static boolean isFinal(DetailAST aAST)
          Determines whether an AST defines a final element.
static boolean isInEJB(DetailAST aAST)
          Determines whether an AST node is in the definition of an EJB class.
static boolean isPublic(DetailAST aAST)
          Determines whether an AST defines a public element.
static boolean isPublicMethod(DetailAST aAST, java.lang.String aName)
          Determines whether an AST node defines a public method.
static boolean isPublicMethod(DetailAST aAST, java.lang.String aName, boolean aIsVoid)
          Determines whether an AST node defines a public method.
static boolean isPublicMethod(DetailAST aAST, java.lang.String aName, boolean aIsVoid, int aParameterCount)
          Determines whether an AST node defines a public method.
static boolean isStatic(DetailAST aAST)
          Determines whether an AST defines a static element.
static boolean isVoid(DetailAST aAST)
          Determines whether an AST defines a void method.
static boolean sameParameters(DetailAST aMethodAST1, DetailAST aMethodAST2)
          Tests whether two method definition ASTs have the same parameter lists according to type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

hasPublicMethod

public static boolean hasPublicMethod(DetailAST aAST,
                                      java.lang.String aName)
Determines whether an AST node has a definition of a public method.

Parameters:
aAST - the node to check. Normally aAST is a CLASS_DEF.
aName - the name of the method.
Returns:
true if aAST has a definition of a public method with name aName.

hasPublicMethod

public static boolean hasPublicMethod(DetailAST aAST,
                                      java.lang.String aName,
                                      boolean aIsVoid)
Determines whether an AST node has a definition of a public method.

Parameters:
aAST - the node to check. Normally aAST is a CLASS_DEF.
aName - the name of the method.
aIsVoid - designates whether the method is void.
Returns:
true if aAST has a definition of a public method with name aName and that is void according to aIsVoid.

hasPublicMethod

public static boolean hasPublicMethod(DetailAST aAST,
                                      java.lang.String aName,
                                      boolean aIsVoid,
                                      int aParameterCount)
Determines whether an AST node has a definition of a public method.

Parameters:
aAST - the node to check. Normally aAST is a CLASS_DEF.
aName - the name of the method.
aIsVoid - designates whether the method is void.
aParameterCount - the number of method parameters.
Returns:
true if aAST has a definition of a public method with name aName and that is void according to aIsVoid.

hasPublicConstructor

public static boolean hasPublicConstructor(DetailAST aAST,
                                           int aParameterCount)
Determines whether an AST defines a class with a public constructor with a given number of parameters.

Parameters:
aAST - the AST to check.
aParameterCount - the number of parameters
Returns:
true if aAST defines a class with a public constructor with aParameterCount parameters.

implementsEntityBean

public static boolean implementsEntityBean(DetailAST aAST)
Determines whether an AST node is in the definition of a class that implements javax.ejb.EntityBean.

Parameters:
aAST - the AST to check.
Returns:
true if aAST is in the definition of a class that implements javax.ejb.SessionBean.

implementsSessionBean

public static boolean implementsSessionBean(DetailAST aAST)
Determines whether an AST node is in the definition of a class that implements javax.ejb.SessionBean.

Parameters:
aAST - the AST to check.
Returns:
true if aAST is in the definition of a class that implements javax.ejb.SessionBean.

isInEJB

public static boolean isInEJB(DetailAST aAST)
Determines whether an AST node is in the definition of an EJB class.

Parameters:
aAST - the AST to check.
Returns:
true if aAST is in the definition of a an EJB class.

isAbstract

public static boolean isAbstract(DetailAST aAST)
Determines whether an AST defines an abstract element.

Parameters:
aAST - the AST to check.
Returns:
true if aAST defines an abstract element.

isFinal

public static boolean isFinal(DetailAST aAST)
Determines whether an AST defines a final element.

Parameters:
aAST - the AST to check.
Returns:
true if aAST defines a final element.

isPublic

public static boolean isPublic(DetailAST aAST)
Determines whether an AST defines a public element.

Parameters:
aAST - the AST to check.
Returns:
true if aAST defines a public element.

isStatic

public static boolean isStatic(DetailAST aAST)
Determines whether an AST defines a static element.

Parameters:
aAST - the AST to check.
Returns:
true if aAST defines a static element.

isVoid

public static boolean isVoid(DetailAST aAST)
Determines whether an AST defines a void method.

Parameters:
aAST - the AST to check.
Returns:
true if aAST defines a void method.

hasImplements

public static boolean hasImplements(DetailAST aAST,
                                    java.lang.String aInterface)
Determines whether an AST node declares an implementation of an interface.

Parameters:
aAST - the AST to check.
aInterface - the interface to check.
Returns:
if the class defined by aAST implements declares an implementation of aInterface.

hasExtends

public static boolean hasExtends(DetailAST aAST,
                                 java.lang.String aClassOrInterface)
Determines whether an AST node declares an extension of a class or interface.

Parameters:
aAST - the AST to check.
aClassOrInterface - the class or interface to check.
Returns:
if the class defined by aAST implements declares an extension of aClassOrInterface.

hasThrows

public static boolean hasThrows(DetailAST aAST,
                                java.lang.String aException)
Determines whether an AST node declares a throw of an Exception.

Parameters:
aAST - the AST to check.
aException - the name of the Exception to check.
Returns:
if the class defined by aAST implements declares a throw of aException.

isPublicMethod

public static boolean isPublicMethod(DetailAST aAST,
                                     java.lang.String aName,
                                     boolean aIsVoid,
                                     int aParameterCount)
Determines whether an AST node defines a public method.

Parameters:
aAST - the node to check. Normally aAST is a METHOD_DEF.
aName - the name of the method.
aIsVoid - designates whether the method is void.
aParameterCount - the number of method parameters.
Returns:
true if aAST is the definition of a public method with name aName and that is void according to aIsVoid.

isPublicMethod

public static boolean isPublicMethod(DetailAST aAST,
                                     java.lang.String aName,
                                     boolean aIsVoid)
Determines whether an AST node defines a public method.

Parameters:
aAST - the node to check. Normally aAST is a METHOD_DEF.
aName - the name of the method.
aIsVoid - designates whether the method is void.
Returns:
true if aAST is the definition of a public method with name aName and that is void according to aIsVoid.

isPublicMethod

public static boolean isPublicMethod(DetailAST aAST,
                                     java.lang.String aName)
Determines whether an AST node defines a public method.

Parameters:
aAST - the node to check. Normally aAST is a METHOD_DEF.
aName - the name of the method.
Returns:
true if aAST is the definition of a public method with name aName and that is void according to aIsVoid.

constructDottedName

public static java.lang.String constructDottedName(DetailAST aAST)
Builds the dotted name String representation of the object contained within an AST.

Parameters:
aAST - the AST containing the entire hierarcy of the object
Returns:
the dotted name String representation of the object contained within aAST.

sameParameters

public static boolean sameParameters(DetailAST aMethodAST1,
                                     DetailAST aMethodAST2)
Tests whether two method definition ASTs have the same parameter lists according to type.

Parameters:
aMethodAST1 - the first method AST to test.
aMethodAST2 - the second method AST to test.
Returns:
true if aMethodAST1 and aMethodAST2 have the same parameter lists.

equalTypes

public static boolean equalTypes(DetailAST aTypeAST1,
                                 DetailAST aTypeAST2)
Tests whether two type AST nodes have the same type.

Parameters:
aTypeAST1 - the first type AST to test.
aTypeAST2 - the second type AST to test.
Returns:
true if aTypeAST1 and aTypeAST2 have the same type.

Back to the Checkstyle Home Page