pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / queryparser / src / java / org / apache / lucene / queryParser / standard / nodes / PrefixWildcardQueryNode.java
1 package org.apache.lucene.queryParser.standard.nodes;
2
3 import org.apache.lucene.queryParser.core.nodes.FieldQueryNode;
4
5 /**
6  * Licensed to the Apache Software Foundation (ASF) under one or more
7  * contributor license agreements.  See the NOTICE file distributed with
8  * this work for additional information regarding copyright ownership.
9  * The ASF licenses this file to You under the Apache License, Version 2.0
10  * (the "License"); you may not use this file except in compliance with
11  * the License.  You may obtain a copy of the License at
12  *
13  *     http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 /**
23  * A {@link PrefixWildcardQueryNode} represents wildcardquery that matches abc*
24  * or *. This does not apply to phrases, this is a special case on the original
25  * lucene parser. TODO: refactor the code to remove this special case from the
26  * parser. and probably do it on a Processor
27  */
28 public class PrefixWildcardQueryNode extends WildcardQueryNode {
29
30   private static final long serialVersionUID = 6851557641826407515L;
31
32   /**
33    * @param field
34    *          - field name
35    * @param text
36    *          - value including the wildcard
37    * @param begin
38    *          - position in the query string
39    * @param end
40    *          - position in the query string
41    */
42   public PrefixWildcardQueryNode(CharSequence field, CharSequence text,
43       int begin, int end) {
44     super(field, text, begin, end);
45   }
46
47   public PrefixWildcardQueryNode(FieldQueryNode fqn) {
48     this(fqn.getField(), fqn.getText(), fqn.getBegin(), fqn.getEnd());
49   }
50
51   @Override
52   public String toString() {
53     return "<prefixWildcard field='" + this.field + "' term='" + this.text
54         + "'/>";
55   }
56
57   @Override
58   public PrefixWildcardQueryNode cloneTree() throws CloneNotSupportedException {
59     PrefixWildcardQueryNode clone = (PrefixWildcardQueryNode) super.cloneTree();
60
61     // nothing to do here
62
63     return clone;
64   }
65 }