From lucene-net-commits-return-1508-apmail-lucene-lucene-net-commits-archive=lucene.apache.org@lucene.apache.org Mon Sep 5 18:54:31 2011 Return-Path: X-Original-To: apmail-lucene-lucene-net-commits-archive@www.apache.org Delivered-To: apmail-lucene-lucene-net-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BC50E8829 for ; Mon, 5 Sep 2011 18:54:31 +0000 (UTC) Received: (qmail 83191 invoked by uid 500); 5 Sep 2011 18:54:31 -0000 Delivered-To: apmail-lucene-lucene-net-commits-archive@lucene.apache.org Received: (qmail 83120 invoked by uid 500); 5 Sep 2011 18:54:31 -0000 Mailing-List: contact lucene-net-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucene.apache.org Delivered-To: mailing list lucene-net-commits@lucene.apache.org Received: (qmail 83113 invoked by uid 99); 5 Sep 2011 18:54:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Sep 2011 18:54:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Sep 2011 18:54:27 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id CE01323889E7; Mon, 5 Sep 2011 18:54:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Date: Mon, 05 Sep 2011 18:54:06 -0000 To: lucene-net-commits@lucene.apache.org From: mherndon@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110905185406.CE01323889E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Subject: [Lucene.Net] svn commit: r1165384 - /incubator/lucene.net/branches/Lucene.Net_4e/src/Lucene.Net/Analysis/TokenStream.cs Author: mherndon Date: Mon Sep 5 18:54:06 2011 New Revision: 1165384 URL: http://svn.apache.org/viewvc?rev=1165384&view=rev Log: adding the initial first pass at the abstract TokenStream class Modified: incubator/lucene.net/branches/Lucene.Net_4e/src/Lucene.Net/Analysis/TokenStream.cs Modified: incubator/lucene.net/branches/Lucene.Net_4e/src/Lucene.Net/Analysis/TokenStream.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_4e/src/Lucene.Net/Analysis/TokenStream.cs?rev=1165384&r1=1165383&r2=1165384&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_4e/src/Lucene.Net/Analysis/TokenStream.cs (original) +++ incubator/lucene.net/branches/Lucene.Net_4e/src/Lucene.Net/Analysis/TokenStream.cs Mon Sep 5 18:54:06 2011 @@ -21,15 +21,128 @@ namespace Lucene.Net.Analysis { + using System; using System.Diagnostics.CodeAnalysis; using Lucene.Net.Util; + /// - /// TODO: port + /// 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 class TokenStream : AttributeSource + 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(); + } } } \ No newline at end of file