// ----------------------------------------------------------------------- // // TODO: Update copyright text. // // ----------------------------------------------------------------------- namespace Lucene.Net.Analysis { using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; /// /// is wrapper for that /// reads in char[] and outputs a . /// /// public sealed class CharReader : CharStream { /// /// Initializes a new instance of the class. /// /// The reader. private CharReader(StreamReader reader) : base(reader) { } /// /// Casts or creates a new CharReader /// /// The reader. /// /// An instance of . /// public static CharReader CastOrCreate(StreamReader reader) { if (reader is CharReader) return (CharReader)reader; return new CharReader(reader); } /// /// Corrects the offset. /// /// The offset for the output. /// /// The offset based on the input. /// /// /// /// fixes offsets to account for /// removal or insertion of characters, so that the offsets /// reported in the tokens match the character offsets of the /// original Reader. /// /// /// is generally invoked by Tokenizer classes /// and CharFilter classes. /// /// public override int CorrectOffset(int offset) { return offset; } /// /// When it is called by trusted applications, reads a maximum of characters from the current stream into , beginning at . /// /// When this method returns, contains the specified character array with the values between and (+ - 1) replaced by the characters read from the current source. /// The index of at which to begin writing. /// The maximum number of characters to read. /// /// The number of characters that have been read, or 0 if at the end of the stream and no data was read. The number will be less than or equal to the parameter, depending on whether the data is available within the stream. /// /// The buffer length minus is less than . /// /// is null. /// /// or is negative. /// An I/O error occurs, such as the stream is closed. public override int Read(char[] buffer, int index, int count) { return this.InnerReader.Read(buffer, index, count); } } }