org.incava.java

Class SimpleNodeUtil

Known Direct Subclasses:
ClassUtil, FieldUtil, FunctionUtil, ItemUtil, ParameterUtil, ThrowsUtil, TypeDeclarationUtil, VariableUtil

public class SimpleNodeUtil
extends java.lang.Object

Miscellaneous routines for the SimpleNode.

Method Summary

static void
dump(net.sourceforge.pmd.ast.SimpleNode node, String prefix)
static void
dump(net.sourceforge.pmd.ast.SimpleNode node, String prefix, boolean showWhitespace)
static net.sourceforge.pmd.ast.SimpleNode
findChild(net.sourceforge.pmd.ast.SimpleNode parent, Class childType)
static net.sourceforge.pmd.ast.SimpleNode
findChild(net.sourceforge.pmd.ast.SimpleNode parent, Class childType, int index)
static net.sourceforge.pmd.ast.SimpleNode[]
findChildren(net.sourceforge.pmd.ast.SimpleNode parent)
Returns all children of the node.
static net.sourceforge.pmd.ast.SimpleNode[]
findChildren(net.sourceforge.pmd.ast.SimpleNode parent, Class childType)
static net.sourceforge.pmd.ast.Token
findToken(net.sourceforge.pmd.ast.SimpleNode node, int tokenType)
static List
getChildren(net.sourceforge.pmd.ast.SimpleNode node)
Returns a list of children, both nodes and tokens.
static List
getChildren(net.sourceforge.pmd.ast.SimpleNode node, boolean getNodes, boolean getTokens)
Returns a list of children, optionally nodes and tokens.
static List
getChildrenSerially(net.sourceforge.pmd.ast.SimpleNode node)
Returns a list of child tokens, non-hierarchically.
static List
getChildrenSerially(net.sourceforge.pmd.ast.SimpleNode node, List list)
Returns a list of child tokens, non-hierarchically.
static net.sourceforge.pmd.ast.Token
getLeadingToken(net.sourceforge.pmd.ast.SimpleNode node, int tokenType)
Returns whether the node has a matching token, occurring prior to any non-tokens (i.e., before any child nodes).
static List
getLeadingTokens(net.sourceforge.pmd.ast.SimpleNode node)
Returns the tokens preceding the first child of the node.
static int
getLevel(net.sourceforge.pmd.ast.SimpleNode node)
Returns a numeric "level" for the node.
protected static String
getLocation(net.sourceforge.pmd.ast.Token t1, net.sourceforge.pmd.ast.Token t2)
static net.sourceforge.pmd.ast.SimpleNode
getParent(net.sourceforge.pmd.ast.SimpleNode node)
Returns the parent node.
static List
getTokens(net.sourceforge.pmd.ast.SimpleNode node)
Returns the tokens for a node.
static boolean
hasChildren(net.sourceforge.pmd.ast.SimpleNode node)
Returns whether the node has any children.
static boolean
hasLeadingToken(net.sourceforge.pmd.ast.SimpleNode node, int tokenType)
Returns whether the node has a matching token, occurring prior to any non-tokens (i.e., before any child nodes).
static void
print(net.sourceforge.pmd.ast.SimpleNode node)
static void
print(net.sourceforge.pmd.ast.SimpleNode node, String prefix)
static String
toString(net.sourceforge.pmd.ast.SimpleNode node)
Returns the token images for the node.

Method Details

dump

public static void dump(net.sourceforge.pmd.ast.SimpleNode node,
                        String prefix)

dump

public static void dump(net.sourceforge.pmd.ast.SimpleNode node,
                        String prefix,
                        boolean showWhitespace)

findChild

public static net.sourceforge.pmd.ast.SimpleNode findChild(net.sourceforge.pmd.ast.SimpleNode parent,
                                                           Class childType)

findChild

public static net.sourceforge.pmd.ast.SimpleNode findChild(net.sourceforge.pmd.ast.SimpleNode parent,
                                                           Class childType,
                                                           int index)

findChildren

public static net.sourceforge.pmd.ast.SimpleNode[] findChildren(net.sourceforge.pmd.ast.SimpleNode parent)
Returns all children of the node.

findChildren

public static net.sourceforge.pmd.ast.SimpleNode[] findChildren(net.sourceforge.pmd.ast.SimpleNode parent,
                                                                Class childType)

findToken

public static net.sourceforge.pmd.ast.Token findToken(net.sourceforge.pmd.ast.SimpleNode node,
                                                      int tokenType)

getChildren

public static List getChildren(net.sourceforge.pmd.ast.SimpleNode node)
Returns a list of children, both nodes and tokens.

getChildren

public static List getChildren(net.sourceforge.pmd.ast.SimpleNode node,
                               boolean getNodes,
                               boolean getTokens)
Returns a list of children, optionally nodes and tokens.

getChildrenSerially

public static List getChildrenSerially(net.sourceforge.pmd.ast.SimpleNode node)
Returns a list of child tokens, non-hierarchically.

getChildrenSerially

public static List getChildrenSerially(net.sourceforge.pmd.ast.SimpleNode node,
                                       List list)
Returns a list of child tokens, non-hierarchically.

getLeadingToken

public static net.sourceforge.pmd.ast.Token getLeadingToken(net.sourceforge.pmd.ast.SimpleNode node,
                                                            int tokenType)
Returns whether the node has a matching token, occurring prior to any non-tokens (i.e., before any child nodes).

getLeadingTokens

public static List getLeadingTokens(net.sourceforge.pmd.ast.SimpleNode node)
Returns the tokens preceding the first child of the node.

getLevel

public static int getLevel(net.sourceforge.pmd.ast.SimpleNode node)
Returns a numeric "level" for the node. Zero is public or abstract, one is protected, two is package, and three is private.

getLocation

protected static String getLocation(net.sourceforge.pmd.ast.Token t1,
                                    net.sourceforge.pmd.ast.Token t2)

getParent

public static net.sourceforge.pmd.ast.SimpleNode getParent(net.sourceforge.pmd.ast.SimpleNode node)
Returns the parent node.

getTokens

public static List getTokens(net.sourceforge.pmd.ast.SimpleNode node)
Returns the tokens for a node.

hasChildren

public static boolean hasChildren(net.sourceforge.pmd.ast.SimpleNode node)
Returns whether the node has any children.

hasLeadingToken

public static boolean hasLeadingToken(net.sourceforge.pmd.ast.SimpleNode node,
                                      int tokenType)
Returns whether the node has a matching token, occurring prior to any non-tokens (i.e., before any child nodes).

print

public static void print(net.sourceforge.pmd.ast.SimpleNode node)

print

public static void print(net.sourceforge.pmd.ast.SimpleNode node,
                         String prefix)

toString

public static String toString(net.sourceforge.pmd.ast.SimpleNode node)
Returns the token images for the node.