org.apache.lucene.queryparser.xml

## Class CoreParser

- java.lang.Object
- - org.apache.lucene.queryparser.xml.CoreParser

- All Implemented Interfaces:
    QueryBuilder
  Direct Known Subclasses:
    CorePlusQueriesParser

      public class CoreParser
      extends Object
      implements QueryBuilder

  Assembles a QueryBuilder which uses only core Lucene Query objects

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Analyzer` | `analyzer`
    `static EntityResolver` | `DISALLOW_EXTERNAL_ENTITY_RESOLVER`
    `protected FilterBuilderFactory` | `filterFactory`
    `static int` | `maxNumCachedFilters`
    `protected QueryParser` | `parser`
    `protected QueryBuilderFactory` | `queryFactory`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `CoreParser(Analyzer analyzer, QueryParser parser)` Construct an XML parser that uses a single instance QueryParser for handling UserQuery tags - all parse operations are synchronised on this parser
    `` | `CoreParser(String defaultField, Analyzer analyzer)` Constructs an XML parser that creates a QueryParser for each UserQuery request.
    `protected` | `CoreParser(String defaultField, Analyzer analyzer, QueryParser parser)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addFilterBuilder(String nodeName, FilterBuilder builder)`
    `void` | `addQueryBuilder(String nodeName, QueryBuilder builder)`
    `protected EntityResolver` | `getEntityResolver()` Returns a SAX `EntityResolver` to be used by `DocumentBuilder`.
    `protected ErrorHandler` | `getErrorHandler()` Subclass and override to return a SAX `ErrorHandler` to be used by `DocumentBuilder`.
    `Query` | `getQuery(Element e)`
    `Query` | `parse(InputStream xmlStream)` Parses the given stream as XML file and returns a `Query`.

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

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

- - ### Field Detail

    - #### analyzer

          protected Analyzer analyzer

    - #### parser

          protected QueryParser parser

    - #### queryFactory

          protected QueryBuilderFactory queryFactory

    - #### filterFactory

          protected FilterBuilderFactory filterFactory

    - #### maxNumCachedFilters

          public static int maxNumCachedFilters

    - #### DISALLOW_EXTERNAL_ENTITY_RESOLVER

          public static final EntityResolver DISALLOW_EXTERNAL_ENTITY_RESOLVER

  - ### Constructor Detail

    - #### CoreParser

          public CoreParser(Analyzer analyzer,
                    QueryParser parser)

      Construct an XML parser that uses a single instance QueryParser for handling UserQuery tags - all parse operations are synchronised on this parser
      Parameters:
        `parser` - A QueryParser which will be synchronized on during parse calls.

    - #### CoreParser

          public CoreParser(String defaultField,
                    Analyzer analyzer)

      Constructs an XML parser that creates a QueryParser for each UserQuery request.
      Parameters:
        `defaultField` - The default field name used by QueryParsers constructed for UserQuery tags

    - #### CoreParser

          protected CoreParser(String defaultField,
                    Analyzer analyzer,
                    QueryParser parser)

  - ### Method Detail

    - #### parse

          public Query parse(InputStream xmlStream)
                      throws ParserException

      Parses the given stream as XML file and returns a `Query`. By default this disallows external entities for security reasons.
      Throws:
        `ParserException`

    - #### addQueryBuilder

          public void addQueryBuilder(String nodeName,
                             QueryBuilder builder)

    - #### addFilterBuilder

          public void addFilterBuilder(String nodeName,
                              FilterBuilder builder)

    - #### getEntityResolver

          protected EntityResolver getEntityResolver()

      Returns a SAX `EntityResolver` to be used by `DocumentBuilder`. By default this returns `DISALLOW_EXTERNAL_ENTITY_RESOLVER`, which disallows the expansion of external entities (for security reasons). To restore legacy behavior, override this method to return `null`.

    - #### getErrorHandler

          protected ErrorHandler getErrorHandler()

      Subclass and override to return a SAX `ErrorHandler` to be used by `DocumentBuilder`. By default this returns `null` so no error handler is used. This method can be used to redirect XML parse errors/warnings to a custom logger.

    - #### getQuery

          public Query getQuery(Element e)
                         throws ParserException

      Specified by:
        `getQuery` in interface `QueryBuilder`
      Throws:
        `ParserException`

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