pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / src / java / org / apache / lucene / index / TermVectorEntry.java
1 package org.apache.lucene.index;
2
3 /**
4  * Copyright 2007 The Apache Software Foundation
5  * <p/>
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  * <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
30   public TermVectorEntry() {
31   }
32
33   public TermVectorEntry(String field, String term, int frequency, 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
42   public String getField() {
43     return field;
44   }
45
46   public int getFrequency() {
47     return frequency;
48   }
49
50   public TermVectorOffsetInfo[] getOffsets() {
51     return offsets;
52   }
53
54   public int[] getPositions() {
55     return positions;
56   }
57
58   public String getTerm() {
59     return term;
60   }
61
62   //Keep package local
63   void setFrequency(int frequency) {
64     this.frequency = frequency;
65   }
66
67   void setOffsets(TermVectorOffsetInfo[] offsets) {
68     this.offsets = offsets;
69   }
70
71   void setPositions(int[] positions) {
72     this.positions = positions;
73   }
74
75
76   @Override
77   public boolean equals(Object o) {
78     if (this == o) return true;
79     if (o == null || getClass() != o.getClass()) return false;
80
81     TermVectorEntry that = (TermVectorEntry) o;
82
83     if (term != null ? !term.equals(that.term) : that.term != null) return false;
84
85     return true;
86   }
87
88   @Override
89   public int hashCode() {
90     return (term != null ? term.hashCode() : 0);
91   }
92
93   @Override
94   public String toString() {
95     return "TermVectorEntry{" +
96             "field='" + field + '\'' +
97             ", term='" + term + '\'' +
98             ", frequency=" + frequency +
99             '}';
100   }
101 }