[monkeydoc] Merge/add monkeydoc to master.
[mono.git] / mcs / tools / monkeydoc / Lucene.Net / Lucene.Net / Index / TermVectorOffsetInfo.cs
1 /* 
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  * 
9  * http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 using System;
19
20 using System.Runtime.InteropServices;
21
22 namespace Mono.Lucene.Net.Index
23 {
24         
25         /// <summary> The TermVectorOffsetInfo class holds information pertaining to a Term in a {@link Mono.Lucene.Net.Index.TermPositionVector}'s
26         /// 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
27         /// original content).
28         /// </summary>
29         [Serializable]
30         public class TermVectorOffsetInfo
31         {
32                 /// <summary> Convenience declaration when creating a {@link Mono.Lucene.Net.Index.TermPositionVector} that stores only position information.</summary>
33                 [NonSerialized]
34                 public static readonly TermVectorOffsetInfo[] EMPTY_OFFSET_INFO = new TermVectorOffsetInfo[0];
35                 private int startOffset;
36                 private int endOffset;
37                 
38                 public TermVectorOffsetInfo()
39                 {
40                 }
41                 
42                 public TermVectorOffsetInfo(int startOffset, int endOffset)
43                 {
44                         this.endOffset = endOffset;
45                         this.startOffset = startOffset;
46                 }
47                 
48                 /// <summary> The accessor for the ending offset for the term</summary>
49                 /// <returns> The offset
50                 /// </returns>
51                 public virtual int GetEndOffset()
52                 {
53                         return endOffset;
54                 }
55                 
56                 public virtual void  SetEndOffset(int endOffset)
57                 {
58                         this.endOffset = endOffset;
59                 }
60                 
61                 /// <summary> The accessor for the starting offset of the term.
62                 /// 
63                 /// </summary>
64                 /// <returns> The offset
65                 /// </returns>
66                 public virtual int GetStartOffset()
67                 {
68                         return startOffset;
69                 }
70                 
71                 public virtual void  SetStartOffset(int startOffset)
72                 {
73                         this.startOffset = startOffset;
74                 }
75                 
76                 /// <summary> Two TermVectorOffsetInfos are equals if both the start and end offsets are the same</summary>
77                 /// <param name="o">The comparison Object
78                 /// </param>
79                 /// <returns> true if both {@link #GetStartOffset()} and {@link #GetEndOffset()} are the same for both objects.
80                 /// </returns>
81                 public  override bool Equals(System.Object o)
82                 {
83                         if (this == o)
84                                 return true;
85                         if (!(o is TermVectorOffsetInfo))
86                                 return false;
87                         
88                         TermVectorOffsetInfo termVectorOffsetInfo = (TermVectorOffsetInfo) o;
89                         
90                         if (endOffset != termVectorOffsetInfo.endOffset)
91                                 return false;
92                         if (startOffset != termVectorOffsetInfo.startOffset)
93                                 return false;
94                         
95                         return true;
96                 }
97                 
98                 public override int GetHashCode()
99                 {
100                         int result;
101                         result = startOffset;
102                         result = 29 * result + endOffset;
103                         return result;
104                 }
105         }
106 }