Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
AbstractNode(int id) |
AbstractNode(int id,
int theBeginLine,
int theEndLine,
int theBeginColumn,
int theEndColumn) |
Modifier and Type | Method and Description |
---|---|
protected void |
appendElement(Node parentNode) |
List<Node> |
findChildNodesWithXPath(String xpathString)
Returns all the nodes matching the xpath expression.
|
<T> List<T> |
findChildrenOfType(Class<T> targetType)
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 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() |
<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)
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 |
<T> List<T> |
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.
|
<T> boolean |
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.
|
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
public AbstractNode(int id)
public AbstractNode(int id, int theBeginLine, int theEndLine, int theBeginColumn, int theEndColumn)
public boolean isSingleLine()
public void jjtOpen()
Node
public void jjtClose()
Node
public void jjtSetParent(Node parent)
Node
jjtSetParent
in interface Node
public Node jjtGetParent()
jjtGetParent
in interface Node
public void jjtAddChild(Node child, int index)
Node
jjtAddChild
in interface Node
public void jjtSetChildIndex(int index)
Node
jjtSetChildIndex
in interface Node
index
- the child indexpublic int jjtGetChildIndex()
jjtGetChildIndex
in interface Node
public Node jjtGetChild(int index)
Node
jjtGetChild
in interface Node
index
- the child index. Must be nonnegative and less than
Node.jjtGetNumChildren()
.public int jjtGetNumChildren()
Node
jjtGetNumChildren
in interface Node
public abstract String toString()
public boolean hasImageEqualTo(String image)
hasImageEqualTo
in interface Node
public int getBeginLine()
getBeginLine
in interface Node
public void testingOnly__setBeginLine(int i)
public int getBeginColumn()
getBeginColumn
in interface Node
public void testingOnly__setBeginColumn(int i)
public int getEndLine()
getEndLine
in interface Node
public void testingOnly__setEndLine(int i)
public int getEndColumn()
getEndColumn
in interface Node
public void testingOnly__setEndColumn(int i)
public DataFlowNode getDataFlowNode()
getDataFlowNode
in interface Node
public void setDataFlowNode(DataFlowNode dataFlowNode)
setDataFlowNode
in interface Node
public Node getNthParent(int n)
n
ancestorsgetNthParent
in interface Node
n
- how many ancestors to iterate over.IllegalArgumentException
- if n
is not positive.public <T> T getFirstParentOfType(Class<T> parentType)
getFirstParentOfType
in interface Node
parentType
- class which you want to find.public <T> List<T> getParentsOfType(Class<T> parentType)
getParentsOfType
in interface Node
parentType
- classes which you want to find.public <T> List<T> findDescendantsOfType(Class<T> targetType)
findDescendantsOfType
in interface Node
targetType
- class which you want to find.public <T> void findDescendantsOfType(Class<T> targetType, List<T> results, boolean crossBoundaries)
findDescendantsOfType
in interface Node
targetType
- class which you want to find.results
- list to store the matching descendantscrossBoundaries
- if false
, recursion stops for nodes for which Node.isFindBoundary()
is true
public <T> List<T> findChildrenOfType(Class<T> targetType)
findChildrenOfType
in interface Node
targetType
- class which you want to find.if traversal of the entire tree is needed.
public boolean isFindBoundary()
isFindBoundary
in interface Node
public Document getAsDocument()
Node
getAsDocument
in interface Node
protected void appendElement(Node parentNode)
public <T> T getFirstDescendantOfType(Class<T> descendantType)
getFirstDescendantOfType
in interface Node
descendantType
- class which you want to find.null
if none found.public <T> T getFirstChildOfType(Class<T> childType)
getFirstChildOfType
in interface Node
childType
- 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 Node
type
- the node type to searchtrue
if there is at least one descendant of the given typepublic final boolean hasDecendantOfAnyType(Class<?>... types)
types
- public List<Node> findChildNodesWithXPath(String xpathString) throws org.jaxen.JaxenException
findChildNodesWithXPath
in interface Node
xpathString
- the expression to checkorg.jaxen.JaxenException
public boolean hasDescendantMatchingXPath(String xpathString)
hasDescendantMatchingXPath
in interface Node
xpathString
- the expression to checkpublic Object getUserData()
Node.setUserData(Object)
.getUserData
in interface Node
public 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 Node
userData
- The data to set on this node.public GenericToken jjtGetFirstToken()
public void jjtSetFirstToken(GenericToken token)
public GenericToken jjtGetLastToken()
public void jjtSetLastToken(GenericToken token)
Copyright © 2002-2016 InfoEther. All Rights Reserved.