// ----------------------------------------------------------------------- // // // 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.Diagnostics.CodeAnalysis; using Lucene.Net.Util; /// /// TODO: update summary when Field, Document, TokenFilter, CachingTokenFilter, and IndexWriter have been created or ported. /// /// /// /// All subclasses of Token stream must seal /// /// [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix", Justification = "The name is valid even if it does not derived from Stream.")] public abstract class TokenStream : AttributeSource, IDisposable { //// TODO: create fxcop or nunit/mbunit tests that assert subclasses of TokenStream to seal constructors or IncrementToken(). //// https://cwiki.apache.org/confluence/display/LUCENENET/Lucene+Concepts /// /// Initializes a new instance of the class. /// protected TokenStream() { } /// /// Initializes a new instance of the class. /// /// The source. protected TokenStream(AttributeSource source) : base(source) { } /// /// Initializes a new instance of the class. /// /// The factory. protected TokenStream(AttributeFactory factory) : base(factory) { } /// /// Closes the . /// public virtual void Close() { } /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// public virtual void Dispose() { this.Dispose(true); } /// /// End invokes end-of-stream operations, such as setting the final offset of a stream. /// The default implementation does nothing. /// /// /// /// 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 virtual void End() { } /// /// Advances the stream to the next token. /// /// /// /// TODO: update remarks for IncrementToken when class summary is updated. /// /// /// An instance of . public abstract bool IncrementToken(); /// /// Resets this stream to the beginning. The default implementation does nothing. /// /// /// /// 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 virtual void Reset() { } /// /// Releases unmanaged and - optionally - managed resources /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources. protected virtual void Dispose(bool release) { this.Close(); } } }