public class QueryParserHelper extends Object
It contains methods that allows the user to change the implementation used on the three phases.
QueryNodeProcessor
,
SyntaxParser
,
QueryBuilder
,
QueryConfigHandler
Constructor and Description |
---|
QueryParserHelper(QueryConfigHandler queryConfigHandler,
SyntaxParser syntaxParser,
QueryNodeProcessor processor,
QueryBuilder builder)
Creates a query parser helper object using the specified configuration,
text parser, processor and builder.
|
Modifier and Type | Method and Description |
---|---|
QueryBuilder |
getQueryBuilder()
Returns the query builder used to build a object from the query node tree.
|
QueryConfigHandler |
getQueryConfigHandler()
Returns the query configuration handler, which is used during the query
node tree processing.
|
QueryNodeProcessor |
getQueryNodeProcessor()
Returns the processor object used to process the query node tree, it
returns
null if no processor is used. |
SyntaxParser |
getSyntaxParser()
Returns the text parser used to build a query node tree from a query
string.
|
Object |
parse(String query,
String defaultField)
Parses a query string to an object, usually some query object.
In this method the three phases are executed: 1st - the query string is parsed using the text parser returned by getSyntaxParser() , the result is a query
node tree 2nd - the query node tree is processed by the processor returned by getQueryNodeProcessor() 3th - a object is built from the query node tree using the builder returned by getQueryBuilder() |
void |
setQueryBuilder(QueryBuilder queryBuilder)
The query builder that will be used to build an object from the query node
tree.
|
void |
setQueryConfigHandler(QueryConfigHandler config)
Sets the query configuration handler that will be used during query
processing.
|
void |
setQueryNodeProcessor(QueryNodeProcessor processor)
Sets the processor that will be used to process the query node tree.
|
void |
setSyntaxParser(SyntaxParser syntaxParser)
Sets the text parser that will be used to parse the query string, it cannot
be
null . |
public QueryParserHelper(QueryConfigHandler queryConfigHandler, SyntaxParser syntaxParser, QueryNodeProcessor processor, QueryBuilder builder)
queryConfigHandler
- the query configuration handler that will be initially set to this
helpersyntaxParser
- the text parser that will be initially set to this helperprocessor
- the query processor that will be initially set to this helperbuilder
- the query builder that will be initially set to this helperQueryNodeProcessor
,
SyntaxParser
,
QueryBuilder
,
QueryConfigHandler
public QueryNodeProcessor getQueryNodeProcessor()
null
if no processor is used.null
if no processor is usedQueryNodeProcessor
,
setQueryNodeProcessor(QueryNodeProcessor)
public void setQueryNodeProcessor(QueryNodeProcessor processor)
QueryConfigHandler
returned by
getQueryConfigHandler()
, it will be set on the processor. The
argument can be null
, which means that no processor will be
used to process the query node tree.processor
- the processor that will be used to process the query node tree,
this argument can be null
getQueryNodeProcessor()
,
QueryNodeProcessor
public void setSyntaxParser(SyntaxParser syntaxParser)
null
.syntaxParser
- the text parser that will be used to parse the query stringgetSyntaxParser()
,
SyntaxParser
public void setQueryBuilder(QueryBuilder queryBuilder)
null
.queryBuilder
- the query builder used to build something from the query node treegetQueryBuilder()
,
QueryBuilder
public QueryConfigHandler getQueryConfigHandler()
null
.null
if not query configuration handler is definedQueryConfigHandler
,
setQueryConfigHandler(QueryConfigHandler)
public QueryBuilder getQueryBuilder()
parse(String, String)
.setQueryBuilder(QueryBuilder)
,
QueryBuilder
public SyntaxParser getSyntaxParser()
SyntaxParser
.SyntaxParser
,
setSyntaxParser(SyntaxParser)
public void setQueryConfigHandler(QueryConfigHandler config)
null
. It's also set to the processor
returned by getQueryNodeProcessor()
.config
- the query configuration handler used during query processing, it
can be null
getQueryConfigHandler()
,
QueryConfigHandler
public Object parse(String query, String defaultField) throws QueryNodeException
getSyntaxParser()
, the result is a query
node tree getQueryNodeProcessor()
getQueryBuilder()
query
- the query stringdefaultField
- the default field used by the text parserQueryNodeException
- if something wrong happens along the three phasesCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.