net.sourceforge.pmd.ast

Class SimpleNode

public abstract class SimpleNode extends Object implements Node

Field Summary
protected intbeginColumn
protected intbeginLine
protected Node[]children
protected intendColumn
protected intendLine
protected intid
protected Nodeparent
protected JavaParserparser
Constructor Summary
SimpleNode(int i)
SimpleNode(JavaParser p, int i)
Method Summary
protected voidappendElement(Node parentNode)
DocumentasXml()
booleancontainsChildOfType(Class type)
Finds if this node contains a child of the given type.
voiddiscardIfNecessary()
voiddump(String prefix)
protected voiddumpChildren(String prefix)
ListfindChildNodesWithXPath(String xpathString)
ListfindChildrenOfType(Class targetType)
voidfindChildrenOfType(Class targetType, List results)
voidfindChildrenOfType(Class targetType, List results, boolean descendIntoNestedClasses)
intgetBeginColumn()
intgetBeginLine()
IDataFlowNodegetDataFlowNode()
intgetEndColumn()
intgetEndLine()
NodegetFirstChildOfType(Class childType)
Traverses down the tree to find the first child instance of type childType
NodegetFirstParentOfType(Class parentType)
Traverses up the tree to find the first parent instance of type parentType
StringgetImage()
NodegetNthParent(int n)
ListgetParentsOfType(Class parentType)
Traverses up the tree to find all of the parent instances of type parentType
ScopegetScope()
voidjjtAddChild(Node n, int i)
NodejjtGetChild(int i)
intjjtGetNumChildren()
NodejjtGetParent()
voidjjtReplaceChild(Node old, Node newNode)
voidjjtSetParent(Node n)
voidsetDataFlowNode(IDataFlowNode dataFlowNode)
voidsetDiscardable()
voidsetImage(String image)
voidsetScope(Scope scope)
voidsetUnDiscardable()
voidtestingOnly__setBeginColumn(int i)
voidtestingOnly__setBeginLine(int i)
StringtoString(String prefix)

Field Detail

beginColumn

protected int beginColumn

beginLine

protected int beginLine

children

protected Node[] children

endColumn

protected int endColumn

endLine

protected int endLine

id

protected int id

parent

protected Node parent

parser

protected JavaParser parser

Constructor Detail

SimpleNode

public SimpleNode(int i)

SimpleNode

public SimpleNode(JavaParser p, int i)

Method Detail

appendElement

protected void appendElement(Node parentNode)

asXml

public Document asXml()

containsChildOfType

public final boolean containsChildOfType(Class type)
Finds if this node contains a child of the given type. This is an utility method that uses findChildrenOfType

Parameters: type the node type to search

Returns: true if there is at lease on child of the given type and false in any other case

discardIfNecessary

public void discardIfNecessary()

dump

public void dump(String prefix)

dumpChildren

protected void dumpChildren(String prefix)

findChildNodesWithXPath

public List findChildNodesWithXPath(String xpathString)

findChildrenOfType

public List findChildrenOfType(Class targetType)

findChildrenOfType

public void findChildrenOfType(Class targetType, List results)

findChildrenOfType

public void findChildrenOfType(Class targetType, List results, boolean descendIntoNestedClasses)

getBeginColumn

public int getBeginColumn()

getBeginLine

public int getBeginLine()

getDataFlowNode

public IDataFlowNode getDataFlowNode()

getEndColumn

public int getEndColumn()

getEndLine

public int getEndLine()

getFirstChildOfType

public Node getFirstChildOfType(Class childType)
Traverses down the tree to find the first child instance of type childType

Parameters: childType class which you want to find.

Returns: Node of type childType. Returns null if none found.

getFirstParentOfType

public Node getFirstParentOfType(Class parentType)
Traverses up the tree to find the first parent instance of type parentType

Parameters: parentType class which you want to find.

Returns: Node of type parentType. Returns null if none found.

getImage

public String getImage()

getNthParent

public Node getNthParent(int n)

getParentsOfType

public List getParentsOfType(Class parentType)
Traverses up the tree to find all of the parent instances of type parentType

Parameters: parentType classes which you want to find.

Returns: List of parentType instances found.

getScope

public Scope getScope()

jjtAddChild

public void jjtAddChild(Node n, int i)

jjtGetChild

public Node jjtGetChild(int i)

jjtGetNumChildren

public int jjtGetNumChildren()

jjtGetParent

public Node jjtGetParent()

jjtReplaceChild

public void jjtReplaceChild(Node old, Node newNode)

jjtSetParent

public void jjtSetParent(Node n)

setDataFlowNode

public void setDataFlowNode(IDataFlowNode dataFlowNode)

setDiscardable

public void setDiscardable()

setImage

public void setImage(String image)

setScope

public void setScope(Scope scope)

setUnDiscardable

public void setUnDiscardable()

testingOnly__setBeginColumn

public void testingOnly__setBeginColumn(int i)

testingOnly__setBeginLine

public void testingOnly__setBeginLine(int i)

toString

public String toString(String prefix)