// ----------------------------------------------------------------------- // // // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // // ----------------------------------------------------------------------- namespace Lucene.Net.Analysis { using System; using System.Collections.Generic; using System.Linq; using System.Text; /// /// A TokenFilter is a that wraps an inner which /// serves as the input source for the stream. /// public abstract class TokenFilter : TokenStream { private readonly TokenStream tokenStream; /// /// Initializes a new instance of the class. /// /// The token stream. protected TokenFilter(TokenStream tokenStream) { this.tokenStream = tokenStream; } /// /// Gets the inner token stream which is the input source for this stream. /// /// The token stream. protected virtual TokenStream TokenStream { get { return this.tokenStream; } } /// /// Closes the . /// public override void Close() { this.TokenStream.Close(); } /// /// End invokes end-of-stream operations, such as setting the final offset of a stream. /// Calls on the inner /// /// /// /// This method is called by the consumer after the last token has been /// consumed. i.e. after returns false. /// /// /// This method can be used to perform any end-of-stream operations. /// An example would be setting the final offset of a stream. /// The final offset of a stream might differ from the offset of the last token. /// This could be in case one or more whitespaces followed after the last /// token, but a WhitespaceTokenizer was used. /// /// public override void End() { this.TokenStream.End(); } /// /// Resets this stream to the beginning. Calls on /// the . /// /// /// /// is not needed for the standard indexing /// process. However, if the tokens of are /// intended to be consumed more than once, it is necessary to /// implement . /// /// /// If a caches tokens and feeds them back again after a /// reset, it is imperative that you clone the tokens when you store them on the first pass. /// It is also imperative to clone the tokens when you return them on future passes after /// is invoked. /// /// public override void Reset() { this.TokenStream.Reset(); } } }