org.apache.lucene.queryparser.flexible.core

## Class QueryParserHelper

- java.lang.Object
- - org.apache.lucene.queryparser.flexible.core.QueryParserHelper

- Direct Known Subclasses:
    StandardQueryParser

      public class QueryParserHelper
      extends Object

  This class is a helper for the query parser framework, it does all the three query parser phrases at once: text parsing, query processing and query building.

  It contains methods that allows the user to change the implementation used on the three phases.

  See Also:
    `QueryNodeProcessor`, `SyntaxParser`, `QueryBuilder`, `QueryConfigHandler`

- - ### Constructor Summary

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

  - ### Method Summary

    Methods
    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`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### QueryParserHelper

          public QueryParserHelper(QueryConfigHandler queryConfigHandler,
                           SyntaxParser syntaxParser,
                           QueryNodeProcessor processor,
                           QueryBuilder builder)

      Creates a query parser helper object using the specified configuration, text parser, processor and builder.
      Parameters:
        `queryConfigHandler` - the query configuration handler that will be initially set to this helper
        `syntaxParser` - the text parser that will be initially set to this helper
        `processor` - the query processor that will be initially set to this helper
        `builder` - the query builder that will be initially set to this helper
      See Also:
        `QueryNodeProcessor`, `SyntaxParser`, `QueryBuilder`, `QueryConfigHandler`

  - ### Method Detail

    - #### getQueryNodeProcessor

          public QueryNodeProcessor getQueryNodeProcessor()

      Returns the processor object used to process the query node tree, it returns `null` if no processor is used.
      Returns:
        the actual processor used to process the query node tree, `null` if no processor is used
      See Also:
        `QueryNodeProcessor`, `setQueryNodeProcessor(QueryNodeProcessor)`

    - #### setQueryNodeProcessor

          public void setQueryNodeProcessor(QueryNodeProcessor processor)

      Sets the processor that will be used to process the query node tree. If there is any `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.
      Parameters:
        `processor` - the processor that will be used to process the query node tree, this argument can be `null`
      See Also:
        `getQueryNodeProcessor()`, `QueryNodeProcessor`

    - #### setSyntaxParser

          public void setSyntaxParser(SyntaxParser syntaxParser)

      Sets the text parser that will be used to parse the query string, it cannot be `null`.
      Parameters:
        `syntaxParser` - the text parser that will be used to parse the query string
      See Also:
        `getSyntaxParser()`, `SyntaxParser`

    - #### setQueryBuilder

          public void setQueryBuilder(QueryBuilder queryBuilder)

      The query builder that will be used to build an object from the query node tree. It cannot be `null`.
      Parameters:
        `queryBuilder` - the query builder used to build something from the query node tree
      See Also:
        `getQueryBuilder()`, `QueryBuilder`

    - #### getQueryConfigHandler

          public QueryConfigHandler getQueryConfigHandler()

      Returns the query configuration handler, which is used during the query node tree processing. It can be `null`.
      Returns:
        the query configuration handler used on the query processing, `null` if not query configuration handler is defined
      See Also:
        `QueryConfigHandler`, `setQueryConfigHandler(QueryConfigHandler)`

    - #### getQueryBuilder

          public QueryBuilder getQueryBuilder()

      Returns the query builder used to build a object from the query node tree. The object produced by this builder is returned by `parse(String, String)`.
      Returns:
        the query builder
      See Also:
        `setQueryBuilder(QueryBuilder)`, `QueryBuilder`

    - #### getSyntaxParser

          public SyntaxParser getSyntaxParser()

      Returns the text parser used to build a query node tree from a query string. The default text parser instance returned by this method is a `SyntaxParser`.
      Returns:
        the text parse used to build query node trees.
      See Also:
        `SyntaxParser`, `setSyntaxParser(SyntaxParser)`

    - #### setQueryConfigHandler

          public void setQueryConfigHandler(QueryConfigHandler config)

      Sets the query configuration handler that will be used during query processing. It can be `null`. It's also set to the processor returned by `getQueryNodeProcessor()`.
      Parameters:
        `config` - the query configuration handler used during query processing, it can be `null`
      See Also:
        `getQueryConfigHandler()`, `QueryConfigHandler`

    - #### parse

          public Object parse(String query,
                     String defaultField)
                       throws QueryNodeException

      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()`
      Parameters:
        `query` - the query string
        `defaultField` - the default field used by the text parser
      Returns:
        the object built from the query
      Throws:
        `QueryNodeException` - if something wrong happens along the three phases

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.