Class CoreParser
- java.lang.Object
-
- org.apache.lucene.queryparser.xml.CoreParser
-
- All Implemented Interfaces:
SpanQueryBuilder
,QueryBuilder
- Direct Known Subclasses:
CorePlusQueriesParser
public class CoreParser extends Object implements SpanQueryBuilder
Assembles a QueryBuilder which uses only core Lucene Query objects
-
-
Field Summary
Fields Modifier and Type Field Description protected Analyzer
analyzer
protected String
defaultField
static EntityResolver
DISALLOW_EXTERNAL_ENTITY_RESOLVER
protected QueryParser
parser
protected QueryBuilderFactory
queryFactory
protected SpanQueryBuilderFactory
spanFactory
-
Constructor Summary
Constructors Modifier Constructor Description 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)
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
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addQueryBuilder(String nodeName, QueryBuilder builder)
void
addSpanBuilder(String nodeName, SpanQueryBuilder builder)
void
addSpanQueryBuilder(String nodeName, SpanQueryBuilder builder)
protected EntityResolver
getEntityResolver()
Returns a SAXEntityResolver
to be used byDocumentBuilder
.protected ErrorHandler
getErrorHandler()
Subclass and override to return a SAXErrorHandler
to be used byDocumentBuilder
.Query
getQuery(Element e)
SpanQuery
getSpanQuery(Element e)
Query
parse(InputStream xmlStream)
Parses the given stream as XML file and returns aQuery
.
-
-
-
Field Detail
-
defaultField
protected String defaultField
-
analyzer
protected Analyzer analyzer
-
parser
protected QueryParser parser
-
queryFactory
protected QueryBuilderFactory queryFactory
-
spanFactory
protected final SpanQueryBuilderFactory spanFactory
-
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 aQuery
. By default this disallows external entities for security reasons.- Throws:
ParserException
-
addQueryBuilder
public void addQueryBuilder(String nodeName, QueryBuilder builder)
-
addSpanBuilder
public void addSpanBuilder(String nodeName, SpanQueryBuilder builder)
-
addSpanQueryBuilder
public void addSpanQueryBuilder(String nodeName, SpanQueryBuilder builder)
-
getEntityResolver
protected EntityResolver getEntityResolver()
Returns a SAXEntityResolver
to be used byDocumentBuilder
. By default this returnsDISALLOW_EXTERNAL_ENTITY_RESOLVER
, which disallows the expansion of external entities (for security reasons). To restore legacy behavior, override this method to returnnull
.
-
getErrorHandler
protected ErrorHandler getErrorHandler()
Subclass and override to return a SAXErrorHandler
to be used byDocumentBuilder
. By default this returnsnull
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 interfaceQueryBuilder
- Throws:
ParserException
-
getSpanQuery
public SpanQuery getSpanQuery(Element e) throws ParserException
- Specified by:
getSpanQuery
in interfaceSpanQueryBuilder
- Throws:
ParserException
-
-