01: package org.apache.lucene.index;
02:
03: /**
04: * Licensed to the Apache Software Foundation (ASF) under one or more
05: * contributor license agreements. See the NOTICE file distributed with
06: * this work for additional information regarding copyright ownership.
07: * The ASF licenses this file to You under the Apache License, Version 2.0
08: * (the "License"); you may not use this file except in compliance with
09: * 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: /**
21: * The TermVectorOffsetInfo class holds information pertaining to a Term in a {@link org.apache.lucene.index.TermPositionVector}'s
22: * offset information. This offset information is the character offset as set during the Analysis phase (and thus may not be the actual offset in the
23: * original content).
24: */
25: public class TermVectorOffsetInfo {
26: /**
27: * Convenience declaration when creating a {@link org.apache.lucene.index.TermPositionVector} that stores only position information.
28: */
29: public static final TermVectorOffsetInfo[] EMPTY_OFFSET_INFO = new TermVectorOffsetInfo[0];
30: private int startOffset;
31: private int endOffset;
32:
33: public TermVectorOffsetInfo() {
34: }
35:
36: public TermVectorOffsetInfo(int startOffset, int endOffset) {
37: this .endOffset = endOffset;
38: this .startOffset = startOffset;
39: }
40:
41: /**
42: * The accessor for the ending offset for the term
43: * @return The offset
44: */
45: public int getEndOffset() {
46: return endOffset;
47: }
48:
49: public void setEndOffset(int endOffset) {
50: this .endOffset = endOffset;
51: }
52:
53: /**
54: * The accessor for the starting offset of the term.
55: *
56: * @return The offset
57: */
58: public int getStartOffset() {
59: return startOffset;
60: }
61:
62: public void setStartOffset(int startOffset) {
63: this .startOffset = startOffset;
64: }
65:
66: /**
67: * Two TermVectorOffsetInfos are equals if both the start and end offsets are the same
68: * @param o The comparison Object
69: * @return true if both {@link #getStartOffset()} and {@link #getEndOffset()} are the same for both objects.
70: */
71: public boolean equals(Object o) {
72: if (this == o)
73: return true;
74: if (!(o instanceof TermVectorOffsetInfo))
75: return false;
76:
77: final TermVectorOffsetInfo termVectorOffsetInfo = (TermVectorOffsetInfo) o;
78:
79: if (endOffset != termVectorOffsetInfo.endOffset)
80: return false;
81: if (startOffset != termVectorOffsetInfo.startOffset)
82: return false;
83:
84: return true;
85: }
86:
87: public int hashCode() {
88: int result;
89: result = startOffset;
90: result = 29 * result + endOffset;
91: return result;
92: }
93: }
|