com.puppycrawl.tools.checkstyle.checks

Class CheckUtils

public final class CheckUtils extends Object

Contains utility methods for the checks.

Author: Oliver Burn Simon Harris o_sukhodolsky

Method Summary
static FullIdentcreateFullType(DetailAST aTypeAST)
Creates FullIdent for given type node.
static DetailASTgetFirstNode(DetailAST aNode)
Finds sub-node for given node minimal (line, column) pair.
static ListgetTypeParameterNames(DetailAST aNode)
Retrieves the names of the type parameters to the node.
static ListgetTypeParameters(DetailAST aNode)
Retrieves the type parameters to the node.
static booleanisElseIf(DetailAST aAST)
Returns whether a token represents an ELSE as part of an ELSE / IF set.
static booleanisEqualsMethod(DetailAST aAST)
Tests whether a method definition AST defines an equals covariant.
static doubleparseDouble(String aText, int aType)
Returns the value represented by the specified string of the specified type.
static doubleparseFloat(String aText, int aType)
Returns the value represented by the specified string of the specified type.
static intparseInt(String aText, int aRadix)
Parses the string argument as a signed integer in the radix specified by the second argument.
static longparseLong(String aText, int aRadix)
Parses the string argument as a signed long in the radix specified by the second argument.

Method Detail

createFullType

public static FullIdent createFullType(DetailAST aTypeAST)
Creates FullIdent for given type node.

Parameters: aTypeAST a type node.

Returns: FullIdent for given type.

getFirstNode

public static DetailAST getFirstNode(DetailAST aNode)
Finds sub-node for given node minimal (line, column) pair.

Parameters: aNode the root of tree for search.

Returns: sub-node with minimal (line, column) pair.

getTypeParameterNames

public static List getTypeParameterNames(DetailAST aNode)
Retrieves the names of the type parameters to the node.

Parameters: aNode the parameterised AST node

Returns: a list of type parameter names

getTypeParameters

public static List getTypeParameters(DetailAST aNode)
Retrieves the type parameters to the node.

Parameters: aNode the parameterised AST node

Returns: a list of type parameter names

isElseIf

public static boolean isElseIf(DetailAST aAST)
Returns whether a token represents an ELSE as part of an ELSE / IF set.

Parameters: aAST the token to check

Returns: whether it is

isEqualsMethod

public static boolean isEqualsMethod(DetailAST aAST)
Tests whether a method definition AST defines an equals covariant.

Parameters: aAST the method definition AST to test. Precondition: aAST is a TokenTypes.METHOD_DEF node.

Returns: true if aAST defines an equals covariant.

parseDouble

public static double parseDouble(String aText, int aType)
Returns the value represented by the specified string of the specified type. Returns 0 for types other than float, double, int, and long.

Parameters: aText the string to be parsed. aType the token type of the text. Should be a constant of {@link com.puppycrawl.tools.checkstyle.api.TokenTypes}.

Returns: the double value represented by the string argument.

parseFloat

public static double parseFloat(String aText, int aType)
Returns the value represented by the specified string of the specified type. Returns 0 for types other than float, double, int, and long.

Parameters: aText the string to be parsed. aType the token type of the text. Should be a constant of {@link com.puppycrawl.tools.checkstyle.api.TokenTypes}.

Returns: the float value represented by the string argument.

parseInt

public static int parseInt(String aText, int aRadix)
Parses the string argument as a signed integer in the radix specified by the second argument. The characters in the string must all be digits of the specified radix. Handles negative values, which method java.lang.Integer.parseInt(String, int) does not.

Parameters: aText the String containing the integer representation to be parsed. Precondition: aText contains a parsable int. aRadix the radix to be used while parsing aText.

Returns: the integer represented by the string argument in the specified radix.

parseLong

public static long parseLong(String aText, int aRadix)
Parses the string argument as a signed long in the radix specified by the second argument. The characters in the string must all be digits of the specified radix. Handles negative values, which method java.lang.Integer.parseInt(String, int) does not.

Parameters: aText the String containing the integer representation to be parsed. Precondition: aText contains a parsable int. aRadix the radix to be used while parsing aText.

Returns: the long represented by the string argument in the specified radix.