/**
   * Sets the query configuration handler that will be used during query processing. It can be
   * <code>null</code>. It's also set to the processor returned by {@link #getQueryNodeProcessor()}.
   *
   * @param config the query configuration handler used during query processing, it can be <code>
   *     null</code>
   * @see #getQueryConfigHandler()
   * @see QueryConfigHandler
   */
  public void setQueryConfigHandler(QueryConfigHandler config) {
    this.config = config;
    QueryNodeProcessor processor = getQueryNodeProcessor();

    if (processor != null) {
      processor.setQueryConfigHandler(config);
    }
  }
  /**
   * Parses a query string to an object, usually some query object. <br>
   * <br>
   * In this method the three phases are executed: <br>
   * <br>
   * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1st - the query string is parsed using the text parser returned
   * by {@link #getSyntaxParser()}, the result is a query node tree <br>
   * <br>
   * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2nd - the query node tree is processed by the processor returned
   * by {@link #getQueryNodeProcessor()} <br>
   * <br>
   * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3th - a object is built from the query node tree using the
   * builder returned by {@link #getQueryBuilder()}
   *
   * @param query the query string
   * @param defaultField the default field used by the text parser
   * @return the object built from the query
   * @throws QueryNodeException if something wrong happens along the three phases
   */
  public Object parse(String query, String defaultField) throws QueryNodeException {
    QueryNode queryTree = getSyntaxParser().parse(query, defaultField);

    QueryNodeProcessor processor = getQueryNodeProcessor();

    if (processor != null) {
      queryTree = processor.process(queryTree);
    }

    return getQueryBuilder().build(queryTree);
  }
  /**
   * Creates a query parser helper object using the specified configuration, text parser, processor
   * and builder.
   *
   * @param queryConfigHandler the query configuration handler that will be initially set to this
   *     helper
   * @param syntaxParser the text parser that will be initially set to this helper
   * @param processor the query processor that will be initially set to this helper
   * @param builder the query builder that will be initially set to this helper
   * @see QueryNodeProcessor
   * @see SyntaxParser
   * @see QueryBuilder
   * @see QueryConfigHandler
   */
  public QueryParserHelper(
      QueryConfigHandler queryConfigHandler,
      SyntaxParser syntaxParser,
      QueryNodeProcessor processor,
      QueryBuilder builder) {
    this.syntaxParser = syntaxParser;
    this.config = queryConfigHandler;
    this.processor = processor;
    this.builder = builder;

    if (processor != null) {
      processor.setQueryConfigHandler(queryConfigHandler);
    }
  }