2 * Copyright 2004-2005 The Apache Software Foundation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 namespace Lucene
.Net
.Analysis
22 /// <summary> Emits the entire input as a single token.</summary>
23 public class KeywordTokenizer
: Tokenizer
26 private const int DEFAULT_BUFFER_SIZE
= 256;
29 private char[] buffer
;
31 public KeywordTokenizer(System
.IO
.TextReader input
) : this(input
, DEFAULT_BUFFER_SIZE
)
35 public KeywordTokenizer(System
.IO
.TextReader input
, int bufferSize
) : base(input
)
37 this.buffer
= new char[bufferSize
];
41 public override Token
Next()
46 System
.Text
.StringBuilder buffer
= new System
.Text
.StringBuilder();
50 length
= input
.Read((System
.Char
[]) this.buffer
, 0, this.buffer
.Length
);
54 buffer
.Append(this.buffer
, 0, length
);
56 System
.String text
= buffer
.ToString();
57 return new Token(text
, 0, text
.Length
);