pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / src / java / org / apache / lucene / index / TermVectorOffsetInfo.java
1 package org.apache.lucene.index;
2
3 import java.io.Serializable;
4
5 /**
6  * Licensed to the Apache Software Foundation (ASF) under one or more
7  * contributor license agreements.  See the NOTICE file distributed with
8  * this work for additional information regarding copyright ownership.
9  * The ASF licenses this file to You under the Apache License, Version 2.0
10  * (the "License"); you may not use this file except in compliance with
11  * the License.  You may obtain a copy of the License at
12  *
13  *     http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 /**
23  * The TermVectorOffsetInfo class holds information pertaining to a Term in a {@link org.apache.lucene.index.TermPositionVector}'s
24  * 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
25  * original content).
26  */
27 public class TermVectorOffsetInfo implements Serializable {
28   /**
29    * Convenience declaration when creating a {@link org.apache.lucene.index.TermPositionVector} that stores only position information.
30    */
31   public transient static final TermVectorOffsetInfo[] EMPTY_OFFSET_INFO = new TermVectorOffsetInfo[0];
32   private int startOffset;
33   private int endOffset;
34
35   public TermVectorOffsetInfo() {
36   }
37
38   public TermVectorOffsetInfo(int startOffset, int endOffset) {
39     this.endOffset = endOffset;
40     this.startOffset = startOffset;
41   }
42
43   /**
44    * The accessor for the ending offset for the term
45    * @return The offset
46    */
47   public int getEndOffset() {
48     return endOffset;
49   }
50
51   public void setEndOffset(int endOffset) {
52     this.endOffset = endOffset;
53   }
54
55   /**
56    * The accessor for the starting offset of the term.
57    *
58    * @return The offset
59    */
60   public int getStartOffset() {
61     return startOffset;
62   }
63
64   public void setStartOffset(int startOffset) {
65     this.startOffset = startOffset;
66   }
67
68   /**
69    * Two TermVectorOffsetInfos are equals if both the start and end offsets are the same
70    * @param o The comparison Object
71    * @return true if both {@link #getStartOffset()} and {@link #getEndOffset()} are the same for both objects.
72    */
73   @Override
74   public boolean equals(Object o) {
75     if (this == o) return true;
76     if (!(o instanceof TermVectorOffsetInfo)) return false;
77
78     final TermVectorOffsetInfo termVectorOffsetInfo = (TermVectorOffsetInfo) o;
79
80     if (endOffset != termVectorOffsetInfo.endOffset) return false;
81     if (startOffset != termVectorOffsetInfo.startOffset) return false;
82
83     return true;
84   }
85
86   @Override
87   public int hashCode() {
88     int result;
89     result = startOffset;
90     result = 29 * result + endOffset;
91     return result;
92   }
93 }