lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r833560 - /incubator/lucene.net/tags/Lucene.Net_2_4_0/src/Demo/DemoLib/HTML/HTMLParser.cs
Date Fri, 06 Nov 2009 21:25:34 GMT
Author: digy
Date: Fri Nov  6 21:25:32 2009
New Revision: 833560

URL: http://svn.apache.org/viewvc?rev=833560&view=rev
Log:
LUCENENET-201 Bug in Demo for Lucene.Net 2.4.0

Modified:
    incubator/lucene.net/tags/Lucene.Net_2_4_0/src/Demo/DemoLib/HTML/HTMLParser.cs

Modified: incubator/lucene.net/tags/Lucene.Net_2_4_0/src/Demo/DemoLib/HTML/HTMLParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/tags/Lucene.Net_2_4_0/src/Demo/DemoLib/HTML/HTMLParser.cs?rev=833560&r1=833559&r2=833560&view=diff
==============================================================================
--- incubator/lucene.net/tags/Lucene.Net_2_4_0/src/Demo/DemoLib/HTML/HTMLParser.cs (original)
+++ incubator/lucene.net/tags/Lucene.Net_2_4_0/src/Demo/DemoLib/HTML/HTMLParser.cs Fri Nov
 6 21:25:32 2009
@@ -49,38 +49,51 @@
 		internal System.IO.StreamWriter pipeOut;
 		private MyPipedInputStream pipeInStream = null;
 		private System.IO.StreamWriter pipeOutStream = null;
-		
-		private class MyPipedInputStream : System.IO.StreamReader
-		{
-			private void  InitBlock(HTMLParser enclosingInstance)
-			{
-				this.enclosingInstance = enclosingInstance;
-			}
-			private HTMLParser enclosingInstance;
-			public HTMLParser Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			
-			//public MyPipedInputStream(HTMLParser enclosingInstance) : base()
-			//{
-			//	InitBlock(enclosingInstance);
-			//}
-			
-			public MyPipedInputStream(HTMLParser enclosingInstance, System.IO.StreamReader src) :
base(src.BaseStream)
-			{
-				InitBlock(enclosingInstance);
-			}
-			
-			public virtual bool Full()
-			{
-				return enclosingInstance.summaryComplete;
-			}
-		}
+
+        private class MyPipedInputStream : System.IO.MemoryStream
+        {
+            long _readPtr = 0;
+            long _writePtr = 0;
+
+            public System.IO.Stream BaseStream
+            {
+                get
+                {
+                    return this;
+                }
+            }
+
+            public override int Read(byte[] buffer, int offset, int count)
+            {
+                lock (this)
+                {
+                    base.Seek(_readPtr, System.IO.SeekOrigin.Begin);
+                    int x = base.Read(buffer, offset, count);
+                    _readPtr += x;
+                    return x;
+                }
+            }
+
+            public override void Write(byte[] buffer, int offset, int count)
+            {
+                lock (this)
+                {
+                    base.Seek(_writePtr, System.IO.SeekOrigin.Begin);
+                    base.Write(buffer, offset, count);
+                    _writePtr += count;
+                }
+            }
+
+            public override void Close()
+            {
+
+            }
+
+            public virtual bool Full()
+            {
+                return false;
+            }
+        }
 		
 		/// <deprecated> Use HTMLParser(FileInputStream) instead
 		/// </deprecated>
@@ -149,7 +162,7 @@
 		{
 			if (pipeIn == null)
 			{
-				pipeInStream = new MyPipedInputStream(this, new System.IO.StreamReader(new System.IO.MemoryStream(1024)));
+				pipeInStream = new MyPipedInputStream();
 				pipeOutStream = new System.IO.StreamWriter(pipeInStream.BaseStream);
 				pipeIn = new System.IO.StreamReader(pipeInStream.BaseStream, System.Text.Encoding.Default);
// GetEncoding("UTF-16BE"));
 				pipeOut = new System.IO.StreamWriter(pipeOutStream.BaseStream, System.Text.Encoding.Default);
// GetEncoding("UTF-16BE"));



Mime
View raw message