PyLucene 3.4.0-1 import
[pylucene.git] / java / org / apache / pylucene / queryParser / PythonQueryParser.java
1 /* ====================================================================
2  *   Licensed under the Apache License, Version 2.0 (the "License");
3  *   you may not use this file except in compliance with the License.
4  *   You may obtain a copy of the License at
5  *
6  *       http://www.apache.org/licenses/LICENSE-2.0
7  *
8  *   Unless required by applicable law or agreed to in writing, software
9  *   distributed under the License is distributed on an "AS IS" BASIS,
10  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  *   See the License for the specific language governing permissions and
12  *   limitations under the License.
13  * ====================================================================
14  */
15
16 package org.apache.pylucene.queryParser;
17
18 import java.util.List;
19
20 import org.apache.lucene.analysis.Analyzer;
21 import org.apache.lucene.search.Query;
22 import org.apache.lucene.queryParser.QueryParser;
23 import org.apache.lucene.queryParser.CharStream;
24 import org.apache.lucene.queryParser.ParseException;
25 import org.apache.lucene.util.Version;
26
27
28 public class PythonQueryParser extends QueryParser {
29
30     private long pythonObject;
31
32     public PythonQueryParser(Version version, String field, Analyzer analyzer)
33     {
34         super(version, field, analyzer);
35     }
36
37     public PythonQueryParser(CharStream stream)
38     {
39         super(stream);
40     }
41
42     public void pythonExtension(long pythonObject)
43     {
44         this.pythonObject = pythonObject;
45     }
46     public long pythonExtension()
47     {
48         return this.pythonObject;
49     }
50
51     public void finalize()
52         throws Throwable
53     {
54         pythonDecRef();
55     }
56
57     public native void pythonDecRef();
58     public native Query getBooleanQuery(List clauses, boolean disableCoord);
59     public native Query getFuzzyQuery(String field, String termText,
60                                       float minSimilarity);
61     public native Query getPrefixQuery(String field, String termText);
62     public native Query getRangeQuery(String field,
63                                       String part1, String part2,
64                                       boolean inclusive);
65     public native Query getWildcardQuery(String field, String termText);
66
67     public native Query getFieldQuery_quoted(String field, String queryText,
68                                              boolean quoted);
69     public native Query getFieldQuery_slop(String field, String queryText,
70                                            int slop);
71
72     public Query getFieldQuery_quoted_super(String field, String queryText,
73                                             boolean quoted)
74         throws ParseException
75     {
76         return super.getFieldQuery(field, queryText, quoted);
77     }
78
79     public Query getFieldQuery_slop_super(String field, String queryText,
80                                           int slop)
81         throws ParseException
82     {
83         return super.getFieldQuery(field, queryText, slop);
84     }
85
86     public Query getFieldQuery(String field, String queryText, boolean quoted)
87     {
88         return getFieldQuery_quoted(field, queryText, quoted);
89     }
90
91     public Query getFieldQuery(String field, String queryText, int slop)
92     {
93         return getFieldQuery_slop(field, queryText, slop);
94     }
95 }