|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.pmd.lang.ast.AbstractNode
public abstract class AbstractNode
| Field Summary | |
|---|---|
protected int |
beginColumn
|
protected int |
beginLine
|
protected int |
childIndex
|
protected Node[] |
children
|
protected int |
endColumn
|
protected int |
endLine
|
protected GenericToken |
firstToken
|
protected int |
id
|
protected GenericToken |
lastToken
|
protected Node |
parent
|
| Constructor Summary | |
|---|---|
AbstractNode(int id)
|
|
AbstractNode(int id,
int theBeginLine,
int theEndLine,
int theBeginColumn,
int theEndColumn)
|
|
| Method Summary | ||
|---|---|---|
protected void |
appendElement(Node parentNode)
|
|
List |
findChildNodesWithXPath(String xpathString)
Returns all the nodes matching the xpath expression. |
|
|
findChildrenOfType(Class<T> targetType)
Traverses the children to find all the instances of type childType. |
|
|
findDescendantsOfType(Class<T> targetType)
Traverses down the tree to find all the descendant instances of type descendantType. |
|
|
findDescendantsOfType(Class<T> targetType,
List<T> results,
boolean crossBoundaries)
Traverses down the tree to find all the descendant instances of type descendantType. |
|
Document |
getAsDocument()
Get a DOM Document which contains Elements and Attributes representative of this Node and it's children. |
|
int |
getBeginColumn()
|
|
int |
getBeginLine()
|
|
DataFlowNode |
getDataFlowNode()
|
|
int |
getEndColumn()
|
|
int |
getEndLine()
|
|
|
getFirstChildOfType(Class<T> childType)
Traverses the children to find the first instance of type childType. |
|
|
getFirstDescendantOfType(Class<T> descendantType)
Traverses down the tree to find the first descendant instance of type descendantType. |
|
|
getFirstParentOfType(Class<T> parentType)
Traverses up the tree to find the first parent instance of type parentType |
|
String |
getImage()
|
|
Node |
getNthParent(int n)
Returns the n-th parent or null if there are not n ancestors |
|
|
getParentsOfType(Class<T> parentType)
Traverses up the tree to find all of the parent instances of type parentType |
|
Object |
getUserData()
Get the user data associated with this node. |
|
boolean |
hasDecendantOfAnyType(Class<?>... types)
|
|
boolean |
hasDescendantMatchingXPath(String xpathString)
Checks whether at least one descendant matches the xpath expression. |
|
|
hasDescendantOfType(Class<T> type)
Finds if this node contains a descendant of the given type. |
|
boolean |
hasImageEqualTo(String image)
|
|
boolean |
isFindBoundary()
|
|
boolean |
isSingleLine()
|
|
void |
jjtAddChild(Node child,
int index)
This method tells the node to add its argument to the node's list of children. |
|
void |
jjtClose()
This method is called after all the child nodes have been added. |
|
Node |
jjtGetChild(int index)
This method returns a child node. |
|
int |
jjtGetChildIndex()
|
|
GenericToken |
jjtGetFirstToken()
|
|
int |
jjtGetId()
|
|
GenericToken |
jjtGetLastToken()
|
|
int |
jjtGetNumChildren()
Return the number of children the node has. |
|
Node |
jjtGetParent()
|
|
void |
jjtOpen()
This method is called after the node has been made the current node. |
|
void |
jjtSetChildIndex(int index)
Sets the index of this node from the perspective of its parent. |
|
void |
jjtSetFirstToken(GenericToken token)
|
|
void |
jjtSetLastToken(GenericToken token)
|
|
void |
jjtSetParent(Node parent)
This pair of methods are used to inform the node of its parent. |
|
void |
setDataFlowNode(DataFlowNode dataFlowNode)
|
|
void |
setImage(String image)
|
|
void |
setUserData(Object userData)
Set the user data associated with this node. |
|
void |
testingOnly__setBeginColumn(int i)
|
|
void |
testingOnly__setBeginLine(int i)
|
|
void |
testingOnly__setEndColumn(int i)
|
|
void |
testingOnly__setEndLine(int i)
|
|
abstract String |
toString()
Subclasses should implement this method to return a name usable with XPathRule for evaluating Element Names. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Node parent
protected Node[] children
protected int childIndex
protected int id
protected int beginLine
protected int endLine
protected int beginColumn
protected int endColumn
protected GenericToken firstToken
protected GenericToken lastToken
| Constructor Detail |
|---|
public AbstractNode(int id)
public AbstractNode(int id,
int theBeginLine,
int theEndLine,
int theBeginColumn,
int theEndColumn)
| Method Detail |
|---|
public boolean isSingleLine()
public void jjtOpen()
Node
jjtOpen in interface Nodepublic void jjtClose()
Node
jjtClose in interface Nodepublic void jjtSetParent(Node parent)
Node
jjtSetParent in interface Nodepublic Node jjtGetParent()
jjtGetParent in interface Node
public void jjtAddChild(Node child,
int index)
Node
jjtAddChild in interface Nodepublic void jjtSetChildIndex(int index)
Node
jjtSetChildIndex in interface Nodeindex - the child indexpublic int jjtGetChildIndex()
jjtGetChildIndex in interface Nodepublic Node jjtGetChild(int index)
Node
jjtGetChild in interface Nodeindex - the child index. Must be nonnegative and less than
Node.jjtGetNumChildren().public int jjtGetNumChildren()
Node
jjtGetNumChildren in interface Nodepublic int jjtGetId()
jjtGetId in interface Nodepublic abstract String toString()
toString in class Objectpublic String getImage()
getImage in interface Nodepublic void setImage(String image)
setImage in interface Nodepublic boolean hasImageEqualTo(String image)
hasImageEqualTo in interface Nodepublic int getBeginLine()
getBeginLine in interface Nodepublic void testingOnly__setBeginLine(int i)
public int getBeginColumn()
getBeginColumn in interface Nodepublic void testingOnly__setBeginColumn(int i)
public int getEndLine()
getEndLine in interface Nodepublic void testingOnly__setEndLine(int i)
public int getEndColumn()
getEndColumn in interface Nodepublic void testingOnly__setEndColumn(int i)
public DataFlowNode getDataFlowNode()
getDataFlowNode in interface Nodepublic void setDataFlowNode(DataFlowNode dataFlowNode)
setDataFlowNode in interface Nodepublic Node getNthParent(int n)
n ancestors
getNthParent in interface Noden - how many ancestors to iterate over.
IllegalArgumentException - if n is not positive.public <T> T getFirstParentOfType(Class<T> parentType)
getFirstParentOfType in interface NodeparentType - class which you want to find.
public <T> List<T> getParentsOfType(Class<T> parentType)
getParentsOfType in interface NodeparentType - classes which you want to find.
public <T> List<T> findDescendantsOfType(Class<T> targetType)
findDescendantsOfType in interface NodetargetType - class which you want to find.
public <T> void findDescendantsOfType(Class<T> targetType,
List<T> results,
boolean crossBoundaries)
findDescendantsOfType in interface NodetargetType - class which you want to find.results - list to store the matching descendantscrossBoundaries - if false, recursion stops for nodes for which Node.isFindBoundary() is truepublic <T> List<T> findChildrenOfType(Class<T> targetType)
findChildrenOfType in interface NodetargetType - class which you want to find.
if traversal of the entire tree is needed.public boolean isFindBoundary()
isFindBoundary in interface Nodepublic Document getAsDocument()
Node
getAsDocument in interface Nodeprotected void appendElement(Node parentNode)
public <T> T getFirstDescendantOfType(Class<T> descendantType)
getFirstDescendantOfType in interface NodedescendantType - class which you want to find.
null if none found.public <T> T getFirstChildOfType(Class<T> childType)
getFirstChildOfType in interface NodechildType - class which you want to find.
null if none found.if traversal of the entire tree is needed.public final <T> boolean hasDescendantOfType(Class<T> type)
hasDescendantOfType in interface Nodetype - the node type to search
true if there is at least one descendant of the given typepublic final boolean hasDecendantOfAnyType(Class<?>... types)
types -
public List findChildNodesWithXPath(String xpathString)
throws org.jaxen.JaxenException
findChildNodesWithXPath in interface NodexpathString - the expression to check
org.jaxen.JaxenExceptionpublic boolean hasDescendantMatchingXPath(String xpathString)
hasDescendantMatchingXPath in interface NodexpathString - the expression to check
public Object getUserData()
Node.setUserData(Object).
getUserData in interface Nodepublic void setUserData(Object userData)
PMD itself will never set user data onto a node. Nor should any Rule implementation, as the AST nodes are shared between concurrently executing Rules (i.e. it is not thread-safe).
This API is most useful for external applications looking to leverage PMD's robust support for AST structures, in which case application specific annotations on the AST nodes can be quite useful.
setUserData in interface NodeuserData - The data to set on this node.public GenericToken jjtGetFirstToken()
public void jjtSetFirstToken(GenericToken token)
public GenericToken jjtGetLastToken()
public void jjtSetLastToken(GenericToken token)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||