public class QueryBuilder extends Object
QueryBuilder
allows for modular assembly of context graph queries.
Query assembly is performed by chaining a sequence of graph traversal and filtering operations together in order to select a particular set of the input node set's descendants.
Modifier and Type | Method and Description |
---|---|
Query |
build()
Returns a query that represents the currently assembled transformation.
|
QueryBuilder |
chain(Query query)
Applies the given query on the currently selected node set.
|
QueryBuilder |
children()
Selects the union of the current node sets child nodes.
|
QueryBuilder |
descendants()
Selects the merged descendant set of the current node set.
|
QueryBuilder |
empty()
Selects an empty node set.
|
QueryBuilder |
ensureUnique()
Asserts that the current node set is a singleton.
|
QueryBuilder |
filter(Matcher<? super TreeNode> filter)
Filters the current node set using the supplied
Matcher . |
QueryBuilder |
parent()
Selects the parent of the current node.
|
static QueryBuilder |
queryBuilder()
Creates a new query builder instance.
|
public static QueryBuilder queryBuilder()
A newly constructed query builder represents the identity query. It simply returns the input node set as the output node set.
public QueryBuilder filter(Matcher<? super TreeNode> filter)
Matcher
.
Nodes in the current node set that are not selected by the supplied matcher are removed.
filter
- matcher to applypublic QueryBuilder children()
public QueryBuilder parent()
public QueryBuilder descendants()
More precisely this recursively merges the children of each member of the node-set in to the output node set until the set ceases to grow.
public QueryBuilder chain(Query query)
query
- query to applypublic QueryBuilder ensureUnique()
If the current node set is not of size 1 then the query will terminate with
an IllegalStateException
.
public QueryBuilder empty()
public Query build()
Copyright © 2017. All rights reserved.