Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
TermPositions.cs
Go to the documentation of this file.
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 namespace Lucene.Net.Index
21 {
22 
23  /// <summary> TermPositions provides an interface for enumerating the &lt;document,
24  /// frequency, &lt;position&gt;* &gt; tuples for a term. <p/> The document and
25  /// frequency are the same as for a TermDocs. The positions portion lists the ordinal
26  /// positions of each occurrence of a term in a document.
27  ///
28  /// </summary>
29  /// <seealso cref="IndexReader.TermPositions()">
30  /// </seealso>
31 
32  public interface TermPositions : TermDocs
33  {
34  /// <summary>Returns next position in the current document. It is an error to call
35  /// this more than <see cref="TermDocs.Freq()" /> times
36  /// without calling <see cref="TermDocs.Next()" /><p/> This is
37  /// invalid until <see cref="TermDocs.Next()" /> is called for
38  /// the first time.
39  /// </summary>
40  int NextPosition();
41 
42  /// <summary> Returns the length of the payload at the current term position.
43  /// This is invalid until <see cref="NextPosition()" /> is called for
44  /// the first time.<br/>
45  /// </summary>
46  /// <value> length of the current payload in number of bytes </value>
47  int PayloadLength { get; }
48 
49  /// <summary> Returns the payload data at the current term position.
50  /// This is invalid until <see cref="NextPosition()" /> is called for
51  /// the first time.
52  /// This method must not be called more than once after each call
53  /// of <see cref="NextPosition()" />. However, payloads are loaded lazily,
54  /// so if the payload data for the current position is not needed,
55  /// this method may not be called at all for performance reasons.<br/>
56  ///
57  /// </summary>
58  /// <param name="data">the array into which the data of this payload is to be
59  /// stored, if it is big enough; otherwise, a new byte[] array
60  /// is allocated for this purpose.
61  /// </param>
62  /// <param name="offset">the offset in the array into which the data of this payload
63  /// is to be stored.
64  /// </param>
65  /// <returns> a byte[] array containing the data of this payload
66  /// </returns>
67  /// <throws> IOException </throws>
68  byte[] GetPayload(byte[] data, int offset);
69 
70  /// <summary> Checks if a payload can be loaded at this position.
71  /// <p/>
72  /// Payloads can only be loaded once per call to
73  /// <see cref="NextPosition()" />.
74  ///
75  /// </summary>
76  /// <value> true if there is a payload available at this position that can be loaded </value>
77  bool IsPayloadAvailable { get; }
78  }
79 }