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
ITermAttribute.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 using Lucene.Net.Util;
20 
21 namespace Lucene.Net.Analysis.Tokenattributes
22 {
23 
24  /// <summary> The term text of a Token.</summary>
25  public interface ITermAttribute:IAttribute
26  {
27  /// <summary>Returns the Token's term text.
28  ///
29  /// This method has a performance penalty
30  /// because the text is stored internally in a char[]. If
31  /// possible, use <see cref="TermBuffer()" /> and <see cref="TermLength()" />
32  /// directly instead. If you really need a
33  /// String, use this method, which is nothing more than
34  /// a convenience call to <b>new String(token.termBuffer(), 0, token.termLength())</b>
35  /// </summary>
36  string Term { get; }
37 
38  /// <summary>Copies the contents of buffer, starting at offset for
39  /// length characters, into the termBuffer array.
40  /// </summary>
41  /// <param name="buffer">the buffer to copy
42  /// </param>
43  /// <param name="offset">the index in the buffer of the first character to copy
44  /// </param>
45  /// <param name="length">the number of characters to copy
46  /// </param>
47  void SetTermBuffer(char[] buffer, int offset, int length);
48 
49  /// <summary>Copies the contents of buffer into the termBuffer array.</summary>
50  /// <param name="buffer">the buffer to copy
51  /// </param>
52  void SetTermBuffer(System.String buffer);
53 
54  /// <summary>Copies the contents of buffer, starting at offset and continuing
55  /// for length characters, into the termBuffer array.
56  /// </summary>
57  /// <param name="buffer">the buffer to copy
58  /// </param>
59  /// <param name="offset">the index in the buffer of the first character to copy
60  /// </param>
61  /// <param name="length">the number of characters to copy
62  /// </param>
63  void SetTermBuffer(System.String buffer, int offset, int length);
64 
65  /// <summary>Returns the internal termBuffer character array which
66  /// you can then directly alter. If the array is too
67  /// small for your token, use <see cref="ResizeTermBuffer(int)" />
68  /// to increase it. After
69  /// altering the buffer be sure to call <see cref="SetTermLength" />
70  /// to record the number of valid
71  /// characters that were placed into the termBuffer.
72  /// </summary>
73  char[] TermBuffer();
74 
75  /// <summary>Grows the termBuffer to at least size newSize, preserving the
76  /// existing content. Note: If the next operation is to change
77  /// the contents of the term buffer use
78  /// <see cref="SetTermBuffer(char[], int, int)" />,
79  /// <see cref="SetTermBuffer(String)" />, or
80  /// <see cref="SetTermBuffer(String, int, int)" />
81  /// to optimally combine the resize with the setting of the termBuffer.
82  /// </summary>
83  /// <param name="newSize">minimum size of the new termBuffer
84  /// </param>
85  /// <returns> newly created termBuffer with length >= newSize
86  /// </returns>
87  char[] ResizeTermBuffer(int newSize);
88 
89  /// <summary>Return number of valid characters (length of the term)
90  /// in the termBuffer array.
91  /// </summary>
92  int TermLength();
93 
94  /// <summary>Set number of valid characters (length of the term) in
95  /// the termBuffer array. Use this to truncate the termBuffer
96  /// or to synchronize with external manipulation of the termBuffer.
97  /// Note: to grow the size of the array,
98  /// use <see cref="ResizeTermBuffer(int)" /> first.
99  /// </summary>
100  /// <param name="length">the truncated length
101  /// </param>
102  void SetTermLength(int length);
103  }
104 }