public class CoreParser extends Object implements QueryBuilder, SpanQueryBuilder
Modifier and Type | Field and Description |
---|---|
protected Analyzer |
analyzer |
protected String |
defaultField |
static EntityResolver |
DISALLOW_EXTERNAL_ENTITY_RESOLVER |
protected QueryParser |
parser |
protected QueryBuilderFactory |
queryFactory |
protected SpanQueryBuilderFactory |
spanFactory |
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) |
Modifier and Type | Method and Description |
---|---|
void |
addQueryBuilder(String nodeName,
QueryBuilder builder) |
void |
addSpanBuilder(String nodeName,
SpanQueryBuilder builder) |
void |
addSpanQueryBuilder(String nodeName,
SpanQueryBuilder 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) |
SpanQuery |
getSpanQuery(Element e) |
Query |
parse(InputStream xmlStream)
Parses the given stream as XML file and returns a
Query . |
protected String defaultField
protected Analyzer analyzer
protected QueryParser parser
protected QueryBuilderFactory queryFactory
protected final SpanQueryBuilderFactory spanFactory
public static final EntityResolver DISALLOW_EXTERNAL_ENTITY_RESOLVER
public CoreParser(Analyzer analyzer, QueryParser parser)
parser
- A QueryParser which will be synchronized on during parse calls.public CoreParser(String defaultField, Analyzer analyzer)
defaultField
- The default field name used by QueryParsers constructed for UserQuery tagsprotected CoreParser(String defaultField, Analyzer analyzer, QueryParser parser)
public Query parse(InputStream xmlStream) throws ParserException
Query
.
By default this disallows external entities for security reasons.ParserException
public void addQueryBuilder(String nodeName, QueryBuilder builder)
public void addSpanBuilder(String nodeName, SpanQueryBuilder builder)
public void addSpanQueryBuilder(String nodeName, SpanQueryBuilder builder)
protected EntityResolver getEntityResolver()
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
.protected ErrorHandler getErrorHandler()
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.public Query getQuery(Element e) throws ParserException
getQuery
in interface QueryBuilder
ParserException
public SpanQuery getSpanQuery(Element e) throws ParserException
getSpanQuery
in interface SpanQueryBuilder
ParserException
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.