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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 namespace Mono.Lucene.Net.Index
23 /// <summary>Used by DocumentsWriter to implemented a StringReader
24 /// that can be reset to a new string; we use this when
25 /// tokenizing the string value from a Field.
27 sealed class ReusableStringReader : System.IO.TextReader
31 internal System.String s;
32 internal void Init(System.String s)
38 public int Read(char[] c)
40 return Read(c, 0, c.Length);
42 public override int Read(System.Char[] c, int off, int len)
46 SupportClass.TextSupport.GetCharsFromString(s, upto, upto + len, c, off);
58 SupportClass.TextSupport.GetCharsFromString(s, upto, upto + left, c, off);
65 public override void Close()
70 public override int Read()
82 public override int ReadBlock(char[] buffer, int index, int count)
84 return Read(buffer, index, count);
87 public override string ReadLine()
90 for (i = upto; i < s.Length; i++)
93 if (c == '\r' || c == '\n')
95 string result = s.Substring(upto, i - upto);
97 left = s.Length - upto;
98 if (c == '\r' && upto < s.Length && s[upto] == '\n')
113 public override int Peek()
122 public override string ReadToEnd()
124 string result = s.Substring(upto, left);