org.apache.lucene.queryParser.core.builders
public class: QueryTreeBuilder [javadoc |
source]
java.lang.Object
org.apache.lucene.queryParser.core.builders.QueryTreeBuilder
All Implemented Interfaces:
QueryBuilder
Direct Known Subclasses:
StandardQueryTreeBuilder
This class should be used when there is a builder for each type of node.
The type of node may be defined in 2 different ways: - by the field name,
when the node implements the
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
QueryTreeBuilder#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.
| Field Summary |
|---|
| public static final 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. |
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from org.apache.lucene.queryParser.core.builders.QueryTreeBuilder Detail: |
public Object build(QueryNode queryNode) throws QueryNodeException {
process(queryNode);
return queryNode.getTag(QUERY_TREE_BUILDER_TAGID);
}
Builds some kind of object from a query tree. Each node in the query tree
is built using an specific builder associated to it. |
public void setBuilder(CharSequence fieldName,
QueryBuilder builder) {
if (this.fieldNameBuilders == null) {
this.fieldNameBuilders = new HashMap< CharSequence, QueryBuilder >();
}
this.fieldNameBuilders.put(fieldName, builder);
}
Associates a field name with a builder. |
public void setBuilder(Class<QueryNode> queryNodeClass,
QueryBuilder builder) {
if (this.queryNodeBuilders == null) {
this.queryNodeBuilders = new HashMap< Class< ? extends QueryNode >, QueryBuilder >();
}
this.queryNodeBuilders.put(queryNodeClass, builder);
}
Associates a class with a builder |