org.incava.java
Class SimpleNodeUtil

java.lang.Object
  extended by org.incava.java.SimpleNodeUtil
Direct Known Subclasses:
ClassUtil, FieldUtil, FunctionUtil, ItemUtil, ParameterUtil, ThrowsUtil, TypeDeclarationUtil, VariableUtil

public class SimpleNodeUtil
extends java.lang.Object

Miscellaneous routines for the SimpleNode.


Constructor Summary
SimpleNodeUtil()
           
 
Method Summary
static void dump(SimpleNode node, java.lang.String prefix)
           
static void dump(SimpleNode node, java.lang.String prefix, boolean showWhitespace)
           
static SimpleNode findChild(SimpleNode parent, java.lang.Class childType)
           
static SimpleNode findChild(SimpleNode parent, java.lang.Class childType, int index)
           
static SimpleNode[] findChildren(SimpleNode parent)
          Returns all children of the node.
static SimpleNode[] findChildren(SimpleNode parent, java.lang.Class childType)
           
static Token findToken(SimpleNode node, int tokenType)
           
static java.util.List getChildren(SimpleNode node)
          Returns a list of children, both nodes and tokens.
static java.util.List getChildren(SimpleNode node, boolean getNodes, boolean getTokens)
          Returns a list of children, optionally nodes and tokens.
static java.util.List getChildrenSerially(SimpleNode node)
          Returns a list of child tokens, non-hierarchically.
static java.util.List getChildrenSerially(SimpleNode node, java.util.List list)
          Returns a list of child tokens, non-hierarchically.
static Token getLeadingToken(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 java.util.List getLeadingTokens(SimpleNode node)
          Returns the tokens preceding the first child of the node.
static int getLevel(SimpleNode node)
          Returns a numeric "level" for the node.
protected static java.lang.String getLocation(Token t1, Token t2)
           
static SimpleNode getParent(SimpleNode node)
          Returns the parent node.
static java.util.List getTokens(SimpleNode node)
          Returns the tokens for a node.
static boolean hasChildren(SimpleNode node)
          Returns whether the node has any children.
static boolean hasLeadingToken(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(SimpleNode node)
           
static void print(SimpleNode node, java.lang.String prefix)
           
static java.lang.String toString(SimpleNode node)
          Returns the token images for the node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleNodeUtil

public SimpleNodeUtil()
Method Detail

toString

public static java.lang.String toString(SimpleNode node)
Returns the token images for the node.


hasChildren

public static boolean hasChildren(SimpleNode node)
Returns whether the node has any children.


getParent

public static SimpleNode getParent(SimpleNode node)
Returns the parent node.


getChildren

public static java.util.List getChildren(SimpleNode node)
Returns a list of children, both nodes and tokens.


getChildren

public static java.util.List getChildren(SimpleNode node,
                                         boolean getNodes,
                                         boolean getTokens)
Returns a list of children, optionally nodes and tokens.


findChild

public static SimpleNode findChild(SimpleNode parent,
                                   java.lang.Class childType)

findChild

public static SimpleNode findChild(SimpleNode parent,
                                   java.lang.Class childType,
                                   int index)

getChildrenSerially

public static java.util.List getChildrenSerially(SimpleNode node)
Returns a list of child tokens, non-hierarchically.


getChildrenSerially

public static java.util.List getChildrenSerially(SimpleNode node,
                                                 java.util.List list)
Returns a list of child tokens, non-hierarchically.


findChildren

public static SimpleNode[] findChildren(SimpleNode parent,
                                        java.lang.Class childType)

findChildren

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


getTokens

public static java.util.List getTokens(SimpleNode node)
Returns the tokens for a node.


findToken

public static Token findToken(SimpleNode node,
                              int tokenType)

hasLeadingToken

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


getLeadingToken

public static Token getLeadingToken(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 java.util.List getLeadingTokens(SimpleNode node)
Returns the tokens preceding the first child of the node.


print

public static void print(SimpleNode node)

print

public static void print(SimpleNode node,
                         java.lang.String prefix)

dump

public static void dump(SimpleNode node,
                        java.lang.String prefix)

dump

public static void dump(SimpleNode node,
                        java.lang.String prefix,
                        boolean showWhitespace)

getLocation

protected static java.lang.String getLocation(Token t1,
                                              Token t2)

getLevel

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