QueryNodeProcessorImpl (Lucene 10.5.1 queryparser API)
Description: declaration: package: org.apache.lucene.queryparser.flexible.core.processors, class: QueryNodeProcessorImpl

Package org.apache.lucene.queryparser.flexible.core.processors

# Class QueryNodeProcessorImpl

java.lang.Object
org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl

All Implemented Interfaces:
  `QueryNodeProcessor`

Direct Known Subclasses:
  `AllowLeadingWildcardProcessor`, `AnalyzerQueryNodeProcessor`, `BooleanModifiersQueryNodeProcessor`, `BooleanSingleChildOptimizationQueryNodeProcessor`, `BoostQueryNodeProcessor`, `DefaultPhraseSlopQueryNodeProcessor`, `FuzzyQueryNodeProcessor`, `IntervalQueryNodeProcessor`, `MatchAllDocsQueryNodeProcessor`, `MultiFieldQueryNodeProcessor`, `MultiTermRewriteMethodProcessor`, `NoChildOptimizationQueryNodeProcessor`, `OpenRangeQueryNodeProcessor`, `PhraseSlopQueryNodeProcessor`, `PointQueryNodeProcessor`, `PointRangeQueryNodeProcessor`, `RegexpQueryNodeProcessor`, `RemoveDeletedQueryNodesProcessor`, `RemoveEmptyNonLeafQueryNodeProcessor`, `TermRangeQueryNodeProcessor`, `WildcardQueryNodeProcessor`

public abstract class QueryNodeProcessorImpl extends Object implements QueryNodeProcessor
This is a default implementation for the `QueryNodeProcessor` interface, it's an abstract class, so it should be extended by classes that want to process a `QueryNode` tree.

This class process `QueryNode`s from left to right in the tree. While it's walking down the tree, for every node, `preProcessNode(QueryNode)` is invoked. After a node's children are processed, `postProcessNode(QueryNode)` is invoked for that node. `setChildrenOrder(List)` is invoked before `postProcessNode(QueryNode)` only if the node has at least one child, in `setChildrenOrder(List)` the implementor might redefine the children order or remove any children from the children list.

Here is an example about how it process the nodes:

          a
         / \
        b   e
       / \
      c   d

Here is the order the methods would be invoked for the tree described above:

          preProcessNode( a );
          preProcessNode( b );
          preProcessNode( c );
          postProcessNode( c );
          preProcessNode( d );
          postProcessNode( d );
          setChildrenOrder( bChildrenList );
          postProcessNode( b );
          preProcessNode( e );
          postProcessNode( e );
          setChildrenOrder( aChildrenList );
          postProcessNode( a )

See Also:
  - `QueryNodeProcessor`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `QueryNodeProcessorImpl()`
  `QueryNodeProcessorImpl(QueryConfigHandler queryConfigHandler)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `QueryConfigHandler`
  `getQueryConfigHandler()`
  For reference about this method check: `QueryNodeProcessor.getQueryConfigHandler()`.
  `protected abstract QueryNode`
  `postProcessNode(QueryNode node)`
  This method is invoked for every node when walking up the tree.
  `protected abstract QueryNode`
  `preProcessNode(QueryNode node)`
  This method is invoked for every node when walking down the tree.
  `QueryNode`
  `process(QueryNode queryTree)`
  Processes a query node tree.
  `protected void`
  `processChildren(QueryNode queryTree)`
  This method is called every time a child is processed.
  `protected abstract List<QueryNode>`
  `setChildrenOrder(List<QueryNode> children)`
  This method is invoked for every node that has at least on child.
  `void`
  `setQueryConfigHandler(QueryConfigHandler queryConfigHandler)`
  For reference about this method check: `QueryNodeProcessor.setQueryConfigHandler(QueryConfigHandler)`.

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

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

- ## Constructor Details

  - ### QueryNodeProcessorImpl

    public QueryNodeProcessorImpl()

  - ### QueryNodeProcessorImpl

    public QueryNodeProcessorImpl(QueryConfigHandler queryConfigHandler)

- ## Method Details

  - ### process

    public QueryNode process(QueryNode queryTree) throws QueryNodeException
    Description copied from interface: `QueryNodeProcessor`
    Processes a query node tree. It may return the same or another query tree. I should never return `null`.
    Specified by:
      `process` in interface `QueryNodeProcessor`
    Parameters:
      `queryTree` - tree root node
    Returns:
      the processed query tree
    Throws:
      `QueryNodeException`

  - ### processChildren

    protected void processChildren(QueryNode queryTree) throws QueryNodeException
    This method is called every time a child is processed.
    Parameters:
      `queryTree` - the query node child to be processed
    Throws:
      `QueryNodeException` - if something goes wrong during the query node processing

  - ### setQueryConfigHandler

    public void setQueryConfigHandler(QueryConfigHandler queryConfigHandler)
    For reference about this method check: `QueryNodeProcessor.setQueryConfigHandler(QueryConfigHandler)`.
    Specified by:
      `setQueryConfigHandler` in interface `QueryNodeProcessor`
    Parameters:
      `queryConfigHandler` - the query configuration handler to be set.
    See Also:
      - `QueryNodeProcessor.getQueryConfigHandler()`
      - `QueryConfigHandler`

  - ### getQueryConfigHandler

    public QueryConfigHandler getQueryConfigHandler()
    For reference about this method check: `QueryNodeProcessor.getQueryConfigHandler()`.
    Specified by:
      `getQueryConfigHandler` in interface `QueryNodeProcessor`
    Returns:
      QueryConfigHandler the query configuration handler to be set.
    See Also:
      - `QueryNodeProcessor.setQueryConfigHandler(QueryConfigHandler)`
      - `QueryConfigHandler`

  - ### preProcessNode

    protected abstract QueryNode preProcessNode(QueryNode node) throws QueryNodeException
    This method is invoked for every node when walking down the tree.
    Parameters:
      `node` - the query node to be pre-processed
    Returns:
      a query node
    Throws:
      `QueryNodeException` - if something goes wrong during the query node processing

  - ### postProcessNode

    protected abstract QueryNode postProcessNode(QueryNode node) throws QueryNodeException
    This method is invoked for every node when walking up the tree.
    Parameters:
      `node` - node the query node to be post-processed
    Returns:
      a query node
    Throws:
      `QueryNodeException` - if something goes wrong during the query node processing

  - ### setChildrenOrder

    protected abstract List<QueryNode> setChildrenOrder(List<QueryNode> children) throws QueryNodeException
    This method is invoked for every node that has at least on child. It's invoked right before `postProcessNode(QueryNode)` is invoked.
    Parameters:
      `children` - the list containing all current node's children
    Returns:
      a new list containing all children that should be set to the current node
    Throws:
      `QueryNodeException` - if something goes wrong during the query node processing