blob: 9a710deca67f61a7d1a5c33319c3f2f8298f808b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.query;
import java.nio.ByteBuffer;
/**
* Fuzzy search term
*
* @author alexeyche
*/
public class FuzzyItem extends TermItem {
private String fuzzyQuery;
public FuzzyItem(String indexName, boolean isFromQuery, String fuzzyQuery) {
super(indexName, isFromQuery, null);
setValue(fuzzyQuery);
}
@Override
public void setValue(String value) {
this.fuzzyQuery = value;
}
@Override
public String getRawWord() {
return stringValue();
}
@Override
public boolean isWords() {
return false;
}
@Override
public ItemType getItemType() {
return ItemType.FUZZY;
}
@Override
public String getName() {
return "FUZZY";
}
@Override
public String stringValue() {
return fuzzyQuery;
}
@Override
public boolean isStemmed() {
return false;
}
@Override
public String getIndexedString() {
return stringValue();
}
@Override
public int getNumWords() {
return 1;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
FuzzyItem other = (FuzzyItem) obj;
if (fuzzyQuery == null) {
if (other.fuzzyQuery != null) {
return false;
}
} else if (!fuzzyQuery.equals(other.fuzzyQuery)) {
return false;
}
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((fuzzyQuery == null) ? 0 : fuzzyQuery.hashCode());
return result;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FuzzyItem [fuzzyQuery=").append(fuzzyQuery).append("]");
return builder.toString();
}
protected void encodeThis(ByteBuffer buffer) {
super.encodeThis(buffer);
putString(getIndexedString(), buffer);
}
}
|