lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r833562 - /incubator/lucene.net/trunk/C#/src/Demo/DemoLib/HTML/HTMLParser.cs
Date Fri, 06 Nov 2009 21:32:28 GMT
Author: digy
Date: Fri Nov  6 21:32:28 2009
New Revision: 833562

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

Modified:
    incubator/lucene.net/trunk/C#/src/Demo/DemoLib/HTML/HTMLParser.cs

Modified: incubator/lucene.net/trunk/C#/src/Demo/DemoLib/HTML/HTMLParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Demo/DemoLib/HTML/HTMLParser.cs?rev=833562&r1=833561&r2=833562&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Demo/DemoLib/HTML/HTMLParser.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Demo/DemoLib/HTML/HTMLParser.cs Fri Nov  6 21:32:28
2009
@@ -50,37 +50,50 @@
 		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(null)
-			//{
-			//	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.GetEncoding("UTF-16BE"));
 				pipeOut = new System.IO.StreamWriter(pipeOutStream.BaseStream, System.Text.Encoding.GetEncoding("UTF-16BE"));



Mime
View raw message