lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccurr...@apache.org
Subject [Lucene.Net] svn commit: r1294875 [29/45] - in /incubator/lucene.net/trunk: ./ build/ build/vs2010/contrib/ build/vs2010/test/ doc/ src/ src/contrib/Analyzers/ src/contrib/Analyzers/AR/ src/contrib/Analyzers/BR/ src/contrib/Analyzers/CJK/ src/contrib/Analyzers/Cn/ ...
Date Tue, 28 Feb 2012 22:43:28 GMT
Modified: incubator/lucene.net/trunk/src/core/Search/TopFieldCollector.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/TopFieldCollector.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/TopFieldCollector.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/TopFieldCollector.cs Tue Feb 28 22:43:08 2012
@@ -16,9 +16,8 @@
  */
 
 using System;
-
+using Lucene.Net.Util;
 using IndexReader = Lucene.Net.Index.IndexReader;
-using PriorityQueue = Lucene.Net.Util.PriorityQueue;
 using Entry = Lucene.Net.Search.FieldValueHitQueue.Entry;
 
 namespace Lucene.Net.Search
@@ -33,21 +32,19 @@ namespace Lucene.Net.Search
 	/// <p/><b>NOTE:</b> This API is experimental and might change in
 	/// incompatible ways in the next release.<p/>
 	/// </summary>
-	public abstract class TopFieldCollector:TopDocsCollector
+	public abstract class TopFieldCollector : TopDocsCollector<Entry>
 	{
-		
 		// TODO: one optimization we could do is to pre-fill
 		// the queue with sentinel value that guaranteed to
 		// always compare lower than a real hit; this would
 		// save having to check queueFull on each insert
 		
-		/*
-		* Implements a TopFieldCollector over one SortField criteria, without
-		* tracking document scores and maxScore.
-		*/
-		private class OneComparatorNonScoringCollector:TopFieldCollector
+		//
+		// Implements a TopFieldCollector over one SortField criteria, without
+		// tracking document scores and maxScore.
+		//
+		private class OneComparatorNonScoringCollector : TopFieldCollector
 		{
-			
 			internal FieldComparator comparator;
 			internal int reverseMul;
 			
@@ -57,14 +54,14 @@ namespace Lucene.Net.Search
 				reverseMul = queue.GetReverseMul()[0];
 			}
 			
-			internal void  UpdateBottom(int doc)
+			internal void UpdateBottom(int doc)
 			{
 				// bottom.score is already set to Float.NaN in add().
-				bottom.docID = docBase + doc;
-				bottom = (Entry) pq.UpdateTop();
+				bottom.doc = docBase + doc;
+				bottom = pq.UpdateTop();
 			}
 			
-			public override void  Collect(int doc)
+			public override void Collect(int doc)
 			{
 				++totalHits;
 				if (queueFull)
@@ -96,23 +93,23 @@ namespace Lucene.Net.Search
 				}
 			}
 			
-			public override void  SetNextReader(IndexReader reader, int docBase)
+			public override void SetNextReader(IndexReader reader, int docBase)
 			{
 				this.docBase = docBase;
 				comparator.SetNextReader(reader, docBase);
 			}
 			
-			public override void  SetScorer(Scorer scorer)
+			public override void SetScorer(Scorer scorer)
 			{
 				comparator.SetScorer(scorer);
 			}
 		}
 		
