Top Description Fields Constructors Methods
org.terracotta.context.query

public Class QueryBuilder

extends Object
Class Inheritance
Imports
org.terracotta.context.TreeNode

A 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.

Field Summary

Modifier and TypeField and Description
private Query

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Query

Returns:

a newly constructed query
build
()

Returns a query that represents the currently assembled transformation.

public QueryBuilder

Returns:

this query builder
chain
(Query
query to apply
query
)

Applies the given query on the currently selected node set.

public QueryBuilder

Returns:

this query builder
children
()

Selects the union of the current node sets child nodes.

public QueryBuilder

Returns:

this query builder
descendants
()

Selects the merged descendant set of the current node set.

public QueryBuilder

Returns:

this query builder
empty
()

Selects an empty node set.

public QueryBuilder

Returns:

this query builder
ensureUnique
()

Asserts that the current node set is a singleton.

public QueryBuilder

Returns:

this query builder
filter
(Matcher<? super TreeNode>
matcher to apply
filter
)

Filters the current node set using the supplied Matcher.

public QueryBuilder

Returns:

this query builder
parent
()

Selects the parent of the current node.

public static QueryBuilder

Returns:

a new query builder
queryBuilder
()

Creates a new query builder instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
private Query current

Constructor Detail

QueryBuilderback to summary
private QueryBuilder()

Method Detail

buildback to summary
public Query build()

Returns a query that represents the currently assembled transformation.

Returns:Query

a newly constructed query

chainback to summary
public QueryBuilder chain(Query query)

Applies the given query on the currently selected node set.

Parameters
query:Query

query to apply

Returns:QueryBuilder

this query builder

childrenback to summary
public QueryBuilder children()

Selects the union of the current node sets child nodes.

Returns:QueryBuilder

this query builder

descendantsback to summary
public QueryBuilder descendants()

Selects the merged descendant set of the current node set.

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.

Returns:QueryBuilder

this query builder

emptyback to summary
public QueryBuilder empty()

Selects an empty node set.

Returns:QueryBuilder

this query builder

ensureUniqueback to summary
public QueryBuilder ensureUnique()

Asserts that the current node set is a singleton.

If the current node set is not of size 1 then the query will terminate with an IllegalStateException.

Returns:QueryBuilder

this query builder

filterback to summary
public QueryBuilder filter(Matcher<? super TreeNode> filter)

Filters the current node set using the supplied Matcher.

Nodes in the current node set that are not selected by the supplied matcher are removed.

Parameters
filter:Matcher<? super TreeNode>

matcher to apply

Returns:QueryBuilder

this query builder

parentback to summary
public QueryBuilder parent()

Selects the parent of the current node.

Returns:QueryBuilder

this query builder

queryBuilderback to summary
public static QueryBuilder queryBuilder()

Creates a new query builder instance.

A newly constructed query builder represents the identity query. It simply returns the input node set as the output node set.

Returns:QueryBuilder

a new query builder