lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slomb...@apache.org
Subject [Lucene.Net] svn commit: r1145450 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g: src/core/Analysis/TeeSinkTokenFilter.cs test/core/Analysis/TestTeeSinkTokenFilter.cs
Date Tue, 12 Jul 2011 04:15:52 GMT
Author: slombard
Date: Tue Jul 12 04:15:52 2011
New Revision: 1145450

URL: http://svn.apache.org/viewvc?rev=1145450&view=rev
Log:
[LUCENENET-434] Removed Anonymous from TeeSinkTokenFilter class and updated the unit test

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Analysis/TeeSinkTokenFilter.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Analysis/TestTeeSinkTokenFilter.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Analysis/TeeSinkTokenFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Analysis/TeeSinkTokenFilter.cs?rev=1145450&r1=1145449&r2=1145450&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Analysis/TeeSinkTokenFilter.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Analysis/TeeSinkTokenFilter.cs
Tue Jul 12 04:15:52 2011
@@ -68,13 +68,7 @@ namespace Lucene.Net.Analysis
 	/// </summary>
 	public sealed class TeeSinkTokenFilter:TokenFilter
 	{
-		public class AnonymousClassSinkFilter:SinkFilter
-		{
-			public override bool Accept(AttributeSource source)
-			{
-				return true;
-			}
-		}
+
         private List<WeakReference> sinks = new List<WeakReference>();
 		
 		/// <summary> Instantiates a new TeeSinkTokenFilter.</summary>
@@ -171,15 +165,16 @@ namespace Lucene.Net.Analysis
 			}
 		}
 		
-		/// <summary> A filter that decides which {@link AttributeSource} states to store
in the sink.</summary>
-		public abstract class SinkFilter
+		/// <summary> A filter that decides which <see cref="AttributeSource"/> states
to store in the sink.</summary>
+		public class SinkFilter
 		{
-			/// <summary> Returns true, iff the current state of the passed-in {@link AttributeSource}
shall be stored
+
+			/// <summary> Returns true, if the current state of the passed-in <see cref="AttributeSource"/>
shall be stored
 			/// in the sink. 
 			/// </summary>
-			public abstract bool Accept(AttributeSource source);
+            public Func<AttributeSource, bool> Accept;
 			
-			/// <summary> Called by {@link SinkTokenStream#Reset()}. This method does nothing
by default
+			/// <summary> Called by <see cref="SinkTokenStream.Reset"/>. This method does
nothing by default
 			/// and can optionally be overridden.
 			/// </summary>
 			public void  Reset()
@@ -254,7 +249,8 @@ namespace Lucene.Net.Analysis
 		private static readonly SinkFilter ACCEPT_ALL_FILTER;
 		static TeeSinkTokenFilter()
 		{
-			ACCEPT_ALL_FILTER = new AnonymousClassSinkFilter();
+            ACCEPT_ALL_FILTER = new SinkFilter() 
+            { Accept = (a) => { return true; } };
 		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Analysis/TestTeeSinkTokenFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Analysis/TestTeeSinkTokenFilter.cs?rev=1145450&r1=1145449&r2=1145450&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Analysis/TestTeeSinkTokenFilter.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Analysis/TestTeeSinkTokenFilter.cs
Tue Jul 12 04:15:52 2011
@@ -33,22 +33,7 @@ namespace Lucene.Net.Analysis
     [TestFixture]
 	public class TestTeeSinkTokenFilter:BaseTokenStreamTestCase
 	{
-		public class AnonymousClassSinkFilter:TeeSinkTokenFilter.SinkFilter
-		{
-			public override bool Accept(AttributeSource a)
-			{
-				TermAttribute termAtt = (TermAttribute) a.GetAttribute(typeof(TermAttribute));
-				return termAtt.Term().ToUpper().Equals("The".ToUpper());
-			}
-		}
-		public class AnonymousClassSinkFilter1:TeeSinkTokenFilter.SinkFilter
-		{
-			public override bool Accept(AttributeSource a)
-			{
-				TermAttribute termAtt = (TermAttribute) a.GetAttribute(typeof(TermAttribute));
-				return termAtt.Term().ToUpper().Equals("Dogs".ToUpper());
-			}
-		}
+
 		protected internal System.Text.StringBuilder buffer1;
 		protected internal System.Text.StringBuilder buffer2;
 		protected internal System.String[] tokens1;
@@ -269,24 +254,42 @@ namespace Lucene.Net.Analysis
 			}
 			internal int count = 0;
 			internal int modCount;
-			
-			internal ModuloSinkFilter(TestTeeSinkTokenFilter enclosingInstance, int mc)
+
+            internal ModuloSinkFilter(TestTeeSinkTokenFilter enclosingInstance, int mc)
 			{
-				InitBlock(enclosingInstance);
+                Accept = (a) =>
+                {
+                    bool b = (a != null && count % modCount == 0);
+                    count++;
+                    return b;
+                };
+                InitBlock(enclosingInstance);
 				modCount = mc;
 			}
-			
-			public override bool Accept(AttributeSource a)
-			{
-				bool b = (a != null && count % modCount == 0);
-				count++;
-				return b;
-			}
+
 		}
 		static TestTeeSinkTokenFilter()
 		{
-			theFilter = new AnonymousClassSinkFilter();
-			dogFilter = new AnonymousClassSinkFilter1();
+		    theFilter = new TeeSinkTokenFilter.SinkFilter()
+		    {
+
+		        Accept = (a) =>
+		        {
+		            TermAttribute termAtt =
+		                (TermAttribute) a.GetAttribute(typeof (TermAttribute));
+		            return termAtt.Term().ToUpper().Equals("The".ToUpper());
+		        }
+		    };
+
+		    dogFilter = new TeeSinkTokenFilter.SinkFilter()
+		    {
+		        Accept = (a) =>
+		        {
+		            TermAttribute termAtt =
+		                (TermAttribute) a.GetAttribute(typeof (TermAttribute));
+		            return termAtt.Term().ToUpper().Equals("Dogs".ToUpper());
+		        }
+		    };
 		}
 	}
 }
\ No newline at end of file



Mime
View raw message