public class TreeGrepMatch<T> extends Object
TreeGrep
. For every pattern node, it can be used
to recover the matching node in the tree that is being searched.
Usage: Suppose match
is an instance of TreeGrepMatch<T> that is
generated by searching through a tree t
for some pattern p
.
Then, the match
object provides three methods to access the matching elements
between the tree and the pattern.
getPatternDFSMatches()
: This
gives a list of matches for the nodes of the pattern, assuming that the pattern is traversed in
depth first order. Use TreeTraversal.depthFirstTraversal(Tree)
for depth first traversal
of the pattern.
getPatternLeafMatches()
: This
gives a list of matches for just the leaves of the pattern.
getRootMatch()
: This gets the
node in the tree that matches the root of the pattern.
TreeGrep
,
TreeTraversal.depthFirstTraversal(Tree)
Modifier and Type | Field and Description |
---|---|
protected Tree<T>[] |
dfs |
protected List<Tree<T>> |
matches |
protected List<Tree<T>> |
patternLeafMatches |
Constructor and Description |
---|
TreeGrepMatch(Tree<T> pattern) |
TreeGrepMatch(TreeGrepMatch<T> t) |
Modifier and Type | Method and Description |
---|---|
Tree<T> |
getPattern() |
List<Tree<T>> |
getPatternDFSMatches()
Get nodes in the most recently searched tree, which match those of the pattern when traversed
depth first.
|
List<Tree<T>> |
getPatternLeafMatches()
Get the nodes in the most recently searched tree which match the leaves of the pattern.
|
Tree<T> |
getRootMatch()
Get the node in the most recently searched tree that matches that root of the pattern.
|
String |
toString() |
public TreeGrepMatch(TreeGrepMatch<T> t)
public List<Tree<T>> getPatternLeafMatches()
public List<Tree<T>> getPatternDFSMatches()
public Tree<T> getRootMatch()
Copyright © 2017. All rights reserved.