public class QueryTreeBuilder extends Object implements QueryBuilder
FieldableNode
interface - by its class,
it keeps checking the class and all the interfaces and classes this class
implements/extends until it finds a builder for that class/interface
This class always check if there is a builder for the field name before it
checks for the node class. So, field name builders have precedence over class
builders.
When a builder is found for a node, it's called and the node is passed to the
builder. If the returned built object is not null
, it's tagged
on the node using the tag QUERY_TREE_BUILDER_TAGID
.
The children are usually built before the parent node. However, if a builder
associated to a node is an instance of QueryTreeBuilder
, the node is
delegated to this builder and it's responsible to build the node and its
children.QueryBuilder
Modifier and Type | Field and Description |
---|---|
static String |
QUERY_TREE_BUILDER_TAGID
This tag is used to tag the nodes in a query tree with the built objects
produced from their own associated builder.
|
Constructor and Description |
---|
QueryTreeBuilder()
QueryTreeBuilder constructor. |
Modifier and Type | Method and Description |
---|---|
Object |
build(QueryNode queryNode)
Builds some kind of object from a query tree.
|
void |
setBuilder(CharSequence fieldName,
QueryBuilder builder)
Associates a field name with a builder.
|
void |
setBuilder(Class<? extends QueryNode> queryNodeClass,
QueryBuilder builder)
Associates a class with a builder
|
public static final String QUERY_TREE_BUILDER_TAGID
public QueryTreeBuilder()
QueryTreeBuilder
constructor.public void setBuilder(CharSequence fieldName, QueryBuilder builder)
fieldName
- the field namebuilder
- the builder to be associatedpublic void setBuilder(Class<? extends QueryNode> queryNodeClass, QueryBuilder builder)
queryNodeClass
- the classbuilder
- the builder to be associatedpublic Object build(QueryNode queryNode) throws QueryNodeException
build
in interface QueryBuilder
queryNode
- the query tree root nodeQueryNodeException
- if some node builder throws a
QueryNodeException
or if there is a node which had no
builder associated to itCopyright © 2000-2019 Apache Software Foundation. All Rights Reserved.