01: package org.apache.lucene.index;
02:
03: /**
04: * Copyright 2007 The Apache Software Foundation
05: * <p/>
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: * <p/>
10: * http://www.apache.org/licenses/LICENSE-2.0
11: * <p/>
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: /**
20: * Convenience class for holding TermVector information.
21: */
22: public class TermVectorEntry {
23: private String field;
24: private String term;
25: private int frequency;
26: private TermVectorOffsetInfo[] offsets;
27: int[] positions;
28:
29: public TermVectorEntry() {
30: }
31:
32: public TermVectorEntry(String field, String term, int frequency,
33: TermVectorOffsetInfo[] offsets, int[] positions) {
34: this .field = field;
35: this .term = term;
36: this .frequency = frequency;
37: this .offsets = offsets;
38: this .positions = positions;
39: }
40:
41: public String getField() {
42: return field;
43: }
44:
45: public int getFrequency() {
46: return frequency;
47: }
48:
49: public TermVectorOffsetInfo[] getOffsets() {
50: return offsets;
51: }
52:
53: public int[] getPositions() {
54: return positions;
55: }
56:
57: public String getTerm() {
58: return term;
59: }
60:
61: //Keep package local
62: void setFrequency(int frequency) {
63: this .frequency = frequency;
64: }
65:
66: void setOffsets(TermVectorOffsetInfo[] offsets) {
67: this .offsets = offsets;
68: }
69:
70: void setPositions(int[] positions) {
71: this .positions = positions;
72: }
73:
74: public boolean equals(Object o) {
75: if (this == o)
76: return true;
77: if (o == null || getClass() != o.getClass())
78: return false;
79:
80: TermVectorEntry that = (TermVectorEntry) o;
81:
82: if (term != null ? !term.equals(that.term) : that.term != null)
83: return false;
84:
85: return true;
86: }
87:
88: public int hashCode() {
89: return (term != null ? term.hashCode() : 0);
90: }
91:
92: public String toString() {
93: return "TermVectorEntry{" + "field='" + field + '\''
94: + ", term='" + term + '\'' + ", frequency=" + frequency
95: + '}';
96: }
97: }
|