LUCENE-2162: Allow ExtendableQueryParser extensions accessing the toplevel parser and its properties

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@894180 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Simon Willnauer 2009-12-28 14:27:14 +00:00
parent a0d5801661
commit 7c3ed5867e
2 changed files with 14 additions and 2 deletions

View File

@ -133,7 +133,7 @@ public class ExtendableQueryParser extends QueryParser {
final ParserExtension extension = this.extensions
.getExtension(splitExtensionField.cud);
if (extension != null) {
return extension.parse(new ExtensionQuery(splitExtensionField.cur,
return extension.parse(new ExtensionQuery(this, splitExtensionField.cur,
queryText));
}
return super.getFieldQuery(field, queryText);

View File

@ -1,5 +1,7 @@
package org.apache.lucene.queryParser.ext;
import org.apache.lucene.queryParser.QueryParser;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@ -29,6 +31,7 @@ public class ExtensionQuery {
private final String field;
private final String rawQueryString;
private final QueryParser topLevelParser;
/**
* Creates a new {@link ExtensionQuery}
@ -38,9 +41,10 @@ public class ExtensionQuery {
* @param rawQueryString
* the raw extension query string
*/
public ExtensionQuery(String field, String rawQueryString) {
public ExtensionQuery(QueryParser topLevelParser, String field, String rawQueryString) {
this.field = field;
this.rawQueryString = rawQueryString;
this.topLevelParser = topLevelParser;
}
/**
@ -60,4 +64,12 @@ public class ExtensionQuery {
public String getRawQueryString() {
return rawQueryString;
}
/**
* Returns the top level parser which created this {@link ExtensionQuery}
* @return the top level parser which created this {@link ExtensionQuery}
*/
public QueryParser getTopLevelParser() {
return topLevelParser;
}
}