~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ParametricQueryNode.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.lucene.queryParser.core.nodes;
2
 
 
3
 
/**
4
 
 * Licensed to the Apache Software Foundation (ASF) under one or more
5
 
 * contributor license agreements.  See the NOTICE file distributed with
6
 
 * this work for additional information regarding copyright ownership.
7
 
 * The ASF licenses this file to You under the Apache License, Version 2.0
8
 
 * (the "License"); you may not use this file except in compliance with
9
 
 * the License.  You may obtain a copy of the License at
10
 
 *
11
 
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 
 *
13
 
 * Unless required by applicable law or agreed to in writing, software
14
 
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 
 * See the License for the specific language governing permissions and
17
 
 * limitations under the License.
18
 
 */
19
 
 
20
 
import org.apache.lucene.queryParser.core.parser.EscapeQuerySyntax;
21
 
 
22
 
/**
23
 
 * A {@link ParametricQueryNode} represents LE, LT, GE, GT, EQ, NE query.
24
 
 * Example: date >= "2009-10-10" OR price = 200
25
 
 * 
26
 
 * @deprecated this class will be removed in future. {@link FieldQueryNode} 
27
 
 * should be used instead.
28
 
 */
29
 
@Deprecated
30
 
public class ParametricQueryNode extends FieldQueryNode {
31
 
 
32
 
  private static final long serialVersionUID = -5770038129741218116L;
33
 
 
34
 
  private CompareOperator operator;
35
 
 
36
 
  public enum CompareOperator {
37
 
    LE { 
38
 
      @Override
39
 
      public String toString() { return "<="; }
40
 
    },
41
 
    LT {
42
 
      @Override
43
 
      public String toString() { return "<";  }
44
 
    },
45
 
    GE {
46
 
      @Override
47
 
      public String toString() { return ">="; }
48
 
    },
49
 
    GT {
50
 
      @Override
51
 
      public String toString() { return ">";  }
52
 
    },
53
 
    EQ {
54
 
      @Override
55
 
      public String toString() { return "=";  }
56
 
    },
57
 
    NE {
58
 
      @Override
59
 
      public String toString() { return "!="; }
60
 
    };
61
 
  }
62
 
 
63
 
  /**
64
 
   * @param field
65
 
   *          - field name
66
 
   * @param comp
67
 
   *          - CompareOperator
68
 
   * @param value
69
 
   *          - text value
70
 
   * @param begin
71
 
   *          - position in the query string
72
 
   * @param end
73
 
   *          - position in the query string
74
 
   */
75
 
  public ParametricQueryNode(CharSequence field, CompareOperator comp,
76
 
      CharSequence value, int begin, int end) {
77
 
    super(field, value, begin, end);
78
 
    this.operator = comp;
79
 
    setLeaf(true);
80
 
  }
81
 
 
82
 
  public CharSequence getOperand() {
83
 
    return getText();
84
 
  }
85
 
 
86
 
  @Override
87
 
  public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser) {
88
 
    return this.field + "" + this.operator.toString() + "\"" + this.text + "\"";
89
 
  }
90
 
 
91
 
  @Override
92
 
  public String toString() {
93
 
    return "<parametric field='" + this.field + "' operator='"
94
 
        + this.operator.toString() + "' text='" + this.text + "'/>";
95
 
  }
96
 
 
97
 
  @Override
98
 
  public ParametricQueryNode cloneTree() throws CloneNotSupportedException {
99
 
    ParametricQueryNode clone = (ParametricQueryNode) super.cloneTree();
100
 
 
101
 
    clone.operator = this.operator;
102
 
 
103
 
    return clone;
104
 
  }
105
 
 
106
 
  /**
107
 
   * @return the operator
108
 
   */
109
 
  public CompareOperator getOperator() {
110
 
    return this.operator;
111
 
  }
112
 
}