-		/*
-		* Implements a TopFieldCollector over one SortField criteria, without
-		* tracking document scores and maxScore, and assumes out of orderness in doc
-		* Ids collection.
-		*/
+		//
+		// Implements a TopFieldCollector over one SortField criteria, without
+		// tracking document scores and maxScore, and assumes out of orderness in doc
+		// Ids collection.
+		//
 		private class OutOfOrderOneComparatorNonScoringCollector:OneComparatorNonScoringCollector
 		{
 			
@@ -120,14 +117,14 @@ namespace Lucene.Net.Search
 			{
 			}
 			
-			public override void  Collect(int doc)
+			public override void Collect(int doc)
 			{
 				++totalHits;
 				if (queueFull)
 				{
 					// Fastmatch: return if this hit is not competitive
 					int cmp = reverseMul * comparator.CompareBottom(doc);
-					if (cmp < 0 || (cmp == 0 && doc + docBase > bottom.docID))
+					if (cmp < 0 || (cmp == 0 && doc + docBase > bottom.doc))
 					{
 						return ;
 					}
@@ -161,7 +158,7 @@ namespace Lucene.Net.Search
 		* Implements a TopFieldCollector over one SortField criteria, while tracking
 		* document scores but no maxScore.
 		*/
-		private class OneComparatorScoringNoMaxScoreCollector:OneComparatorNonScoringCollector
+		private class OneComparatorScoringNoMaxScoreCollector : OneComparatorNonScoringCollector
 		{
 			
 			internal Scorer scorer;
@@ -170,14 +167,14 @@ namespace Lucene.Net.Search
 			{
 			}
 			
-			internal void  updateBottom(int doc, float score)
+			internal void UpdateBottom(int doc, float score)
 			{
-				bottom.docID = docBase + doc;
+				bottom.doc = docBase + doc;
 				bottom.score = score;
-				bottom = (Entry) pq.UpdateTop();
+				bottom = pq.UpdateTop();
 			}
 			
-			public override void  Collect(int doc)
+			public override void Collect(int doc)
 			{
 				++totalHits;
 				if (queueFull)
@@ -195,7 +192,7 @@ namespace Lucene.Net.Search
 					
 					// This hit is competitive - replace bottom element in queue & adjustTop
 					comparator.Copy(bottom.slot, doc);
-					updateBottom(doc, score);
+					UpdateBottom(doc, score);
 					comparator.SetBottom(bottom.slot);
 				}
 				else
@@ -227,7 +224,7 @@ namespace Lucene.Net.Search
 		* document scores but no maxScore, and assumes out of orderness in doc Ids
 		* collection.
 		*/
-		private class OutOfOrderOneComparatorScoringNoMaxScoreCollector:OneComparatorScoringNoMaxScoreCollector
+		private class OutOfOrderOneComparatorScoringNoMaxScoreCollector : OneComparatorScoringNoMaxScoreCollector
 		{
 			
 			public OutOfOrderOneComparatorScoringNoMaxScoreCollector(FieldValueHitQueue queue, int numHits, bool fillFields):base(queue, numHits, fillFields)
@@ -241,7 +238,7 @@ namespace Lucene.Net.Search
 				{
 					// Fastmatch: return if this hit is not competitive
 					int cmp = reverseMul * comparator.CompareBottom(doc);
-					if (cmp < 0 || (cmp == 0 && doc + docBase > bottom.docID))
+					if (cmp < 0 || (cmp == 0 && doc + docBase > bottom.doc))
 					{
 						return ;
 					}
@@ -251,7 +248,7 @@ namespace Lucene.Net.Search
 					
 					// This hit is competitive - replace bottom element in queue & adjustTop
 					comparator.Copy(bottom.slot, doc);
-					updateBottom(doc, score);
+					UpdateBottom(doc, score);
 					comparator.SetBottom(bottom.slot);
 				}
 				else
@@ -277,10 +274,10 @@ namespace Lucene.Net.Search
 			}
 		}
 		
-		/*
-		* Implements a TopFieldCollector over one SortField criteria, with tracking
-		* document scores and maxScore.
-		*/
+		//
+		// Implements a TopFieldCollector over one SortField criteria, with tracking
+		// document scores and maxScore.
+		//
 		private class OneComparatorScoringMaxScoreCollector:OneComparatorNonScoringCollector
 		{
 			
@@ -294,9 +291,9 @@ namespace Lucene.Net.Search
 			
 			internal void  UpdateBottom(int doc, float score)
 			{
-				bottom.docID = docBase + doc;
+				bottom.doc = docBase + doc;
 				bottom.score = score;
-				bottom = (Entry) pq.UpdateTop();
+				bottom = pq.UpdateTop();
 			}
 			
 			public override void  Collect(int doc)
@@ -343,12 +340,12 @@ namespace Lucene.Net.Search
 			}
 		}
 		
-		/*
-		* Implements a TopFieldCollector over one SortField criteria, with tracking
-		* document scores and maxScore, and assumes out of orderness in doc Ids
-		* collection.
-		*/
-		private class OutOfOrderOneComparatorScoringMaxScoreCollector:OneComparatorScoringMaxScoreCollector
+		//
+		// Implements a TopFieldCollector over one SortField criteria, with tracking
+		// document scores and maxScore, and assumes out of orderness in doc Ids
+		// collection.
+		//
+		private class OutOfOrderOneComparatorScoringMaxScoreCollector : OneComparatorScoringMaxScoreCollector
 		{
 			
 			public OutOfOrderOneComparatorScoringMaxScoreCollector(FieldValueHitQueue queue, int numHits, bool fillFields):base(queue, numHits, fillFields)
@@ -367,7 +364,7 @@ namespace Lucene.Net.Search
 				{
 					// Fastmatch: return if this hit is not competitive
 					int cmp = reverseMul * comparator.CompareBottom(doc);
-					if (cmp < 0 || (cmp == 0 && doc + docBase > bottom.docID))
+					if (cmp < 0 || (cmp == 0 && doc + docBase > bottom.doc))
 					{
 						return ;
 					}
@@ -403,7 +400,6 @@ namespace Lucene.Net.Search
 		*/
 		private class MultiComparatorNonScoringCollector:TopFieldCollector
 		{
-			
 			internal FieldComparator[] comparators;
 			internal int[] reverseMul;
 			
@@ -416,8 +412,8 @@ namespace Lucene.Net.Search
 			internal void  UpdateBottom(int doc)
 			{
 				// bottom.score is already set to Float.NaN in add().
-				bottom.docID = docBase + doc;
-				bottom = (Entry) pq.UpdateTop();
+				bottom.doc = docBase + doc;
+				bottom = pq.UpdateTop();
 			}
 			
 			public override void  Collect(int doc)
@@ -534,7 +530,7 @@ namespace Lucene.Net.Search
 						else if (i == comparators.Length - 1)
 						{
 							// This is the equals case.
-							if (doc + docBase > bottom.docID)
+							if (doc + docBase > bottom.doc)
 							{
 								// Definitely not competitive
 								return ;
@@ -586,7 +582,7 @@ namespace Lucene.Net.Search
 		* Implements a TopFieldCollector over multiple SortField criteria, with
 		* tracking document scores and maxScore.
 		*/
-		private class MultiComparatorScoringMaxScoreCollector:MultiComparatorNonScoringCollector
+		private class MultiComparatorScoringMaxScoreCollector : MultiComparatorNonScoringCollector
 		{
 			
 			internal Scorer scorer;
@@ -599,9 +595,9 @@ namespace Lucene.Net.Search
 			
 			internal void  UpdateBottom(int doc, float score)
 			{
-				bottom.docID = docBase + doc;
+				bottom.doc = docBase + doc;
 				bottom.score = score;
-				bottom = (Entry) pq.UpdateTop();
+				bottom = pq.UpdateTop();
 			}
 			
 			public override void  Collect(int doc)
@@ -716,7 +712,7 @@ namespace Lucene.Net.Search
 						else if (i == comparators.Length - 1)
 						{
 							// This is the equals case.
-							if (doc + docBase > bottom.docID)
+							if (doc + docBase > bottom.doc)
 							{
 								// Definitely not competitive
 								return ;
@@ -779,9 +775,9 @@ namespace Lucene.Net.Search
 			
 			internal void  UpdateBottom(int doc, float score)
 			{
-				bottom.docID = docBase + doc;
+				bottom.doc = docBase + doc;
 				bottom.score = score;
-				bottom = (Entry) pq.UpdateTop();
+				bottom = pq.UpdateTop();
 			}
 			
 			public override void  Collect(int doc)
@@ -891,7 +887,7 @@ namespace Lucene.Net.Search
 						else if (i == comparators.Length - 1)
 						{
 							// This is the equals case.
-							if (doc + docBase > bottom.docID)
+							if (doc + docBase > bottom.doc)
 							{
 								// Definitely not competitive
 								return ;
@@ -970,7 +966,8 @@ namespace Lucene.Net.Search
 		// internal versions. If someone will define a constructor with any other
 		// visibility, then anyone will be able to extend the class, which is not what
 		// we want.
-		private TopFieldCollector(PriorityQueue pq, int numHits, bool fillFields):base(pq)
+		private TopFieldCollector(PriorityQueue<Entry> pq, int numHits, bool fillFields)
+            : base(pq)
 		{
 			this.numHits = numHits;
 			this.fillFields = fillFields;
@@ -1089,7 +1086,7 @@ namespace Lucene.Net.Search
 		
 		internal void  Add(int slot, int doc, float score)
 		{
-			bottom = (Entry) pq.Add(new Entry(slot, docBase + doc, score));
+			bottom = pq.Add(new Entry(slot, docBase + doc, score));
 			queueFull = totalHits == numHits;
 		}
 		
@@ -1106,15 +1103,15 @@ namespace Lucene.Net.Search
 				FieldValueHitQueue queue = (FieldValueHitQueue) pq;
 				for (int i = howMany - 1; i >= 0; i--)
 				{
-					results[i] = queue.FillFields((Entry) queue.Pop());
+					results[i] = queue.FillFields(queue.Pop());
 				}
 			}
 			else
 			{
 				for (int i = howMany - 1; i >= 0; i--)
 				{
-					Entry entry = (Entry) pq.Pop();
-					results[i] = new FieldDoc(entry.docID, entry.score);
+					Entry entry = pq.Pop();
+					results[i] = new FieldDoc(entry.doc, entry.score);
 				}
 			}
 		}

Modified: incubator/lucene.net/trunk/src/core/Search/TopScoreDocCollector.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/TopScoreDocCollector.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/TopScoreDocCollector.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/TopScoreDocCollector.cs Tue Feb 28 22:43:08 2012
@@ -34,7 +34,7 @@ namespace Lucene.Net.Search
     /// collector will not properly collect hits with such
     /// scores.
 	/// </summary>
-	public abstract class TopScoreDocCollector:TopDocsCollector
+	public abstract class TopScoreDocCollector : TopDocsCollector<ScoreDoc>
 	{
 		
 		// Assumes docs are scored in order.
@@ -62,7 +62,7 @@ namespace Lucene.Net.Search
 				}
 				pqTop.doc = doc + docBase;
 				pqTop.score = score;
-				pqTop = (ScoreDoc) pq.UpdateTop();
+				pqTop = pq.UpdateTop();
 			}
 			
 			public override bool AcceptsDocsOutOfOrder()
@@ -93,7 +93,7 @@ namespace Lucene.Net.Search
 				}
 				pqTop.doc = doc;
 				pqTop.score = score;
-				pqTop = (ScoreDoc) pq.UpdateTop();
+				pqTop = pq.UpdateTop();
 			}
 			
 			public override bool AcceptsDocsOutOfOrder()
@@ -133,7 +133,7 @@ namespace Lucene.Net.Search
 		{
 			// HitQueue implements getSentinelObject to return a ScoreDoc, so we know
 			// that at this point top() is already initialized.
-			pqTop = (ScoreDoc) pq.Top();
+			pqTop = pq.Top();
 		}
 		
 		public /*protected internal*/ override TopDocs NewTopDocs(ScoreDoc[] results, int start)
@@ -158,7 +158,7 @@ namespace Lucene.Net.Search
 				{
 					pq.Pop();
 				}
-				maxScore = ((ScoreDoc) pq.Pop()).score;
+				maxScore = pq.Pop().score;
 			}
 			
 			return new TopDocs(totalHits, results, maxScore);

Modified: incubator/lucene.net/trunk/src/core/Search/WildcardQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/WildcardQuery.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/WildcardQuery.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/WildcardQuery.cs Tue Feb 28 22:43:08 2012
@@ -39,35 +39,55 @@ namespace Lucene.Net.Search
 	/// <seealso cref="WildcardTermEnum">
 	/// </seealso>
 	[Serializable]
-	public class WildcardQuery:MultiTermQuery
+	public class WildcardQuery : MultiTermQuery
 	{
 		private bool termContainsWildcard;
-		new protected internal Term term;
+	    private bool termIsPrefix;
+		protected internal Term term;
 		
-		public WildcardQuery(Term term):base(term)
-		{ //will be removed in 3.0
+		public WildcardQuery(Term term)
+		{ 
 			this.term = term;
-			this.termContainsWildcard = (term.Text().IndexOf('*') != - 1) || (term.Text().IndexOf('?') != - 1);
+		    string text = term.Text();
+		    this.termContainsWildcard = (term.Text().IndexOf('*') != -1)
+		                                || (term.Text().IndexOf('?') != -1);
+		    this.termIsPrefix = termContainsWildcard
+		                        && (text.IndexOf('?') == -1)
+		                        && (text.IndexOf('*') == text.Length - 1);
 		}
 		
 		public /*protected internal*/ override FilteredTermEnum GetEnum(IndexReader reader)
 		{
-			return new WildcardTermEnum(reader, GetTerm());
+            if (termContainsWildcard)
+            {
+                return new WildcardTermEnum(reader, GetTerm());
+            }
+            else
+            {
+                return new SingleTermEnum(reader, GetTerm());
+            }
 		}
 		
 		/// <summary> Returns the pattern term.</summary>
-        [Obsolete("Lucene.Net-2.9.1. This method overrides obsolete member Lucene.Net.Search.MultiTermQuery.GetTerm()")]
-		public override Term GetTerm()
+		public Term GetTerm()
 		{
 			return term;
 		}
 		
 		public override Query Rewrite(IndexReader reader)
 		{
-			if (!termContainsWildcard)
-				return new TermQuery(GetTerm());
-			else
-				return base.Rewrite(reader);
+            if (termIsPrefix)
+            {
+                MultiTermQuery rewritten =
+                    new PrefixQuery(term.CreateTerm(term.text.Substring(0, term.text.IndexOf('*'))));
+                rewritten.SetBoost(GetBoost());
+                rewritten.SetRewriteMethod(GetRewriteMethod());
+                return rewritten;
+            }
+            else
+            {
+                return base.Rewrite(reader);
+            }
 		}
 		
 		/// <summary>Prints a user-readable version of this query. </summary>

Modified: incubator/lucene.net/trunk/src/core/Search/WildcardTermEnum.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/WildcardTermEnum.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/WildcardTermEnum.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/WildcardTermEnum.cs Tue Feb 28 22:43:08 2012
@@ -28,11 +28,8 @@ namespace Lucene.Net.Search
 	/// <p/>
 	/// Term enumerations are always ordered by Term.compareTo().  Each term in
 	/// the enumeration is greater than all that precede it.
-	/// 
 	/// </summary>
-	/// <version>  $Id: WildcardTermEnum.java 783371 2009-06-10 14:39:56Z mikemccand $
-	/// </version>
-	public class WildcardTermEnum:FilteredTermEnum
+	public class WildcardTermEnum : FilteredTermEnum
 	{
 		internal Term searchTerm;
 		internal System.String field;

Modified: incubator/lucene.net/trunk/src/core/Store/AlreadyClosedException.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/AlreadyClosedException.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Store/AlreadyClosedException.cs (original)
+++ incubator/lucene.net/trunk/src/core/Store/AlreadyClosedException.cs Tue Feb 28 22:43:08 2012
@@ -20,19 +20,28 @@ using System.Runtime.Serialization;
 
 namespace Lucene.Net.Store
 {
-	
-	/// <summary> This exception is thrown when there is an attempt to
-	/// access something that has already been closed.
-	/// </summary>
-	[Serializable]
-	public class AlreadyClosedException:System.SystemException
-	{
-		public AlreadyClosedException(System.String message):base(message)
-		{
-		}
+    /// <summary> This exception is thrown when there is an attempt to
+    /// access something that has already been closed.
+    /// </summary>
+    [Serializable]
+    public class AlreadyClosedException : SystemException
+    {
+        public AlreadyClosedException()
+        {
+        }
+
+        public AlreadyClosedException(string message) : base(message)
+        {
+        }
+
+        public AlreadyClosedException(string message, Exception inner) : base(message, inner)
+        {
+        }
 
-        protected AlreadyClosedException(SerializationInfo info, StreamingContext context) : base(info, context)
+        protected AlreadyClosedException(
+            SerializationInfo info,
+            StreamingContext context) : base(info, context)
         {
         }
-	}
+    }
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Store/BufferedIndexInput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/BufferedIndexInput.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Store/BufferedIndexInput.cs (original)
+++ incubator/lucene.net/trunk/src/core/Store/BufferedIndexInput.cs Tue Feb 28 22:43:08 2012
@@ -21,13 +21,13 @@ namespace Lucene.Net.Store
 {
 	
 	/// <summary>Base implementation class for buffered <see cref="IndexInput" />. </summary>
-	public abstract class BufferedIndexInput:IndexInput, System.ICloneable
+	public abstract class BufferedIndexInput : IndexInput, System.ICloneable
 	{
 		
 		/// <summary>Default buffer size </summary>
 		public const int BUFFER_SIZE = 1024;
 		
-		private int bufferSize = BUFFER_SIZE;
+		private int _bufferSize = BUFFER_SIZE;
 		
 		protected internal byte[] buffer;
 		
@@ -41,26 +41,26 @@ namespace Lucene.Net.Store
 				Refill();
 			return buffer[bufferPosition++];
 		}
-		
-		public BufferedIndexInput()
+
+	    protected BufferedIndexInput()
 		{
 		}
 		
 		/// <summary>Inits BufferedIndexInput with a specific bufferSize </summary>
-		public BufferedIndexInput(int bufferSize)
+		protected BufferedIndexInput(int bufferSize)
 		{
 			CheckBufferSize(bufferSize);
-			this.bufferSize = bufferSize;
+			this._bufferSize = bufferSize;
 		}
 		
 		/// <summary>Change the buffer size used by this IndexInput </summary>
 		public virtual void  SetBufferSize(int newSize)
 		{
-			System.Diagnostics.Debug.Assert(buffer == null || bufferSize == buffer.Length, "buffer=" + buffer + " bufferSize=" + bufferSize + " buffer.length=" +(buffer != null ? buffer.Length: 0));
-			if (newSize != bufferSize)
+			System.Diagnostics.Debug.Assert(buffer == null || _bufferSize == buffer.Length, "buffer=" + buffer + " bufferSize=" + _bufferSize + " buffer.length=" +(buffer != null ? buffer.Length: 0));
+			if (newSize != _bufferSize)
 			{
 				CheckBufferSize(newSize);
-				bufferSize = newSize;
+				_bufferSize = newSize;
 				if (buffer != null)
 				{
 					// Resize the existing buffer and carefully save as
@@ -87,15 +87,23 @@ namespace Lucene.Net.Store
 			// Subclasses can do something here
 			buffer = newBuffer;
 		}
-		
-		/// <seealso cref="SetBufferSize">
-		/// </seealso>
-		public virtual int GetBufferSize()
-		{
-			return bufferSize;
-		}
-		
-		private void  CheckBufferSize(int bufferSize)
+
+	    /// <seealso cref="SetBufferSize">
+	    /// </seealso>
+	    public virtual int BufferSize
+	    {
+	        get { return _bufferSize; }
+	    }
+        
+        /// <seealso cref="SetBufferSize">
+        /// </seealso>
+        [Obsolete("Use BufferSize property instead.")]
+        public virtual int GetBufferSize()
+        {
+            return BufferSize;
+        }
+
+	    private void  CheckBufferSize(int bufferSize)
 		{
 			if (bufferSize <= 0)
 				throw new System.ArgumentException("bufferSize must be greater than 0 (got " + bufferSize + ")");
@@ -129,7 +137,7 @@ namespace Lucene.Net.Store
 					bufferPosition += available;
 				}
 				// and now, read the remaining 'len' bytes:
-				if (useBuffer && len < bufferSize)
+				if (useBuffer && len < _bufferSize)
 				{
 					// If the amount left to read is small enough, and
 					// we are allowed to use our buffer, do it in the usual
@@ -170,7 +178,7 @@ namespace Lucene.Net.Store
 		private void  Refill()
 		{
 			long start = bufferStart + bufferPosition;
-			long end = start + bufferSize;
+			long end = start + _bufferSize;
 			if (end > Length())
 			// don't read past EOF
 				end = Length();
@@ -180,7 +188,7 @@ namespace Lucene.Net.Store
 			
 			if (buffer == null)
 			{
-				NewBuffer(new byte[bufferSize]); // allocate buffer lazily
+				NewBuffer(new byte[_bufferSize]); // allocate buffer lazily
 				SeekInternal(bufferStart);
 			}
 			ReadInternal(buffer, 0, newLength);

Modified: incubator/lucene.net/trunk/src/core/Store/BufferedIndexOutput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/BufferedIndexOutput.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Store/BufferedIndexOutput.cs (original)
+++ incubator/lucene.net/trunk/src/core/Store/BufferedIndexOutput.cs Tue Feb 28 22:43:08 2012
@@ -28,6 +28,8 @@ namespace Lucene.Net.Store
 		private byte[] buffer = new byte[BUFFER_SIZE];
 		private long bufferStart = 0; // position in file of buffer
 		private int bufferPosition = 0; // position in buffer
+
+	    private bool isDisposed;
 		
 		/// <summary>Writes a single byte.</summary>
 		/// <seealso cref="IndexInput.ReadByte()">
@@ -126,10 +128,17 @@ namespace Lucene.Net.Store
 		public abstract void  FlushBuffer(byte[] b, int offset, int len);
 		
 		/// <summary>Closes this stream to further operations. </summary>
-		public override void  Close()
-		{
-			Flush();
-		}
+        protected override void Dispose(bool disposing)
+        {
+            if (isDisposed) return;
+
+            if (disposing)
+            {
+                Flush();
+            }
+
+		    isDisposed = true;
+        }
 		
 		/// <summary>Returns the current position in this file, where the next write will
 		/// occur.

Modified: incubator/lucene.net/trunk/src/core/Store/CheckSumIndexInput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/CheckSumIndexInput.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Store/CheckSumIndexInput.cs (original)
+++ incubator/lucene.net/trunk/src/core/Store/CheckSumIndexInput.cs Tue Feb 28 22:43:08 2012
@@ -16,6 +16,7 @@
  */
 
 using System;
+using Lucene.Net.Support;
 
 namespace Lucene.Net.Store
 {
@@ -23,15 +24,17 @@ namespace Lucene.Net.Store
 	/// <summary>Writes bytes through to a primary IndexOutput, computing
 	/// checksum as it goes. Note that you cannot use seek(). 
 	/// </summary>
-	public class ChecksumIndexInput:IndexInput
+	public class ChecksumIndexInput : IndexInput
 	{
 		internal IndexInput main;
-		internal SupportClass.Checksum digest;
+		internal IChecksum digest;
+
+	    private bool isDisposed;
 		
 		public ChecksumIndexInput(IndexInput main)
 		{
 			this.main = main;
-            digest = new SupportClass.CRC32();
+            digest = new CRC32();
 		}
 		
 		public override byte ReadByte()
@@ -46,17 +49,33 @@ namespace Lucene.Net.Store
 			main.ReadBytes(b, offset, len);
 			digest.Update(b, offset, len);
 		}
-		
-		
-		public virtual long GetChecksum()
-		{
-			return digest.GetValue();
-		}
-		
-		public override void  Close()
-		{
-			main.Close();
-		}
+
+	    public virtual long Checksum
+	    {
+	        get { return digest.Value; }
+	    }
+
+        [Obsolete("Use Checksum property instead")]
+        public virtual long GetChecksum()
+        {
+            return Checksum;
+        }
+
+	    protected override void Dispose(bool disposing)
+        {
+            if (isDisposed) return;
+
+            if (disposing)
+            {
+                if (main != null)
+                {
+                    main.Dispose();
+                }
+            }
+
+            main = null;
+            isDisposed = true;
+        }
 		
 		public override long GetFilePointer()
 		{
@@ -72,12 +91,5 @@ namespace Lucene.Net.Store
 		{
 			return main.Length();
 		}
-
-        /*
-		override public System.Object Clone()
-		{
-			return null;
-		}
-        */
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Store/CheckSumIndexOutput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/CheckSumIndexOutput.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Store/CheckSumIndexOutput.cs (original)
+++ incubator/lucene.net/trunk/src/core/Store/CheckSumIndexOutput.cs Tue Feb 28 22:43:08 2012
@@ -16,9 +16,8 @@
  */
 
 using System;
-
-using Checksum = SupportClass.Checksum;
-using CRC32 = SupportClass.CRC32;
+using Lucene.Net.Support;
+using CRC32 = Lucene.Net.Support.CRC32;
 
 namespace Lucene.Net.Store
 {
@@ -29,7 +28,9 @@ namespace Lucene.Net.Store
 	public class ChecksumIndexOutput:IndexOutput
 	{
 		internal IndexOutput main;
-		internal Checksum digest;
+		internal IChecksum digest;
+
+	    private bool isDisposed;
 		
 		public ChecksumIndexOutput(IndexOutput main)
 		{
@@ -48,21 +49,34 @@ namespace Lucene.Net.Store
 			digest.Update(b, offset, length);
 			main.WriteBytes(b, offset, length);
 		}
-		
-		public virtual long GetChecksum()
-		{
-			return digest.GetValue();
-		}
-		
-		public override void  Flush()
+
+	    public virtual long Checksum
+	    {
+	        get { return digest.GetValue(); }
+	    }
+
+        [Obsolete("Use Checksum property instead")]
+        public virtual long GetChecksum()
+        {
+            return Checksum;
+        }
+
+	    public override void  Flush()
 		{
 			main.Flush();
 		}
-		
-		public override void  Close()
-		{
-			main.Close();
-		}
+
+        protected override void Dispose(bool disposing)
+        {
+            if (isDisposed) return;
+
+            if (disposing)
+            {
+                main.Close();
+            }
+
+            isDisposed = true;
+        }
 		
 		public override long GetFilePointer()
 		{
@@ -81,7 +95,7 @@ namespace Lucene.Net.Store
 		/// </summary>
 		public virtual void  PrepareCommit()
 		{
-			long checksum = GetChecksum();
+			long checksum = Checksum;
 			// Intentionally write a mismatched checksum.  This is
 			// because we want to 1) test, as best we can, that we
 			// are able to write a long to the file, but 2) not
@@ -96,7 +110,7 @@ namespace Lucene.Net.Store
 		/// <summary>See <see cref="PrepareCommit" /> </summary>
 		public virtual void  FinishCommit()
 		{
-			main.WriteLong(GetChecksum());
+			main.WriteLong(Checksum);
 		}
 		
 		public override long Length()

Modified: incubator/lucene.net/trunk/src/core/Store/Directory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/Directory.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Store/Directory.cs (original)
+++ incubator/lucene.net/trunk/src/core/Store/Directory.cs Tue Feb 28 22:43:08 2012
@@ -48,30 +48,10 @@ namespace Lucene.Net.Store
 		/// </summary>
 		[NonSerialized]
 		protected internal LockFactory lockFactory;
-		
-		/// <deprecated> For some Directory implementations (<see cref="FSDirectory" />
-		///, and its subclasses), this method
-		/// silently filters its results to include only index
-		/// files.  Please use <see cref="ListAll" /> instead, which
-		/// does no filtering. 
-		/// </deprecated>
-        [Obsolete("For some Directory implementations (FSDirectory}, and its subclasses), this method silently filters its results to include only index files.  Please use ListAll instead, which does no filtering. ")]
-		public abstract System.String[] List();
-		
-		/// <summary>Returns an array of strings, one for each file in the
-		/// directory.  Unlike <see cref="List" /> this method does no
-		/// filtering of the contents in a directory, and it will
-		/// never return null (throws IOException instead).
-		/// 
-		/// Currently this method simply fallsback to <see cref="List" />
-		/// for Directory impls outside of Lucene's core &amp;
-		/// contrib, but in 3.0 that method will be removed and
-		/// this method will become abstract. 
-		/// </summary>
-		public virtual System.String[] ListAll()
-		{
-			return List();
-		}
+
+	    /// <summary>Returns an array of strings, one for each file in the directory.</summary>
+	    /// <exception cref="System.IO.IOException"></exception>
+	    public abstract System.String[] ListAll();
 		
 		/// <summary>Returns true iff a file with the given name exists. </summary>
 		public abstract bool FileExists(System.String name);
@@ -85,15 +65,6 @@ namespace Lucene.Net.Store
 		/// <summary>Removes an existing file in the directory. </summary>
 		public abstract void  DeleteFile(System.String name);
 		
-		/// <summary>Renames an existing file in the directory.
-		/// If a file already exists with the new name, then it is replaced.
-		/// This replacement is not guaranteed to be atomic.
-		/// </summary>
-		/// <deprecated> 
-		/// </deprecated>
-        [Obsolete]
-		public abstract void  RenameFile(System.String from, System.String to);
-		
 		/// <summary>Returns the length of a file in the directory. </summary>
 		public abstract long FileLength(System.String name);
 		
@@ -148,12 +119,21 @@ namespace Lucene.Net.Store
 			}
 		}
 		
-		/// <summary>Closes the store. </summary>
-		public abstract void  Close();
+		[Obsolete("Use Dispose() instead")]
+		public void Close()
+		{
+		    Dispose();
+		}
 
-        public abstract void Dispose();
-		
-		/// <summary> Set the LockFactory that this Directory instance should
+        /// <summary>Closes the store. </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+
+	    protected abstract void Dispose(bool disposing);
+
+	    /// <summary> Set the LockFactory that this Directory instance should
 		/// use for its locking implementation.  Each * instance of
 		/// LockFactory should only be used for one directory (ie,
 		/// do not share a single instance across multiple
@@ -164,8 +144,9 @@ namespace Lucene.Net.Store
 		/// </param>
 		public virtual void  SetLockFactory(LockFactory lockFactory)
 		{
+		    System.Diagnostics.Debug.Assert(lockFactory != null);
 			this.lockFactory = lockFactory;
-			lockFactory.SetLockPrefix(this.GetLockID());
+			lockFactory.SetLockPrefix(this.LockId);
 		}
 		
 		/// <summary> Get the LockFactory that this Directory instance is
@@ -177,20 +158,33 @@ namespace Lucene.Net.Store
 		{
 			return this.lockFactory;
 		}
-		
-		/// <summary> Return a string identifier that uniquely differentiates
-		/// this Directory instance from other Directory instances.
-		/// This ID should be the same if two Directory instances
-		/// (even in different JVMs and/or on different machines)
-		/// are considered "the same index".  This is how locking
-		/// "scopes" to the right index.
-		/// </summary>
-		public virtual System.String GetLockID()
-		{
-			return this.ToString();
-		}
 
-        public override string ToString()
+	    /// <summary> Return a string identifier that uniquely differentiates
+	    /// this Directory instance from other Directory instances.
+	    /// This ID should be the same if two Directory instances
+	    /// (even in different JVMs and/or on different machines)
+	    /// are considered "the same index".  This is how locking
+	    /// "scopes" to the right index.
+	    /// </summary>
+	    public virtual string LockId
+	    {
+	        get { return ToString(); }
+	    }
+
+        /// <summary> Return a string identifier that uniquely differentiates
+        /// this Directory instance from other Directory instances.
+        /// This ID should be the same if two Directory instances
+        /// (even in different JVMs and/or on different machines)
+        /// are considered "the same index".  This is how locking
+        /// "scopes" to the right index.
+        /// </summary>
+        [Obsolete("Use LockId property instead.")]
+        public virtual System.String GetLockID()
+        {
+            return ToString();
+        }
+
+	    public override string ToString()
         {
             return base.ToString() + " lockFactory=" + GetLockFactory();
         }

Modified: incubator/lucene.net/trunk/src/core/Store/FSDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/FSDirectory.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Store/FSDirectory.cs (original)
+++ incubator/lucene.net/trunk/src/core/Store/FSDirectory.cs Tue Feb 28 22:43:08 2012
@@ -19,6 +19,7 @@ using System;
 using System.Collections.Generic;
 
 // Used only for WRITE_LOCK_NAME in deprecated create=true case:
+using Lucene.Net.Support;
 using IndexFileNameFilter = Lucene.Net.Index.IndexFileNameFilter;
 using IndexWriter = Lucene.Net.Index.IndexWriter;
 using Constants = Lucene.Net.Util.Constants;
@@ -98,333 +99,23 @@ namespace Lucene.Net.Store
 	/// <p/>The locking implementation is by default <see cref="NativeFSLockFactory" />
 	///, but can be changed by
 	/// passing in a custom <see cref="LockFactory" /> instance.
-	/// The deprecated <c>getDirectory</c> methods default to use
-	/// <see cref="SimpleFSLockFactory" /> for backwards compatibility.
-	/// The system properties 
-	/// <c>org.apache.lucene.store.FSDirectoryLockFactoryClass</c>
-	/// and <c>org.apache.lucene.FSDirectory.class</c>
-	/// are deprecated and only used by the deprecated
-	/// <c>getDirectory</c> methods. The system property
-	/// <c>org.apache.lucene.lockDir</c> is ignored completely,
-	/// If you really want to store locks
-	/// elsewhere, you can create your own <see cref="SimpleFSLockFactory" />
-	/// (or <see cref="NativeFSLockFactory" />,
-	/// etc.) passing in your preferred lock directory.
-	/// 
-	/// <p/><em>In 3.0 this class will become abstract.</em>
-	/// 
 	/// </summary>
-	/// <seealso cref="Directory">
-	/// </seealso>
-	// TODO: in 3.0 this will become an abstract base class
-	public class FSDirectory:Directory
+	public abstract class FSDirectory : Directory
 	{
-		
-		/// <summary>This cache of directories ensures that there is a unique Directory
-		/// instance per path, so that synchronization on the Directory can be used to
-		/// synchronize access between readers and writers.  We use
-		/// refcounts to ensure when the last use of an FSDirectory
-		/// instance for a given canonical path is closed, we remove the
-		/// instance from the cache.  See LUCENE-776
-		/// for some relevant discussion.
-		/// </summary>
-		/// <deprecated> Not used by any non-deprecated methods anymore
-		/// </deprecated>
-        [Obsolete("Not used by any non-deprecated methods anymore")]
-        private static readonly Dictionary<string, FSDirectory> DIRECTORIES = new Dictionary<string, FSDirectory>();
-		
-		private static bool disableLocks = false;
-		
-		// TODO: should this move up to the Directory base class?  Also: should we
-		// make a per-instance (in addition to the static "default") version?
-		
-		/// <summary> Set whether Lucene's use of lock files is disabled. By default, 
-		/// lock files are enabled. They should only be disabled if the index
-		/// is on a read-only medium like a CD-ROM.
-		/// </summary>
-        /// <deprecated> Use a <see cref="Open(System.IO.DirectoryInfo, LockFactory)" /> or a constructor
-		/// that takes a <see cref="LockFactory" /> and supply
-		/// <see cref="NoLockFactory.GetNoLockFactory" />. This setting does not work
-        /// with <see cref="Open(System.IO.DirectoryInfo)" /> only the deprecated <c>getDirectory</c>
-		/// respect this setting.   
-		/// </deprecated>
-        [Obsolete("Use a Open(System.IO.DirectoryInfo, LockFactory) or a constructor that takes a LockFactory and supply NoLockFactory.GetNoLockFactory. This setting does not work with Open(File) only the deprecated GetDirectory respect this setting.")]
-		public static void  SetDisableLocks(bool doDisableLocks)
-		{
-			FSDirectory.disableLocks = doDisableLocks;
-		}
-		
-		/// <summary> Returns whether Lucene's use of lock files is disabled.</summary>
-		/// <returns> true if locks are disabled, false if locks are enabled.
-		/// </returns>
-		/// <seealso cref="SetDisableLocks">
-		/// </seealso>
-		/// <deprecated> Use a constructor that takes a <see cref="LockFactory" /> and
-		/// supply <see cref="NoLockFactory.GetNoLockFactory" />.
-		/// </deprecated>
-        [Obsolete("Use a constructor that takes a LockFactory and supply NoLockFactory.GetNoLockFactory.")]
-		public static bool GetDisableLocks()
-		{
-			return FSDirectory.disableLocks;
-		}
-		
-        ///// <summary> Directory specified by <c>org.apache.lucene.lockDir</c>
-        ///// or <c>java.io.tmpdir</c> system property.
-        ///// </summary>
-        ///// <deprecated> As of 2.1, <c>LOCK_DIR</c> is unused
-        ///// because the write.lock is now stored by default in the
-        ///// index directory.  If you really want to store locks
-        ///// elsewhere, you can create your own <see cref="// SimpleFSLockFactory" />
-        ///// (or <see cref="NativeFSLockFactory" />,
-        ///// etc.) passing in your preferred lock directory.  Then,
-        ///// pass this <c>LockFactory</c> instance to one of
-        ///// the <c>open</c> methods that take a
-        ///// <c>lockFactory</c> (for example, <see cref="Open(System.IO.DirectoryInfo, LockFactory)" />).
-        ///// </deprecated>
-        //[Obsolete("As of 2.1, LOCK_DIR is unused because the write.lock is now stored by default in the index directory. ")]
-		//public static readonly System.String LOCK_DIR = SupportClass.AppSettings.Get("Lucene.Net.lockDir", System.IO.Path.GetTempPath());
-		
-		/// <summary>The default class which implements filesystem-based directories. </summary>
-		// deprecated
-        [Obsolete]
-        private static readonly System.Type IMPL = typeof(Lucene.Net.Store.SimpleFSDirectory);
-		
 		private static System.Security.Cryptography.HashAlgorithm DIGESTER;
-		
-		/// <summary>A buffer optionally used in renameTo method </summary>
-		private byte[] buffer = null;
-		
-		
-		/// <summary>Returns the directory instance for the named location.
-		/// 
-		/// </summary>
-        /// <deprecated> Use <see cref="Open(System.IO.DirectoryInfo)" />
-		/// 
-		/// </deprecated>
-		/// <param name="path">the path to the directory.
-		/// </param>
-		/// <returns> the FSDirectory for the named file.  
-		/// </returns>
-        [Obsolete("Use Open(System.IO.DirectoryInfo)")]
-		public static FSDirectory GetDirectory(System.String path)
-		{
-			return GetDirectory(new System.IO.DirectoryInfo(path), null);
-		}
-		
-		/// <summary>Returns the directory instance for the named location.
-		/// 
-		/// </summary>
-        /// <deprecated> Use <see cref="Open(System.IO.DirectoryInfo, LockFactory)" />
-		/// 
-		/// </deprecated>
-		/// <param name="path">the path to the directory.
-		/// </param>
-		/// <param name="lockFactory">instance of <see cref="LockFactory" /> providing the
-		/// locking implementation.
-		/// </param>
-		/// <returns> the FSDirectory for the named file.  
-		/// </returns>
-        [Obsolete("Use Open(File, LockFactory)")]
-		public static FSDirectory GetDirectory(System.String path, LockFactory lockFactory)
-		{
-			return GetDirectory(new System.IO.DirectoryInfo(path), lockFactory);
-		}
-		
-		/// <summary>Returns the directory instance for the named location.
-		/// 
-		/// </summary>
-        /// <deprecated> Use <see cref="Open(System.IO.DirectoryInfo)" />
-		/// 
-		/// </deprecated>
-		/// <param name="file">the path to the directory.
-		/// </param>
-		/// <returns> the FSDirectory for the named file.  
-		/// </returns>
-        [Obsolete("Use Open(File)")]
-		public static FSDirectory GetDirectory(System.IO.DirectoryInfo file)
-		{
-			return GetDirectory(file, null);
-		}
 
-        /// <summary>Returns the directory instance for the named location.
-        /// 
-        /// </summary>
-        /// <deprecated> Use <see cref="Open(System.IO.DirectoryInfo)" />
-        /// 
-        /// </deprecated>
-        /// <param name="file">the path to the directory.
-        /// </param>
-        /// <returns> the FSDirectory for the named file.  
-        /// </returns>
-        [System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed in the 3.0 release")]
-        public static FSDirectory GetDirectory(System.IO.FileInfo file)
+        static FSDirectory()
         {
-            return GetDirectory(new System.IO.DirectoryInfo(file.FullName), null);
-        }
-		
-		/// <summary>Returns the directory instance for the named location.
-		/// 
-		/// </summary>
-        /// <deprecated> Use <see cref="Open(System.IO.DirectoryInfo, LockFactory)" />
-		/// 
-		/// </deprecated>
-		/// <param name="file">the path to the directory.
-		/// </param>
-		/// <param name="lockFactory">instance of <see cref="LockFactory" /> providing the
-		/// locking implementation.
-		/// </param>
-		/// <returns> the FSDirectory for the named file.  
-		/// </returns>
-		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed in the 3.0 release")]
-		public static FSDirectory GetDirectory(System.IO.FileInfo file, LockFactory lockFactory)
-		{
-            return GetDirectory(new System.IO.DirectoryInfo(file.FullName), lockFactory);
-		}
-
-        /// <summary>Returns the directory instance for the named location.
-        /// 
-        /// </summary>
-        /// <deprecated> Use <see cref="Open(System.IO.DirectoryInfo, LockFactory)" />
-        /// 
-        /// </deprecated>
-        /// <param name="file">the path to the directory.
-        /// </param>
-        /// <param name="lockFactory">instance of <see cref="LockFactory" /> providing the
-        /// locking implementation.
-        /// </param>
-        /// <returns> the FSDirectory for the named file.  
-        /// </returns>
-        [Obsolete("Use Open(File, LockFactory)")]
-        public static FSDirectory GetDirectory(System.IO.DirectoryInfo file, LockFactory lockFactory)
-        {
-            FSDirectory dir;
-            lock (DIRECTORIES)
-            {
-                if(!DIRECTORIES.TryGetValue(file.FullName, out dir))
-                {
-                    try
-                    {
-                        dir = (FSDirectory)System.Activator.CreateInstance(IMPL, true);
-                    }
-                    catch (System.Exception e)
-                    {
-                        throw new System.SystemException("cannot load FSDirectory class: " + e.ToString(), e);
-                    }
-                    dir.Init(file, lockFactory);
-                    DIRECTORIES.Add(file.FullName, dir);
-                }
-                else
-                {
-                    // Catch the case where a Directory is pulled from the cache, but has a
-                    // different LockFactory instance.
-                    if (lockFactory != null && lockFactory != dir.GetLockFactory())
-                    {
-                        throw new System.IO.IOException("Directory was previously created with a different LockFactory instance; please pass null as the lockFactory instance and use setLockFactory to change it");
-                    }
-                    dir.checked_Renamed = false;
-                }
-            }
-            lock (dir)
+            try
             {
-                dir.refCount++;
+                DIGESTER = Cryptography.GetHashAlgorithm();
             }
-            return dir;
-        }
-		
-		
-		/// <summary>Returns the directory instance for the named location.
-		/// 
-		/// </summary>
-		/// <deprecated> Use IndexWriter's create flag, instead, to
-		/// create a new index.
-		/// 
-		/// </deprecated>
-		/// <param name="path">the path to the directory.
-		/// </param>
-		/// <param name="create">if true, create, or erase any existing contents.
-		/// </param>
-		/// <returns> the FSDirectory for the named file.  
-		/// </returns>
-        [Obsolete("Use IndexWriter's create flag, instead, to create a new index.")]
-		public static FSDirectory GetDirectory(System.String path, bool create)
-		{
-			return GetDirectory(new System.IO.DirectoryInfo(path), create);
-		}
-		
-		/// <summary>Returns the directory instance for the named location.
-		/// 
-		/// </summary>
-		/// <deprecated> Use IndexWriter's create flag, instead, to
-		/// create a new index.
-		/// 
-		/// </deprecated>
-		/// <param name="file">the path to the directory.
-		/// </param>
-		/// <param name="create">if true, create, or erase any existing contents.
-		/// </param>
-		/// <returns> the FSDirectory for the named file.  
-		/// </returns>
-		[System.Obsolete("Use the method that takes a DirectoryInfo, this will be removed in the 3.0 release")]
-		public static FSDirectory GetDirectory(System.IO.FileInfo file, bool create)
-		{
-			return GetDirectory(new System.IO.DirectoryInfo(file.FullName), create);
-		}
-
-        /// <summary>Returns the directory instance for the named location.
-        /// 
-        /// </summary>
-        /// <deprecated> Use IndexWriter's create flag, instead, to
-        /// create a new index.
-        /// 
-        /// </deprecated>
-        /// <param name="file">the path to the directory.
-        /// </param>
-        /// <param name="create">if true, create, or erase any existing contents.
-        /// </param>
-        /// <returns> the FSDirectory for the named file.  
-        /// </returns>
-        [Obsolete("Use IndexWriter's create flag, instead, to create a new index.")]
-        public static FSDirectory GetDirectory(System.IO.DirectoryInfo file, bool create)
-        {
-            FSDirectory dir = GetDirectory(file, null);
-
-            // This is now deprecated (creation should only be done
-            // by IndexWriter):
-            if (create)
+            catch (System.Exception e)
             {
-                dir.Create();
+                throw new System.SystemException(e.ToString(), e);
             }
-
-            return dir;
         }
 		
-		/// <deprecated> 
-		/// </deprecated>
-        [Obsolete]
-		private void  Create()
-		{
-			if (directory.Exists)
- 			{
- 				System.String[] files = SupportClass.FileSupport.GetLuceneIndexFiles(directory.FullName, IndexFileNameFilter.GetFilter()); // clear old files
- 				if (files == null)
- 					throw new System.IO.IOException("cannot read directory " + directory.FullName + ": list() returned null");
- 				for (int i = 0; i < files.Length; i++)
- 				{
-                    System.String fileOrDir = System.IO.Path.Combine(directory.FullName, files[i]);
-                    if (System.IO.File.Exists(fileOrDir))
- 					{
-                        System.IO.File.Delete(fileOrDir);
- 					}
-                    else if (System.IO.Directory.Exists(fileOrDir))
- 					{
-                        System.IO.Directory.Delete(fileOrDir);
- 					}
-                    // no need to throw anything - if a delete fails the exc will propogate to the caller
- 				}
- 			}
- 			lockFactory.ClearLock(IndexWriter.WRITE_LOCK_NAME);
-		}
-		
 		private bool checked_Renamed;
 		
 		internal void  CreateDir()
@@ -472,19 +163,6 @@ namespace Lucene.Net.Store
 		/// <summary>The underlying filesystem directory </summary>
 		protected internal System.IO.DirectoryInfo directory = null;
 		
-		/// <deprecated> 
-		/// </deprecated>
-        [Obsolete]
-		private int refCount = 0;
-		
-		/// <deprecated> 
-		/// </deprecated>
-        [Obsolete]
-		protected internal FSDirectory()
-		{
-		}
-		 // permit subclassing
-		
 		/// <summary>Create a new FSDirectory for the named location (ctor for subclasses).</summary>
 		/// <param name="path">the path of the directory
 		/// </param>
@@ -499,38 +177,37 @@ namespace Lucene.Net.Store
 			{
 				lockFactory = new NativeFSLockFactory();
 			}
-			Init(path, lockFactory);
-			refCount = 1;
-		}
-		
-		/// <summary>Creates an FSDirectory instance, trying to pick the
-		/// best implementation given the current environment.
-		/// The directory returned uses the <see cref="NativeFSLockFactory" />.
-        /// 
-        /// <p/>Currently this returns <see cref="SimpleFSDirectory" /> as
-        /// NIOFSDirectory is currently not supported.
-		/// 
-		/// <p/>Currently this returns <see cref="SimpleFSDirectory" /> as
-		/// NIOFSDirectory is currently not supported.
-		/// 
-		/// <p/><b>NOTE</b>: this method may suddenly change which
-		/// implementation is returned from release to release, in
-		/// the event that higher performance defaults become
-		/// possible; if the precise implementation is important to
-		/// your application, please instantiate it directly,
-		/// instead. On 64 bit systems, it may also good to
-		/// return <see cref="MMapDirectory" />, but this is disabled
-		/// because of officially missing unmap support in Java.
-		/// For optimal performance you should consider using
-		/// this implementation on 64 bit JVMs.
-		/// 
-		/// <p/>See <a href="#subclasses">above</a> 
-		/// </summary>
-		[System.Obsolete("Use the method that takes a DirectoryInfo, this will be removed in the 3.0 release")]
-		public static FSDirectory Open(System.IO.FileInfo path)
-		{
-			System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(path.FullName);
-			return Open(dir, null);
+            // Set up lockFactory with cascaded defaults: if an instance was passed in,
+            // use that; else if locks are disabled, use NoLockFactory; else if the
+            // system property Lucene.Net.Store.FSDirectoryLockFactoryClass is set,
+            // instantiate that; else, use SimpleFSLockFactory:
+
+            directory = path;
+
+            // due to differences in how Java & .NET refer to files, the checks are a bit different
+            if (!directory.Exists && System.IO.File.Exists(directory.FullName))
+            {
+                throw new NoSuchDirectoryException("file '" + directory.FullName + "' exists but is not a directory");
+            }
+            SetLockFactory(lockFactory);
+            
+            // for filesystem based LockFactory, delete the lockPrefix, if the locks are placed
+            // in index dir. If no index dir is given, set ourselves
+            if (lockFactory is FSLockFactory)
+            {
+                FSLockFactory lf = (FSLockFactory)lockFactory;
+                System.IO.DirectoryInfo dir = lf.GetLockDir();
+                // if the lock factory has no lockDir set, use the this directory as lockDir
+                if (dir == null)
+                {
+                    lf.SetLockDir(this.directory);
+                    lf.SetLockPrefix(null);
+                }
+                else if (dir.FullName.Equals(this.directory.FullName))
+                {
+                    lf.SetLockPrefix(null);
+                }
+            }
 		}
 		
 		/// <summary>Creates an FSDirectory instance, trying to pick the
@@ -581,111 +258,6 @@ namespace Lucene.Net.Store
 			}
         }
 		
-		/* will move to ctor, when reflection is removed in 3.0 */
-		private void  Init(System.IO.DirectoryInfo path, LockFactory lockFactory)
-		{
-			
-			// Set up lockFactory with cascaded defaults: if an instance was passed in,
-			// use that; else if locks are disabled, use NoLockFactory; else if the
-			// system property Lucene.Net.Store.FSDirectoryLockFactoryClass is set,
-			// instantiate that; else, use SimpleFSLockFactory:
-			
-			directory = path;
-			
-            // due to differences in how Java & .NET refer to files, the checks are a bit different
-            if (!directory.Exists && System.IO.File.Exists(directory.FullName))
-            {
-                throw new NoSuchDirectoryException("file '" + directory.FullName + "' exists but is not a directory");
-            }
-			
-			if (lockFactory == null)
-			{
-				
-				if (disableLocks)
-				{
-					// Locks are disabled:
-					lockFactory = NoLockFactory.GetNoLockFactory();
-				}
-				else
-				{
-					System.String lockClassName = SupportClass.AppSettings.Get("Lucene.Net.Store.FSDirectoryLockFactoryClass", "");
-					
-					if (lockClassName != null && !lockClassName.Equals(""))
-					{
-						System.Type c;
-						
-						try
-						{
-							c = System.Type.GetType(lockClassName);
-						}
-						catch (System.Exception e)
-						{
-							throw new System.IO.IOException("unable to find LockClass " + lockClassName);
-						}
-						
-						try
-						{
-							lockFactory = (LockFactory) System.Activator.CreateInstance(c, true);
-						}
-						catch (System.UnauthorizedAccessException e)
-						{
-							throw new System.IO.IOException("IllegalAccessException when instantiating LockClass " + lockClassName);
-						}
-						catch (System.InvalidCastException e)
-						{
-							throw new System.IO.IOException("unable to cast LockClass " + lockClassName + " instance to a LockFactory");
-						}
-						catch (System.Exception e)
-						{
-							throw new System.IO.IOException("InstantiationException when instantiating LockClass " + lockClassName);
-						}
-					}
-					else
-					{
-						// Our default lock is SimpleFSLockFactory;
-						// default lockDir is our index directory:
-						lockFactory = new SimpleFSLockFactory();
-					}
-				}
-			}
-			
-			SetLockFactory(lockFactory);
-			
-			// for filesystem based LockFactory, delete the lockPrefix, if the locks are placed
-			// in index dir. If no index dir is given, set ourselves
-			if (lockFactory is FSLockFactory)
-			{
-				FSLockFactory lf = (FSLockFactory) lockFactory;
-				System.IO.DirectoryInfo dir = lf.GetLockDir();
-				// if the lock factory has no lockDir set, use the this directory as lockDir
-				if (dir == null)
-				{
-					lf.SetLockDir(this.directory);
-					lf.SetLockPrefix(null);
-				}
-				else if (dir.FullName.Equals(this.directory.FullName))
-				{
-					lf.SetLockPrefix(null);
-				}
-			}
-		}
-		
-		/// <summary>Lists all files (not subdirectories) in the
-		/// directory.  This method never returns null (throws
-		/// <see cref="System.IO.IOException" /> instead).
-		/// 
-		/// </summary>
-		/// <throws>  NoSuchDirectoryException if the directory </throws>
-		/// <summary>   does not exist, or does exist but is not a
-		/// directory.
-		/// </summary>
-		/// <throws>  IOException if list() returns null  </throws>
-		[System.Obsolete("Use the method that takes a DirectoryInfo, this will be removed in the 3.0 release")]
-		public static System.String[] ListAll(System.IO.FileInfo dir)
-		{
-			return ListAll(new System.IO.DirectoryInfo(dir.FullName));
-		}
-		
         /// <summary>Lists all files (not subdirectories) in the
         /// directory.  This method never returns null (throws
         /// <see cref="System.IO.IOException" /> instead).
@@ -702,6 +274,11 @@ namespace Lucene.Net.Store
             {
                 throw new NoSuchDirectoryException("directory '" + dir.FullName + "' does not exist");
             }
+            else if (System.IO.File.Exists(dir.FullName))
+            {
+                throw new NoSuchDirectoryException("File '" + dir.FullName + "' does not exist");
+            }
+
             // Exclude subdirs, only the file names, not the paths
             System.IO.FileInfo[] files = dir.GetFiles();
             System.String[] result = new System.String[files.Length];
@@ -717,13 +294,6 @@ namespace Lucene.Net.Store
             return result;
         }
 		
-        [Obsolete("Lucene.Net-2.9.1. This method overrides obsolete member Lucene.Net.Store.Directory.List()")]
-		public override System.String[] List()
-		{
-			EnsureOpen();
-			return SupportClass.FileSupport.GetLuceneIndexFiles(directory.FullName, IndexFileNameFilter.GetFilter());
-		}
-		
 		/// <summary>Lists all files (not subdirectories) in the
 		/// directory.
 		/// </summary>
@@ -789,39 +359,6 @@ namespace Lucene.Net.Store
             }
 		}
 		
-		/// <summary>Renames an existing file in the directory. 
-		/// Warning: This is not atomic.
-		/// </summary>
-		/// <deprecated> 
-		/// </deprecated>
-        [Obsolete]
-		public override void  RenameFile(System.String from, System.String to)
-		{
-			lock (this)
-			{
-				EnsureOpen();
-                System.IO.FileInfo old = new System.IO.FileInfo(System.IO.Path.Combine(directory.FullName, from));
-                try
-                {
-                    old.MoveTo(System.IO.Path.Combine(directory.FullName, to));
-                }
-                catch (System.IO.IOException ioe)
-                {
-                    System.IO.IOException newExc = new System.IO.IOException("Cannot rename " + old + " to " + directory, ioe);
-                    throw newExc;
-                }
-			}
-		}
-		
-		/// <summary>Creates an IndexOutput for the file with the given name.
-		/// <em>In 3.0 this method will become abstract.</em> 
-		/// </summary>
-		public override IndexOutput CreateOutput(System.String name)
-		{
-			InitOutput(name);
-			return new FSIndexOutput(new System.IO.FileInfo(System.IO.Path.Combine(directory.FullName, name)));
-		}
-		
 		public override void  Sync(System.String name)
 		{
 			EnsureOpen();
@@ -838,7 +375,7 @@ namespace Lucene.Net.Store
 					try
 					{
                         file = new System.IO.FileStream(fullFile.FullName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
-                        SupportClass.FileSupport.Sync(file);
+                        FileSupport.Sync(file);
                         success = true;
 					}
 					finally
@@ -860,8 +397,10 @@ namespace Lucene.Net.Store
 					{
 						// In 3.0 we will change this to throw
 						// InterruptedException instead
-						SupportClass.ThreadClass.Current().Interrupt();
-                        throw new System.SystemException(ie.ToString(), ie);
+                        // TODO: Change this to throwing a new ThreadInterruptedException when class is build
+                        // ThreadClass.Current().Interrupt();
+                        // throw new System.SystemException(ie.ToString(), ie);
+					    throw;
 					}
 				}
 			}
@@ -877,80 +416,50 @@ namespace Lucene.Net.Store
 			return OpenInput(name, BufferedIndexInput.BUFFER_SIZE);
 		}
 		
-		/// <summary>Creates an IndexInput for the file with the given name.
-		/// <em>In 3.0 this method will become abstract.</em> 
-		/// </summary>
-		public override IndexInput OpenInput(System.String name, int bufferSize)
-		{
-			EnsureOpen();
-			return new FSIndexInput(new System.IO.FileInfo(System.IO.Path.Combine(directory.FullName, name)), bufferSize);
-		}
-		
 		/// <summary> So we can do some byte-to-hexchar conversion below</summary>
 		private static readonly char[] HEX_DIGITS = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
-		
-		
-		public override System.String GetLockID()
-		{
-			EnsureOpen();
-			System.String dirName; // name to be hashed
-			try
-			{
-				dirName = directory.FullName;
-			}
-			catch (System.IO.IOException e)
-			{
-				throw new System.SystemException(e.ToString(), e);
-			}
-			
-			byte[] digest;
-			lock (DIGESTER)
-			{
-				digest = DIGESTER.ComputeHash(System.Text.Encoding.UTF8.GetBytes(dirName));
-			}
-			System.Text.StringBuilder buf = new System.Text.StringBuilder();
-			buf.Append("lucene-");
-			for (int i = 0; i < digest.Length; i++)
-			{
-				int b = digest[i];
-				buf.Append(HEX_DIGITS[(b >> 4) & 0xf]);
-				buf.Append(HEX_DIGITS[b & 0xf]);
-			}
-			
-			return buf.ToString();
-		}
-		
-		/// <summary>Closes the store to future operations. </summary>
-		public override void  Close()
-		{
-			lock (this)
-			{
-				if (isOpen && --refCount <= 0)
-				{
-					isOpen = false;
-					lock (DIRECTORIES)
-					{
-						DIRECTORIES.Remove(directory.FullName);
-					}
-				}
-			}
-		}
 
-        /// <summary>
-        /// .NET
-        /// </summary>
-        public override void Dispose()
-        {
-            Close();
-        }
 
-        [System.Obsolete("A DirectoryInfo is more appropriate, however this is here for backwards compatibility. This will be removed in the 3.0 release")]
-		public virtual System.IO.FileInfo GetFile()
-		{
-			EnsureOpen();
-			return new System.IO.FileInfo(directory.FullName);
-		}
+	    public override string LockId
+	    {
+	        get
+	        {
+	            EnsureOpen();
+	            System.String dirName; // name to be hashed
+	            try
+	            {
+	                dirName = directory.FullName;
+	            }
+	            catch (System.IO.IOException e)
+	            {
+	                throw new System.SystemException(e.ToString(), e);
+	            }
+
+	            byte[] digest;
+	            lock (DIGESTER)
+	            {
+	                digest = DIGESTER.ComputeHash(System.Text.Encoding.UTF8.GetBytes(dirName));
+	            }
+	            System.Text.StringBuilder buf = new System.Text.StringBuilder();
+	            buf.Append("lucene-");
+	            for (int i = 0; i < digest.Length; i++)
+	            {
+	                int b = digest[i];
+	                buf.Append(HEX_DIGITS[(b >> 4) & 0xf]);
+	                buf.Append(HEX_DIGITS[b & 0xf]);
+	            }
+
+	            return buf.ToString();
+	        }
+	    }
 
+	    protected override void Dispose(bool disposing)
+        {
+            lock (this)
+            {
+                isOpen = false;
+            }
+        }
 
         // Java Lucene implements GetFile() which returns a FileInfo.
         // For Lucene.Net, GetDirectory() is more appropriate
@@ -972,7 +481,7 @@ namespace Lucene.Net.Store
 		/// </summary>
 		/// <seealso cref="SetReadChunkSize">
 		/// </seealso>
-		public static readonly int DEFAULT_READ_CHUNK_SIZE;
+		public static readonly int DEFAULT_READ_CHUNK_SIZE = Constants.JRE_IS_64BIT ? int.MaxValue: 100 * 1024 * 1024;
 		
 		// LUCENE-1566
 		private int chunkSize = DEFAULT_READ_CHUNK_SIZE;
@@ -1021,91 +530,5 @@ namespace Lucene.Net.Store
 			// LUCENE-1566
 			return chunkSize;
 		}
-		
-		
-		/// <deprecated> Use SimpleFSDirectory.SimpleFSIndexInput instead 
-		/// </deprecated>
-        [Obsolete("Use SimpleFSDirectory.SimpleFSIndexInput instead ")]
-		public /*protected internal*/ class FSIndexInput:SimpleFSDirectory.SimpleFSIndexInput
-		{
-			
-			/// <deprecated> 
-			/// </deprecated>
-            [Obsolete]
-			new protected internal class Descriptor:SimpleFSDirectory.SimpleFSIndexInput.Descriptor
-			{
-				/// <deprecated> 
-				/// </deprecated>
-                [Obsolete]
-				public Descriptor(/*FSIndexInput enclosingInstance,*/ System.IO.FileInfo file, System.IO.FileAccess mode) : base(file, mode)
-				{
-				}
-			}
-			
-			/// <deprecated> 
-			/// </deprecated>
-            [Obsolete]
-			public FSIndexInput(System.IO.FileInfo path):base(path)
-			{
-			}
-			
-			/// <deprecated> 
-			/// </deprecated>
-            [Obsolete]
-			public FSIndexInput(System.IO.FileInfo path, int bufferSize):base(path, bufferSize)
-			{
-			}
-		}
-		
-		/// <deprecated> Use SimpleFSDirectory.SimpleFSIndexOutput instead 
-		/// </deprecated>
-        [Obsolete("Use SimpleFSDirectory.SimpleFSIndexOutput instead ")]
-		protected internal class FSIndexOutput:SimpleFSDirectory.SimpleFSIndexOutput
-		{
-			
-			/// <deprecated> 
-			/// </deprecated>
-            [Obsolete]
-			public FSIndexOutput(System.IO.FileInfo path):base(path)
-			{
-			}
-		}
-		static FSDirectory()
-		{
-			{
-				try
-				{
-					System.String name = SupportClass.AppSettings.Get("Lucene.Net.FSDirectory.class", typeof(SimpleFSDirectory).FullName);
-					if (typeof(FSDirectory).FullName.Equals(name))
-					{
-						// FSDirectory will be abstract, so we replace it by the correct class
-						IMPL = typeof(SimpleFSDirectory);
-					}
-					else
-					{
-						IMPL = System.Type.GetType(name);
-					}
-				}
-				catch (System.Security.SecurityException se)
-				{
-					IMPL = typeof(SimpleFSDirectory);
-				}
-				catch (System.Exception e)
-				{
-					throw new System.SystemException("cannot load FSDirectory class: " + e.ToString(), e);
-				}
-			}
-			{
-				try
-				{
-					DIGESTER = SupportClass.Cryptography.GetHashAlgorithm();
-				}
-				catch (System.Exception e)
-				{
-					throw new System.SystemException(e.ToString(), e);
-				}
-			}
-			DEFAULT_READ_CHUNK_SIZE = Constants.JRE_IS_64BIT?System.Int32.MaxValue:100 * 1024 * 1024;
-		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Store/FileSwitchDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/FileSwitchDirectory.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Store/FileSwitchDirectory.cs (original)
+++ incubator/lucene.net/trunk/src/core/Store/FileSwitchDirectory.cs Tue Feb 28 22:43:08 2012
@@ -36,10 +36,14 @@ namespace Lucene.Net.Store
 	{
 		private Directory secondaryDir;
 		private Directory primaryDir;
-		private System.Collections.Hashtable primaryExtensions;
+		private System.Collections.Generic.HashSet<string> primaryExtensions;
 		private bool doClose;
+	    private bool isDisposed;
 		
-		public FileSwitchDirectory(System.Collections.Hashtable primaryExtensions, Directory primaryDir, Directory secondaryDir, bool doClose)
+		public FileSwitchDirectory(System.Collections.Generic.HashSet<string> primaryExtensions,
+                                    Directory primaryDir, 
+                                    Directory secondaryDir, 
+                                    bool doClose)
 		{
 			this.primaryExtensions = primaryExtensions;
 			this.primaryDir = primaryDir;
@@ -59,44 +63,42 @@ namespace Lucene.Net.Store
 		{
 			return secondaryDir;
 		}
-		
-		public override void  Close()
-		{
-			if (doClose)
-			{
-				try
-				{
-					secondaryDir.Close();
-				}
-				finally
-				{
-					primaryDir.Close();
-				}
-				doClose = false;
-			}
-		}
 
-        /// <summary>
-        /// .NET
-        /// </summary>
-        public override void Dispose()
+	    protected override void Dispose(bool disposing)
         {
-            Close();
+            if (isDisposed) return;
+
+            if (doClose)
+            {
+                try
+                {
+                    if (secondaryDir != null)
+                    {
+                        secondaryDir.Close();
+                    }
+                }
+                finally
+                {
+                    if (primaryDir != null)
+                    {
+                        primaryDir.Close();
+                    }
+                }
+                doClose = false;
+            }
+
+            secondaryDir = null;
+            primaryDir = null;
+            isDisposed = true;
         }
 		
 		public override System.String[] ListAll()
 		{
-            System.Collections.Generic.List<string> files = new System.Collections.Generic.List<string>();
+            var files = new System.Collections.Generic.List<string>();
             files.AddRange(primaryDir.ListAll());
             files.AddRange(secondaryDir.ListAll());
             return files.ToArray();
 		}
-
-        [Obsolete("Lucene.Net-2.9.1. This method overrides obsolete member Lucene.Net.Store.Directory.List()")]
-		public override System.String[] List()
-		{
-			return ListAll();
-		}
 		
 		/// <summary>Utility method to return a file's extension. </summary>
 		public static System.String GetExtension(System.String name)
@@ -141,12 +143,6 @@ namespace Lucene.Net.Store
 		{
 			GetDirectory(name).DeleteFile(name);
 		}
-
-        [Obsolete("Lucene.Net-2.9.1. This method overrides obsolete member Lucene.Net.Store.Directory.RenameFile(string, string)")]
-		public override void  RenameFile(System.String from, System.String to)
-		{
-			GetDirectory(from).RenameFile(from, to);
-		}
 		
 		public override long FileLength(System.String name)
 		{

Modified: incubator/lucene.net/trunk/src/core/Store/IndexInput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/IndexInput.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Store/IndexInput.cs (original)
+++ incubator/lucene.net/trunk/src/core/Store/IndexInput.cs Tue Feb 28 22:43:08 2012
@@ -16,6 +16,7 @@
  */
 
 using System;
+using Lucene.Net.Support;
 
 namespace Lucene.Net.Store
 {
@@ -25,7 +26,7 @@ namespace Lucene.Net.Store
 	/// </summary>
 	/// <seealso cref="Directory">
 	/// </seealso>
-	public abstract class IndexInput : System.ICloneable
+	public abstract class IndexInput : System.ICloneable, IDisposable
 	{
 		private bool preUTF8Strings; // true if we are reading old (modified UTF8) string format
 		
@@ -217,9 +218,19 @@ namespace Lucene.Net.Store
 			}
 		}
 		
-		
-		/// <summary>Closes the stream to futher operations. </summary>
-		public abstract void  Close();
+		[Obsolete("Use Dispose() instead.")]
+		public void Close()
+		{
+		    Dispose();
+		}
+
+        /// <summary>Closes the stream to futher operations. </summary>
+	    public void Dispose()
+        {
+            Dispose(true);
+        }
+
+	    protected abstract void Dispose(bool disposing);
 		
 		/// <summary>Returns the current position in this file, where the next read will
 		/// occur.
@@ -262,7 +273,7 @@ namespace Lucene.Net.Store
 		// returns Map<String, String>
 		public virtual System.Collections.Generic.IDictionary<string,string> ReadStringStringMap()
 		{
-            System.Collections.Generic.Dictionary<string, string> map = new System.Collections.Generic.Dictionary<string, string>();
+            var map = new HashMap<string, string>();
 			int count = ReadInt();
 			for (int i = 0; i < count; i++)
 			{
@@ -273,5 +284,7 @@ namespace Lucene.Net.Store
 			
 			return map;
 		}
+
+	    /*public abstract void Dispose();*/
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Store/IndexOutput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/IndexOutput.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Store/IndexOutput.cs (original)
+++ incubator/lucene.net/trunk/src/core/Store/IndexOutput.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using Lucene.Net.Support;
 using UnicodeUtil = Lucene.Net.Util.UnicodeUtil;
 
 namespace Lucene.Net.Store
@@ -29,7 +29,7 @@ namespace Lucene.Net.Store
 	/// </seealso>
 	/// <seealso cref="IndexInput">
 	/// </seealso>
-	public abstract class IndexOutput
+    public abstract class IndexOutput : IDisposable
 	{
 		/// <summary>Writes a single byte.</summary>
 		/// <seealso cref="IndexInput.ReadByte()">
@@ -81,7 +81,7 @@ namespace Lucene.Net.Store
 			while ((i & ~ 0x7F) != 0)
 			{
 				WriteByte((byte) ((i & 0x7f) | 0x80));
-				i = SupportClass.Number.URShift(i, 7);
+				i = Number.URShift(i, 7);
 			}
 			WriteByte((byte) i);
 		}
@@ -106,7 +106,7 @@ namespace Lucene.Net.Store
 			while ((i & ~ 0x7F) != 0)
 			{
 				WriteByte((byte) ((i & 0x7f) | 0x80));
-				i = SupportClass.Number.URShift(i, 7);
+				i = Number.URShift(i, 7);
 			}
 			WriteByte((byte) i);
 		}
@@ -150,7 +150,7 @@ namespace Lucene.Net.Store
 				}
 				else
 				{
-					WriteByte((byte) (0xE0 | (SupportClass.Number.URShift(code, 12))));
+					WriteByte((byte) (0xE0 | (Number.URShift(code, 12))));
 					WriteByte((byte) (0x80 | ((code >> 6) & 0x3F)));
 					WriteByte((byte) (0x80 | (code & 0x3F)));
 				}
@@ -184,7 +184,7 @@ namespace Lucene.Net.Store
 				}
 				else
 				{
-					WriteByte((byte) (0xE0 | (SupportClass.Number.URShift(code, 12))));
+					WriteByte((byte) (0xE0 | (Number.URShift(code, 12))));
 					WriteByte((byte) (0x80 | ((code >> 6) & 0x3F)));
 					WriteByte((byte) (0x80 | (code & 0x3F)));
 				}
@@ -216,9 +216,21 @@ namespace Lucene.Net.Store
 		
 		/// <summary>Forces any buffered output to be written. </summary>
 		public abstract void  Flush();
-		
-		/// <summary>Closes this stream to further operations. </summary>
-		public abstract void  Close();
+
+        /// <summary>Closes this stream to further operations. </summary>
+        [Obsolete("Use Dispose() instead.")]
+        public void Close()
+        {
+            Dispose();
+        }
+
+        /// <summary>Closes this stream to further operations. </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+
+	    protected abstract void Dispose(bool disposing);
 		
 		/// <summary>Returns the current position in this file, where the next write will
 		/// occur.
@@ -262,10 +274,10 @@ namespace Lucene.Net.Store
 			else
 			{
 				WriteInt(map.Count);
-                foreach (string key in map.Keys)
+                foreach (var entry in map)
                 {
-                    WriteString(key);
-                    WriteString(map[key]);
+                    WriteString(entry.Key);
+                    WriteString(entry.Value);
                 }
 			}
 		}

Modified: incubator/lucene.net/trunk/src/core/Store/Lock.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/Lock.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Store/Lock.cs (original)
+++ incubator/lucene.net/trunk/src/core/Store/Lock.cs Tue Feb 28 22:43:08 2012
@@ -16,6 +16,7 @@
  */
 
 using System;
+using Lucene.Net.Support;
 
 namespace Lucene.Net.Store
 {
@@ -28,13 +29,8 @@ namespace Lucene.Net.Store
 	/// }
 	/// }.run();
     /// </code>
-	/// 
-	/// 
 	/// </summary>
-	/// <version>  $Id: Lock.java 769409 2009-04-28 14:05:43Z mikemccand $
-	/// </version>
-	/// <seealso cref="Directory.MakeLock(String)">
-	/// </seealso>
+	/// <seealso cref="Directory.MakeLock(String)" />
 	public abstract class Lock
 	{
 		
@@ -112,10 +108,7 @@ namespace Lucene.Net.Store
 				}
 				catch (System.Threading.ThreadInterruptedException e)
 				{
-					// In 3.0 we will change this to throw
-					// InterruptedException instead
-					SupportClass.ThreadClass.Current().Interrupt();
-					throw new System.IO.IOException(e.ToString());
+				    throw;
 				}
 				locked = Obtain();
 			}
@@ -139,7 +132,7 @@ namespace Lucene.Net.Store
 			
 			
 			/// <summary>Constructs an executor that will grab the named lock. </summary>
-			public With(Lock lock_Renamed, long lockWaitTimeout)
+			protected With(Lock lock_Renamed, long lockWaitTimeout)
 			{
 				this.lock_Renamed = lock_Renamed;
 				this.lockWaitTimeout = lockWaitTimeout;

Modified: incubator/lucene.net/trunk/src/core/Store/MMapDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/MMapDirectory.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Store/MMapDirectory.cs (original)
+++ incubator/lucene.net/trunk/src/core/Store/MMapDirectory.cs Tue Feb 28 22:43:08 2012
@@ -104,20 +104,6 @@ namespace Lucene.Net.Store
 			maxBBuf = Constants.JRE_IS_64BIT?System.Int32.MaxValue:(256 * 1024 * 1024);
 		}
 		
-		/// <summary>Create a new MMapDirectory for the named location.
-		/// 
-		/// </summary>
-		/// <param name="path">the path of the directory
-		/// </param>
-		/// <param name="lockFactory">the lock factory to use, or null for the default.
-		/// </param>
-		/// <throws>  IOException </throws>
-		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed in the 3.0 release")]
-		public MMapDirectory(System.IO.FileInfo path, LockFactory lockFactory):base(new System.IO.DirectoryInfo(path.FullName), lockFactory)
-		{
-			InitBlock();
-		}
-		
         /// <summary>Create a new MMapDirectory for the named location.
         /// 
         /// </summary>
@@ -126,45 +112,23 @@ namespace Lucene.Net.Store
         /// <param name="lockFactory">the lock factory to use, or null for the default.
         /// </param>
         /// <throws>  IOException </throws>
-        public MMapDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory) : base(path, lockFactory)
+        public MMapDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory)
+            : base(path, lockFactory)
         {
             InitBlock();
         }
-		
-		/// <summary>Create a new MMapDirectory for the named location and the default lock factory.
-		/// 
-		/// </summary>
-		/// <param name="path">the path of the directory
-		/// </param>
-		/// <throws>  IOException </throws>
-		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed in the 3.0 release")]
-		public MMapDirectory(System.IO.FileInfo path):base(new System.IO.DirectoryInfo(path.FullName), null)
-		{
-			InitBlock();
-		}
-		
-        /// <summary>Create a new MMapDirectory for the named location and the default lock factory.
+
+	    /// <summary>Create a new MMapDirectory for the named location and the default lock factory.
         /// 
         /// </summary>
         /// <param name="path">the path of the directory
         /// </param>
         /// <throws>  IOException </throws>
-        public MMapDirectory(System.IO.DirectoryInfo path) : base(path, null)
-        {
-            InitBlock();
-        }
-		
-		// back compatibility so FSDirectory can instantiate via reflection
-		/// <deprecated> 
-		/// </deprecated>
-        [Obsolete]
-		internal MMapDirectory()
-		{
-			InitBlock();
-		}
-		
-		internal static readonly System.Type[] NO_PARAM_TYPES = new System.Type[0];
-		internal static readonly System.Object[] NO_PARAMS = new System.Object[0];
+        public MMapDirectory(System.IO.DirectoryInfo path)
+            : base(path, null)
+	    {
+	        InitBlock();
+	    }
 		
 		private bool useUnmapHack = false;
 		private int maxBBuf;
@@ -246,7 +210,7 @@ namespace Lucene.Net.Store
 			return maxBBuf;
 		}
 		
-		private class MMapIndexInput:IndexInput, System.ICloneable
+		private class MMapIndexInput : IndexInput
 		{
 			private void  InitBlock(MMapDirectory enclosingInstance)
 			{
@@ -264,7 +228,8 @@ namespace Lucene.Net.Store
 			
 			private System.IO.MemoryStream buffer;
 			private long length;
-			private bool isClone = false;
+			private bool isClone;
+		    private bool isDisposed;
 			
 			internal MMapIndexInput(MMapDirectory enclosingInstance, System.IO.FileStream raf)
 			{
@@ -325,26 +290,33 @@ namespace Lucene.Net.Store
 				return clone;
 			}
 			
-			public override void  Close()
+			protected override void Dispose(bool isDisposing)
 			{
-				if (isClone || buffer == null)
-					return ;
-				// unmap the buffer (if enabled) and at least unset it for GC
-				try
-				{
-					Enclosing_Instance.CleanMapping(buffer);
-				}
-				finally
-				{
-					buffer = null;
-				}
+                if (isDisposed) return;
+
+                if (isDisposing)
+                {
+                    if (isClone || buffer == null)
+                        return;
+                    // unmap the buffer (if enabled) and at least unset it for GC
+                    try
+                    {
+                        Enclosing_Instance.CleanMapping(buffer);
+                    }
+                    finally
+                    {
+                        buffer = null;
+                    }
+                }
+
+			    isDisposed = true;
 			}
 		}
 		
 		// Because Java's ByteBuffer uses an int to address the
 		// values, it's necessary to access a file >
 		// Integer.MAX_VALUE in size using multiple byte buffers.
-		private class MultiMMapIndexInput:IndexInput, System.ICloneable
+		protected internal class MultiMMapIndexInput:IndexInput, System.ICloneable
 		{
 			private void  InitBlock(MMapDirectory enclosingInstance)
 			{
@@ -364,6 +336,8 @@ namespace Lucene.Net.Store
 			private int[] bufSizes; // keep here, ByteBuffer.size() method is optional
 			
 			private long length;
+
+		    private bool isDisposed;
 			
 			private int curBufIndex;
 			private int maxBufSize;
@@ -486,31 +460,33 @@ namespace Lucene.Net.Store
 				}
 				return clone;
 			}
-			
-			public override void  Close()
-			{
-				if (isClone || buffers == null)
-					return ;
-				try
-				{
-					for (int bufNr = 0; bufNr < buffers.Length; bufNr++)
-					{
-						// unmap the buffer (if enabled) and at least unset it for GC
-						try
-						{
-							Enclosing_Instance.CleanMapping(buffers[bufNr]);
-						}
-						finally
-						{
-							buffers[bufNr] = null;
-						}
-					}
-				}
-				finally
-				{
-					buffers = null;
-				}
-			}
+
+            protected override void Dispose(bool disposing)
+            {
+                if (isDisposed) return;
+                if (isClone || buffers == null)
+                    return;
+                try
+                {
+                    for (int bufNr = 0; bufNr < buffers.Length; bufNr++)
+                    {
+                        // unmap the buffer (if enabled) and at least unset it for GC
+                        try
+                        {
+                            Enclosing_Instance.CleanMapping(buffers[bufNr]);
+                        }
+                        finally
+                        {
+                            buffers[bufNr] = null;
+                        }
+                    }
+                }
+                finally
+                {
+                    buffers = null;
+                }
+                isDisposed = true;
+            }
 		}
 		
 		/// <summary>Creates an IndexInput for the file with the given name. </summary>

Modified: incubator/lucene.net/trunk/src/core/Store/NIOFSDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/NIOFSDirectory.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Store/NIOFSDirectory.cs (original)
+++ incubator/lucene.net/trunk/src/core/Store/NIOFSDirectory.cs Tue Feb 28 22:43:08 2012
@@ -23,13 +23,10 @@ namespace Lucene.Net.Store
     /// </summary>
     public class NIOFSDirectory : Lucene.Net.Store.FSDirectory
     {
-        public NIOFSDirectory()
+        public NIOFSDirectory(System.IO.DirectoryInfo dir, LockFactory lockFactory)
+            : base(dir, lockFactory)
         {
             throw new System.NotImplementedException("Waiting for volunteers to implement this class");
-
-        }
-        public NIOFSDirectory(System.IO.DirectoryInfo dir,LockFactory lockFactory)
-        {
         }
 
         /// <summary>
@@ -42,6 +39,11 @@ namespace Lucene.Net.Store
                 throw new System.NotImplementedException("Waiting for volunteers to implement this class");
             }
         }
+
+        public override IndexOutput CreateOutput(string name)
+        {
+            throw new System.NotImplementedException("Waiting for volunteers to implement this class");
+        }
     }
 }
 



Mime
View raw message