public interface Node
Modifier and Type | Method and Description |
---|---|
List<? extends Node> |
findChildNodesWithXPath(String xpathString)
Returns all the nodes matching the xpath expression.
|
<T> List<T> |
findChildrenOfType(Class<T> childType)
Traverses the children to find all the instances of type childType.
|
<T> List<T> |
findDescendantsOfType(Class<T> targetType)
Traverses down the tree to find all the descendant instances of type
descendantType.
|
<T> void |
findDescendantsOfType(Class<T> targetType,
List<T> results,
boolean crossFindBoundaries)
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() |
<T> T |
getFirstChildOfType(Class<T> childType)
Traverses the children to find the first instance of type childType.
|
<T> T |
getFirstDescendantOfType(Class<T> descendantType)
Traverses down the tree to find the first descendant instance of type
descendantType.
|
<T> T |
getFirstParentOfType(Class<T> parentType) |
String |
getImage() |
Node |
getNthParent(int n) |
<T> List<T> |
getParentsOfType(Class<T> parentType) |
Object |
getUserData()
Get the user data associated with this node.
|
boolean |
hasDescendantMatchingXPath(String xpathString)
Checks whether at least one descendant matches the xpath expression.
|
<T> boolean |
hasDescendantOfType(Class<T> type)
Finds if this node contains a descendant of the given type.
|
boolean |
hasImageEqualTo(String image) |
boolean |
isFindBoundary() |
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() |
int |
jjtGetId() |
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 |
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 jjtOpen()
void jjtClose()
void jjtSetParent(Node parent)
Node jjtGetParent()
void jjtAddChild(Node child, int index)
void jjtSetChildIndex(int index)
index
- the child indexint jjtGetChildIndex()
Node jjtGetChild(int index)
index
- the child index. Must be nonnegative and less than
jjtGetNumChildren()
.int jjtGetNumChildren()
int jjtGetId()
String getImage()
void setImage(String image)
boolean hasImageEqualTo(String image)
int getBeginLine()
int getBeginColumn()
int getEndLine()
int getEndColumn()
DataFlowNode getDataFlowNode()
void setDataFlowNode(DataFlowNode dataFlowNode)
boolean isFindBoundary()
Node getNthParent(int n)
<T> T getFirstParentOfType(Class<T> parentType)
<T> List<T> findChildrenOfType(Class<T> childType)
childType
- class which you want to find.if traversal of the entire tree is
needed.
<T> List<T> findDescendantsOfType(Class<T> targetType)
targetType
- class which you want to find.<T> void findDescendantsOfType(Class<T> targetType, List<T> results, boolean crossFindBoundaries)
targetType
- class which you want to find.results
- list to store the matching descendantscrossFindBoundaries
- if false
, recursion stops for nodes for which
isFindBoundary()
is true
<T> T getFirstChildOfType(Class<T> childType)
childType
- class which you want to find.null
if none found.if traversal of the entire tree is
needed.
<T> T getFirstDescendantOfType(Class<T> descendantType)
descendantType
- class which you want to find.null
if none
found.<T> boolean hasDescendantOfType(Class<T> type)
type
- the node type to searchtrue
if there is at least one descendant of the
given typeList<? extends Node> findChildNodesWithXPath(String xpathString) throws org.jaxen.JaxenException
xpathString
- the expression to checkorg.jaxen.JaxenException
boolean hasDescendantMatchingXPath(String xpathString)
xpathString
- the expression to checkDocument getAsDocument()
Object getUserData()
setUserData(Object)
.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.
userData
- The data to set on this node.Copyright © 2002–2017 PMD. All rights reserved.