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 [10/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/Analysis/CharArraySet.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/CharArraySet.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/CharArraySet.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/CharArraySet.cs Tue Feb 28 22:43:08 2012
@@ -16,455 +16,506 @@
  */
 
 using System;
+using System.Collections;
+using System.Linq;
+using System.Collections.Generic;
+
 namespace Lucene.Net.Analysis
 {
-	
-	
-	/// <summary> A simple class that stores Strings as char[]'s in a
-	/// hash table.  Note that this is not a general purpose
-	/// class.  For example, it cannot remove items from the
-	/// set, nor does it resize its hash table to be smaller,
-	/// etc.  It is designed to be quick to test if a char[]
-	/// is in the set without the necessity of converting it
-	/// to a String first.
-	/// </summary>
-	
-	public class CharArraySet:System.Collections.Hashtable
-	{
-		public override int Count
-		{
-			get
-			{
-				return count;
-			}
-			
-		}
-		private const int INIT_SIZE = 8;
-		private char[][] entries;
-		private int count;
-		private bool ignoreCase;
-		
-		/// <summary>Create set with enough capacity to hold startSize
-		/// terms 
-		/// </summary>
-		public CharArraySet(int startSize, bool ignoreCase)
-		{
-			this.ignoreCase = ignoreCase;
-			int size = INIT_SIZE;
-			while (startSize + (startSize >> 2) > size)
-				size <<= 1;
-			entries = new char[size][];
-		}
-		
-		/// <summary>Create set from a Collection of char[] or String </summary>
-		public CharArraySet(System.Collections.ICollection c, bool ignoreCase):this(c.Count, ignoreCase)
-		{
-            System.Collections.IEnumerator e = c is CharArraySet ? ((CharArraySet)c).GetEnumerator() : c.GetEnumerator();
-			while (e.MoveNext())
-			{
-				Add(e.Current);
-			}
-		}
-		/// <summary>Create set from entries </summary>
-		private CharArraySet(char[][] entries, bool ignoreCase, int count)
-		{
-			this.entries = entries;
-			this.ignoreCase = ignoreCase;
-			this.count = count;
-		}
-		
-		/// <summary>true if the <c>len</c> chars of <c>text</c> starting at <c>off</c>
-		/// are in the set 
-		/// </summary>
-		public virtual bool Contains(char[] text, int off, int len)
-		{
-			return entries[GetSlot(text, off, len)] != null;
-		}
-		
-		/// <summary>true if the <c>System.String</c> is in the set </summary>
-		public virtual bool Contains(System.String cs)
-		{
-			return entries[GetSlot(cs)] != null;
-		}
-		
-		private int GetSlot(char[] text, int off, int len)
-		{
-			int code = GetHashCode(text, off, len);
-			int pos = code & (entries.Length - 1);
-			char[] text2 = entries[pos];
-			if (text2 != null && !Equals(text, off, len, text2))
-			{
-				int inc = ((code >> 8) + code) | 1;
-				do 
-				{
-					code += inc;
-					pos = code & (entries.Length - 1);
-					text2 = entries[pos];
-				}
-				while (text2 != null && !Equals(text, off, len, text2));
-			}
-			return pos;
-		}
-		
-		/// <summary>Returns true if the String is in the set </summary>
-		private int GetSlot(System.String text)
-		{
-			int code = GetHashCode(text);
-			int pos = code & (entries.Length - 1);
-			char[] text2 = entries[pos];
-			if (text2 != null && !Equals(text, text2))
-			{
-				int inc = ((code >> 8) + code) | 1;
-				do 
-				{
-					code += inc;
-					pos = code & (entries.Length - 1);
-					text2 = entries[pos];
-				}
-				while (text2 != null && !Equals(text, text2));
-			}
-			return pos;
-		}
-		
-		/// <summary>Add this String into the set </summary>
-		public virtual bool Add(System.String text)
-		{
-			return Add(text.ToCharArray());
-		}
-		
-		/// <summary>Add this char[] directly to the set.
-		/// If ignoreCase is true for this Set, the text array will be directly modified.
-		/// The user should never modify this text array after calling this method.
-		/// </summary>
-		public virtual bool Add(char[] text)
-		{
-			if (ignoreCase)
-				for (int i = 0; i < text.Length; i++)
-					text[i] = System.Char.ToLower(text[i]);
-			int slot = GetSlot(text, 0, text.Length);
-			if (entries[slot] != null)
-				return false;
-			entries[slot] = text;
-			count++;
-			
-			if (count + (count >> 2) > entries.Length)
-			{
-				Rehash();
-			}
-			
-			return true;
-		}
-		
-		private bool Equals(char[] text1, int off, int len, char[] text2)
-		{
-			if (len != text2.Length)
-				return false;
-			if (ignoreCase)
-			{
-				for (int i = 0; i < len; i++)
-				{
-					if (System.Char.ToLower(text1[off + i]) != text2[i])
-						return false;
-				}
-			}
-			else
-			{
-				for (int i = 0; i < len; i++)
-				{
-					if (text1[off + i] != text2[i])
-						return false;
-				}
-			}
-			return true;
-		}
-		
-		private bool Equals(System.String text1, char[] text2)
-		{
-			int len = text1.Length;
-			if (len != text2.Length)
-				return false;
-			if (ignoreCase)
-			{
-				for (int i = 0; i < len; i++)
-				{
-					if (System.Char.ToLower(text1[i]) != text2[i])
-						return false;
-				}
-			}
-			else
-			{
-				for (int i = 0; i < len; i++)
-				{
-					if (text1[i] != text2[i])
-						return false;
-				}
-			}
-			return true;
-		}
-		
-		private void  Rehash()
-		{
-			int newSize = 2 * entries.Length;
-			char[][] oldEntries = entries;
-			entries = new char[newSize][];
-			
-			for (int i = 0; i < oldEntries.Length; i++)
-			{
-				char[] text = oldEntries[i];
-				if (text != null)
-				{
-					// todo: could be faster... no need to compare strings on collision
-					entries[GetSlot(text, 0, text.Length)] = text;
-				}
-			}
-		}
+    /// <summary> A simple class that stores Strings as char[]'s in a
+    /// hash table.  Note that this is not a general purpose
+    /// class.  For example, it cannot remove items from the
+    /// set, nor does it resize its hash table to be smaller,
+    /// etc.  It is designed to be quick to test if a char[]
+    /// is in the set without the necessity of converting it
+    /// to a String first.
+    /// <p/>
+    /// <em>Please note:</em> This class implements <see cref="System.Collections.Generic.ISet{T}"/> but
+    /// does not behave like it should in all cases. The generic type is
+    /// <see cref="System.Collections.Generic.ICollection{T}"/>, because you can add any object to it,
+    /// that has a string representation. The add methods will use
+    /// <see cref="object.ToString()"/> and store the result using a <see cref="char"/>
+    /// buffer. The same behaviour have the <see cref="Contains(object)"/> methods.
+    /// The <see cref="GetEnumerator"/> method returns an <see cref="string"/> IEnumerable.
+    /// For type safety also {@link #stringIterator()} is provided.
+    /// </summary>
+    // TODO: java uses wildcards, .net doesn't have this, easiest way is to 
+    //       make the entire class generic.  Ultimately, though, since this
+    //       works with strings, I can't think of a reason not to just declare
+    //       this as an ISet<string>.
+    public class CharArraySet : ISet<string>
+    {
+        bool _ReadOnly = false;
+        const int INIT_SIZE = 8;
+        char[][] _Entries;
+        int _Count;
+        bool _IgnoreCase;
+        public static CharArraySet EMPTY_SET = CharArraySet.UnmodifiableSet(new CharArraySet(0, false));
+
+        private void Init(int startSize, bool ignoreCase)
+        {
+            this._IgnoreCase = ignoreCase;
+            int size = INIT_SIZE;
+            while (startSize + (startSize >> 2) > size)
+                size <<= 1;
+            _Entries = new char[size][];
+        }
+
+        /// <summary>Create set with enough capacity to hold startSize
+        /// terms 
+        /// </summary>
+        public CharArraySet(int startSize, bool ignoreCase)
+        {
+            Init(startSize, ignoreCase);
+        }
+
+        public CharArraySet(IEnumerable<string> c, bool ignoreCase)
+        {
+            Init(c.Count(), ignoreCase);
+            AddItems(c);
+        }
+
+        /// <summary>Create set from a Collection of char[] or String </summary>
+        public CharArraySet(IEnumerable<object> c, bool ignoreCase)
+        {
+            Init(c.Count(), ignoreCase);
+            AddItems(c);
+        }
+
+        private void AddItems<T>(IEnumerable<T> items)
+        {
+            foreach(T item in items)
+            {
+                Add(item.ToString());
+            }
+        }
+
+        /// <summary>Create set from entries </summary>
+        private CharArraySet(char[][] entries, bool ignoreCase, int count)
+        {
+            this._Entries = entries;
+            this._IgnoreCase = ignoreCase;
+            this._Count = count;
+        }
+
+        /// <summary>true if the <code>len</code> chars of <code>text</code> starting at <code>off</code>
+        /// are in the set 
+        /// </summary>
+        public virtual bool Contains(char[] text, int off, int len)
+        {
+            return _Entries[GetSlot(text, off, len)] != null;
+        }
+
+        public virtual bool Contains(string text)
+        {
+            return _Entries[GetSlot(text)] != null;
+        }
+
+
+        private int GetSlot(char[] text, int off, int len)
+        {
+            int code = GetHashCode(text, off, len);
+            int pos = code & (_Entries.Length - 1);
+            char[] text2 = _Entries[pos];
+            if (text2 != null && !Equals(text, off, len, text2))
+            {
+                int inc = ((code >> 8) + code) | 1;
+                do
+                {
+                    code += inc;
+                    pos = code & (_Entries.Length - 1);
+                    text2 = _Entries[pos];
+                }
+                while (text2 != null && !Equals(text, off, len, text2));
+            }
+            return pos;
+        }
+
+        /// <summary>Returns true if the String is in the set </summary>
+        private int GetSlot(string text)
+        {
+            int code = GetHashCode(text);
+            int pos = code & (_Entries.Length - 1);
+            char[] text2 = _Entries[pos];
+            if (text2 != null && !Equals(text, text2))
+            {
+                int inc = ((code >> 8) + code) | 1;
+                do
+                {
+                    code += inc;
+                    pos = code & (_Entries.Length - 1);
+                    text2 = _Entries[pos];
+                }
+                while (text2 != null && !Equals(text, text2));
+            }
+            return pos;
+        }
+
+        public bool Add(string text)
+        {
+            if (_ReadOnly) throw new NotSupportedException();
+            return Add(text.ToCharArray());
+        }
+
+        /// <summary>Add this char[] directly to the set.
+        /// If ignoreCase is true for this Set, the text array will be directly modified.
+        /// The user should never modify this text array after calling this method.
+        /// </summary>
+        public bool Add(char[] text)
+        {
+            if (_ReadOnly) throw new NotSupportedException();
+
+            if (_IgnoreCase)
+                for (int i = 0; i < text.Length; i++)
+                    text[i] = System.Char.ToLower(text[i]);
+            int slot = GetSlot(text, 0, text.Length);
+            if (_Entries[slot] != null)
+                return false;
+            _Entries[slot] = text;
+            _Count++;
+
+            if (_Count + (_Count >> 2) > _Entries.Length)
+            {
+                Rehash();
+            }
+
+            return true;
+        }
+
+        private bool Equals(char[] text1, int off, int len, char[] text2)
+        {
+            if (len != text2.Length)
+                return false;
+            if (_IgnoreCase)
+            {
+                for (int i = 0; i < len; i++)
+                {
+                    if (char.ToLower(text1[off + i]) != text2[i])
+                        return false;
+                }
+            }
+            else
+            {
+                for (int i = 0; i < len; i++)
+                {
+                    if (text1[off + i] != text2[i])
+                        return false;
+                }
+            }
+            return true;
+        }
+
+        private bool Equals(string text1, char[] text2)
+        {
+            int len = text1.Length;
+            if (len != text2.Length)
+                return false;
+            if (_IgnoreCase)
+            {
+                for (int i = 0; i < len; i++)
+                {
+                    if (char.ToLower(text1[i]) != text2[i])
+                        return false;
+                }
+            }
+            else
+            {
+                for (int i = 0; i < len; i++)
+                {
+                    if (text1[i] != text2[i])
+                        return false;
+                }
+            }
+            return true;
+        }
+
+        private void Rehash()
+        {
+            int newSize = 2 * _Entries.Length;
+            char[][] oldEntries = _Entries;
+            _Entries = new char[newSize][];
+
+            for (int i = 0; i < oldEntries.Length; i++)
+            {
+                char[] text = oldEntries[i];
+                if (text != null)
+                {
+                    // todo: could be faster... no need to compare strings on collision
+                    _Entries[GetSlot(text, 0, text.Length)] = text;
+                }
+            }
+        }
 
         private int GetHashCode(char[] text, int offset, int len)
-		{
-			int code = 0;
-			int stop = offset + len;
-			if (ignoreCase)
-			{
-				for (int i = offset; i < stop; i++)
-				{
-					code = code * 31 + System.Char.ToLower(text[i]);
-				}
-			}
-			else
-			{
-				for (int i = offset; i < stop; i++)
-				{
-					code = code * 31 + text[i];
-				}
-			}
-			return code;
-		}
-		
-		private int GetHashCode(System.String text)
-		{
-			int code = 0;
-			int len = text.Length;
-			if (ignoreCase)
-			{
-				for (int i = 0; i < len; i++)
-				{
-					code = code * 31 + System.Char.ToLower(text[i]);
-				}
-			}
-			else
-			{
-				for (int i = 0; i < len; i++)
-				{
-					code = code * 31 + text[i];
-				}
-			}
-			return code;
-		}
-		
-		public virtual int Size()
-		{
-			return count;
-		}
-		
-		public virtual bool IsEmpty()
-		{
-			return count == 0;
-		}
-		
-		public override bool Contains(System.Object o)
-		{
-			if (o is char[])
-			{
-				char[] text = (char[]) o;
-				return Contains(text, 0, text.Length);
-			}
-			return Contains(o.ToString());
-		}
-
-        //LUCENENET-414 (https://issues.apache.org/jira/browse/LUCENENET-414)
-        public virtual bool Add(object key, object value)
-        {
-            return Add(key);
-        }
-
-		public virtual bool Add(System.Object o)
-		{
-			if (o is char[])
-			{
-				return Add((char[]) o);
-			}
-
-            if (o is System.Collections.Hashtable)
-            {
-                foreach (string word in ((System.Collections.Hashtable)o).Keys)
-                {
-                    Add(word);
-                }
-                return true;
-            }
-
-			return Add(o.ToString());
-		}
-		
-		/// <summary> Returns an unmodifiable <see cref="CharArraySet" />. This allows to provide
-		/// unmodifiable views of internal sets for "read-only" use.
-		/// </summary>
-        /// <param name="set_Renamed">a set for which the unmodifiable set is returned.
-		/// </param>
-		/// <returns> an new unmodifiable <see cref="CharArraySet" />.
-		/// </returns>
-        /// <exception cref="NullReferenceException">NullReferenceException thrown 
-        /// if the given set is <c>null</c>.</exception>
-		public static CharArraySet UnmodifiableSet(CharArraySet set_Renamed)
-		{
-			if (set_Renamed == null)
-				throw new System.NullReferenceException("Given set is null");
-			/*
-			* Instead of delegating calls to the given set copy the low-level values to
-			* the unmodifiable Subclass
-			*/
-			return new UnmodifiableCharArraySet(set_Renamed.entries, set_Renamed.ignoreCase, set_Renamed.count);
-		}
-
-        /// <summary>The Iterator&lt;String&gt; for this set.  Strings are constructed on the fly, so
-		/// use <c>nextCharArray</c> for more efficient access. 
-		/// </summary>
-		public class CharArraySetIterator : System.Collections.IEnumerator
-		{
-			private void  InitBlock(CharArraySet enclosingInstance)
-			{
-				this.enclosingInstance = enclosingInstance;
-			}
-			private CharArraySet enclosingInstance;
-            /// <summary>Returns the next String, as a Set&lt;String&gt; would...
-			/// use nextCharArray() for better efficiency. 
-			/// </summary>
-			public virtual System.Object Current
-			{
-				get
-				{
-					return new System.String(NextCharArray());
-				}
-				
-			}
-			public CharArraySet Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			internal int pos = - 1;
-			internal char[] next_Renamed_Field;
-			internal CharArraySetIterator(CharArraySet enclosingInstance)
-			{
-				InitBlock(enclosingInstance);
-				GoNext();
-			}
-			
-			private void  GoNext()
-			{
-				next_Renamed_Field = null;
-				pos++;
-				while (pos < Enclosing_Instance.entries.Length && (next_Renamed_Field = Enclosing_Instance.entries[pos]) == null)
-					pos++;
-			}
-			
-			public virtual bool MoveNext()
-			{
-				return next_Renamed_Field != null;
-			}
-			
-			/// <summary>do not modify the returned char[] </summary>
-			public virtual char[] NextCharArray()
-			{
-				char[] ret = next_Renamed_Field;
-				GoNext();
-				return ret;
-			}
-			
-			public virtual void  Remove()
-			{
-				throw new System.NotSupportedException();
-			}
-			
-			virtual public void  Reset()
-			{
-                System.Diagnostics.Debug.Fail("Port issue:", "Need to implement this call, CharArraySetIterator.Reset()");  // {{Aroush-2.9
-			}
-		}
-		
-		
-		public new System.Collections.IEnumerator GetEnumerator()
-		{
-			return new CharArraySetIterator(this);
-		}
-		
-		/// <summary> Efficient unmodifiable <see cref="CharArraySet" />. This implementation does not
-		/// delegate calls to a given <see cref="CharArraySet" /> like
-		/// Collections.UnmodifiableSet(java.util.Set) does. Instead is passes
-		/// the internal representation of a <see cref="CharArraySet" /> to a super
-		/// constructor and overrides all mutators. 
-		/// </summary>
-		private sealed class UnmodifiableCharArraySet:CharArraySet
-		{
-			
-			internal UnmodifiableCharArraySet(char[][] entries, bool ignoreCase, int count):base(entries, ignoreCase, count)
-			{
-			}
-			
-			public override bool Add(System.Object o)
-			{
-				throw new System.NotSupportedException();
-			}
-			
-			public override bool AddAll(System.Collections.ICollection coll)
-			{
-				throw new System.NotSupportedException();
-			}
-			
-			public override bool Add(char[] text)
-			{
-				throw new System.NotSupportedException();
-			}
-			
-			public override bool Add(System.String text)
-			{
-				throw new System.NotSupportedException();
-			}
-		}
+        {
+            int code = 0;
+            int stop = offset + len;
+            if (_IgnoreCase)
+            {
+                for (int i = offset; i < stop; i++)
+                {
+                    code = code * 31 + char.ToLower(text[i]);
+                }
+            }
+            else
+            {
+                for (int i = offset; i < stop; i++)
+                {
+                    code = code * 31 + text[i];
+                }
+            }
+            return code;
+        }
+
+        private int GetHashCode(string text)
+        {
+            int code = 0;
+            int len = text.Length;
+            if (_IgnoreCase)
+            {
+                for (int i = 0; i < len; i++)
+                {
+                    code = code * 31 + char.ToLower(text[i]);
+                }
+            }
+            else
+            {
+                for (int i = 0; i < len; i++)
+                {
+                    code = code * 31 + text[i];
+                }
+            }
+            return code;
+        }
+
+        public int Count
+        {
+            get { return _Count; }
+        }
+
+        public bool IsEmpty
+        {
+            get { return _Count == 0; }
+        }
+
+        public bool Contains(object item)
+        {
+            if (item is char[])
+            {
+                char[] text = (char[])item;
+                return Contains(text, 0, text.Length);
+            }
+            return Contains(item.ToString());
+        }
+
+        public bool Add(object item)
+        {
+            return Add(item.ToString());
+        }
+
+        void ICollection<string>.Add(string item)
+        {
+            this.Add(item);
+        }
+
+        /// <summary>
+        /// Returns an unmodifiable <see cref="CharArraySet"/>.  This allows to provide
+        /// unmodifiable views of internal sets for "read-only" use
+        /// </summary>
+        /// <param name="set">A Set for which the unmodifiable set it returns.</param>
+        /// <returns>A new unmodifiable <see cref="CharArraySet"/></returns>
+        /// <throws>ArgumentNullException of the given set is <c>null</c></throws>
+        public static CharArraySet UnmodifiableSet(CharArraySet set)
+        {
+            if(set == null)
+                throw new ArgumentNullException("Given set is null");
+            if (set == EMPTY_SET)
+                return EMPTY_SET;
+            if (set._ReadOnly)
+                return set;
+
+            CharArraySet newSet = new CharArraySet(set._Entries, set._IgnoreCase, set.Count) {IsReadOnly = true};
+            return newSet;
+        }
+
+        /// <summary>
+        /// returns a copy of the given set as a <see cref="CharArraySet"/>.  If the given set
+        /// is a <see cref="CharArraySet"/> the ignoreCase property will be preserved.
+        /// </summary>
+        /// <param name="set">A set to copy</param>
+        /// <returns>a copy of the given set as a <see cref="CharArraySet"/>.  If the given set
+        /// is a <see cref="CharArraySet"/> the ignoreCase property will be preserved.</returns>
+        public static CharArraySet Copy<T>(ISet<T> set)
+        {
+            if (set == null)
+                throw new ArgumentNullException("set", "Given set is null!");
+            if (set == EMPTY_SET)
+                return EMPTY_SET;
+            bool ignoreCase = set is CharArraySet ? ((CharArraySet)set)._IgnoreCase : false;
+            var arrSet = new CharArraySet(set.Count, ignoreCase);
+            arrSet.AddItems(set);
+            return arrSet;
+        }
+
+        public void Clear()
+        {
+            throw new NotSupportedException("Remove not supported!");
+        }
+
+        public bool IsReadOnly
+        {
+            get { return _ReadOnly; }
+            private set { _ReadOnly = value; }
+        }
 
         /// <summary>Adds all of the elements in the specified collection to this collection </summary>
-        public virtual bool AddAll(System.Collections.ICollection items)
+        public void UnionWith(IEnumerable<string> other)
         {
-            bool added = false;
-            System.Collections.IEnumerator iter = items.GetEnumerator();
-            System.Object item;
-            while (iter.MoveNext())
+            if (_ReadOnly) throw new NotSupportedException();
+
+            foreach (string s in other)
             {
-                item = iter.Current;
-                added = Add(item);
+                Add(s.ToCharArray());
             }
-            return added;
         }
 
-        /// <summary>Removes all elements from the set </summary>
-        public virtual new bool Clear()
+        /// <summary>Wrapper that calls UnionWith</summary>
+        public void AddAll(IEnumerable<string> coll)
+        {
+            UnionWith(coll);
+        }
+
+        #region Unneeded methods
+        public void RemoveAll(ICollection<string> c)
         {
-            throw new System.NotSupportedException();
+            throw new NotSupportedException();
         }
 
-        /// <summary>Removes from this set all of its elements that are contained in the specified collection </summary>
-        public virtual bool RemoveAll(System.Collections.ICollection items)
+        public void RetainAll(ICollection<string> c)
         {
-            throw new System.NotSupportedException();
+            throw new NotSupportedException();
         }
 
-        /// <summary>Retains only the elements in this set that are contained in the specified collection </summary>
-        public bool RetainAll(System.Collections.ICollection coll)
+        void ICollection<string>.CopyTo(string[] array, int arrayIndex)
         {
-            throw new System.NotSupportedException();
+            throw new NotSupportedException();
+        }
+
+        void ISet<string>.IntersectWith(IEnumerable<string> other)
+        {
+            throw new NotSupportedException();
+        }
+
+        void ISet<string>.ExceptWith(IEnumerable<string> other)
+        {
+            throw new NotSupportedException();
+        }
+
+        void ISet<string>.SymmetricExceptWith(IEnumerable<string> other)
+        {
+            throw new NotSupportedException();
+        }
+
+        bool ISet<string>.IsSubsetOf(IEnumerable<string> other)
+        {
+            throw new NotSupportedException();
+        }
+
+        bool ISet<string>.IsSupersetOf(IEnumerable<string> other)
+        {
+            throw new NotSupportedException();
+        }
+
+        bool ISet<string>.IsProperSupersetOf(IEnumerable<string> other)
+        {
+            throw new NotSupportedException();
+        }
+
+        bool ISet<string>.IsProperSubsetOf(IEnumerable<string> other)
+        {
+            throw new NotSupportedException();
+        }
+
+        bool ISet<string>.Overlaps(IEnumerable<string> other)
+        {
+            throw new NotSupportedException();
+        }
+
+        bool ISet<string>.SetEquals(IEnumerable<string> other)
+        {
+            throw new NotSupportedException();
+        }
+
+        bool ICollection<string>.Remove(string item)
+        {
+            throw new NotSupportedException();
+        }
+        #endregion
+
+        /// <summary>
+        /// The IEnumerator&lt;String&gt; for this set.  Strings are constructed on the fly,
+        /// so use <c>nextCharArray</c> for more efficient access
+        /// </summary>
+        class CharArraySetEnumerator : IEnumerator<string>
+        {
+            CharArraySet _Creator;
+            int pos = -1;
+            char[] cur;
+
+            protected internal CharArraySetEnumerator(CharArraySet creator)
+            {
+                _Creator = creator;
+            }
+
+            public bool MoveNext()
+            {
+                cur = null;
+                pos++;
+                while (pos < _Creator._Entries.Length && (cur = _Creator._Entries[pos]) == null)
+                    pos++;
+                return cur != null;
+            }
+
+            /// <summary>do not modify the returned char[] </summary>
+            public char[] NextCharArray()
+            {
+                return cur;
+            }
+
+            public string Current
+            {
+                get { return new string(NextCharArray()); }
+            }
+
+            public void Dispose()
+            {
+            }
+
+            object System.Collections.IEnumerator.Current
+            {
+                get { return new string(NextCharArray()); }
+            }
+
+            public void Reset()
+            {
+                throw new NotImplementedException();
+            }
+        }
+
+        public IEnumerator<string> StringEnumerator()
+        {
+            return new CharArraySetEnumerator(this);
+        }
+
+        public IEnumerator<string> GetEnumerator()
+        {
+            return new CharArraySetEnumerator(this);
+        }
+
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return GetEnumerator();
         }
     }
+
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Analysis/CharFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/CharFilter.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/CharFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/CharFilter.cs Tue Feb 28 22:43:08 2012
@@ -29,10 +29,10 @@ namespace Lucene.Net.Analysis
 	/// <version>  $Id$
 	/// 
 	/// </version>
-	public abstract class CharFilter:CharStream
+	public abstract class CharFilter : CharStream
 	{
         private long currentPosition = -1;
-		
+	    private bool isDisposed;
 		protected internal CharStream input;
 		
 		protected internal CharFilter(CharStream in_Renamed) : base(in_Renamed)
@@ -40,15 +40,11 @@ namespace Lucene.Net.Analysis
 			input = in_Renamed;
 		}
 		
-		/// <summary> Subclass may want to override to correct the current offset.
-		/// 
-		/// </summary>
-		/// <param name="currentOff">current offset
-		/// </param>
-		/// <returns> corrected offset
-		/// </returns>
-		public /*protected internal*/ virtual int Correct(int currentOff)
-		{
+		/// <summary>Subclass may want to override to correct the current offset.</summary>
+		/// <param name="currentOff">current offset</param>
+		/// <returns>corrected offset</returns>
+		protected internal virtual int Correct(int currentOff)
+        {
 			return currentOff;
 		}
 		
@@ -59,30 +55,42 @@ namespace Lucene.Net.Analysis
 		{
 			return input.CorrectOffset(Correct(currentOff));
 		}
+
+        protected override void Dispose(bool disposing)
+        {
+            if (isDisposed) return;
+
+            if (disposing)
+            {
+                if (input != null)
+                {
+                    input.Close();
+                }
+            }
+
+            input = null;
+            isDisposed = true;
+            base.Dispose(disposing);
+        }
 		
-		public override void  Close()
-		{
-			input.Close();
-		}
-		
-		public  override int Read(System.Char[] cbuf, int off, int len)
-		{
+		public override int Read(System.Char[] cbuf, int off, int len)
+        {
 			return input.Read(cbuf, off, len);
 		}
 		
 		public bool MarkSupported()
-		{
+        {
             return input.BaseStream.CanSeek;
 		}
 		
-		public void  Mark(int readAheadLimit)
-		{
+		public void Mark(int readAheadLimit)
+        {
             currentPosition = input.BaseStream.Position;
 			input.BaseStream.Position = readAheadLimit;
 		}
 		
-		public void  Reset()
-		{
+		public void Reset()
+        {
 			input.BaseStream.Position = currentPosition;
 		}
 	}

Modified: incubator/lucene.net/trunk/src/core/Analysis/CharReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/CharReader.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/CharReader.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/CharReader.cs Tue Feb 28 22:43:08 2012
@@ -28,7 +28,9 @@ namespace Lucene.Net.Analysis
 	public sealed class CharReader:CharStream
 	{
         private long currentPosition = -1;
-		
+
+	    private bool isDisposed;
+
 		internal System.IO.StreamReader input;
 		
 		public static CharStream Get(System.IO.TextReader input)
@@ -53,11 +55,23 @@ namespace Lucene.Net.Analysis
 		{
 			return currentOff;
 		}
-		
-		public override void  Close()
-		{
-			input.Close();
-		}
+
+        protected override void Dispose(bool disposing)
+        {
+            if (isDisposed) return;
+
+            if (disposing)
+            {
+                if (input != null)
+                {
+                    input.Close();
+                }
+            }
+
+            input = null;
+            isDisposed = true;
+            base.Dispose(disposing);
+        }
 		
 		public  override int Read(System.Char[] cbuf, int off, int len)
 		{

Modified: incubator/lucene.net/trunk/src/core/Analysis/CharStream.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/CharStream.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/CharStream.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/CharStream.cs Tue Feb 28 22:43:08 2012
@@ -29,9 +29,9 @@ namespace Lucene.Net.Analysis
 	/// reported in the tokens match the character offsets of the
 	/// original Reader.
     /// </summary>
-	public abstract class CharStream:System.IO.StreamReader
+	public abstract class CharStream : System.IO.StreamReader
 	{
-        public CharStream(System.IO.StreamReader reader) : base(reader.BaseStream)
+	    protected CharStream(System.IO.StreamReader reader) : base(reader.BaseStream)
         {
         }
 		

Modified: incubator/lucene.net/trunk/src/core/Analysis/CharTokenizer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/CharTokenizer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/CharTokenizer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/CharTokenizer.cs Tue Feb 28 22:43:08 2012
@@ -27,22 +27,22 @@ namespace Lucene.Net.Analysis
 	/// <summary>An abstract base class for simple, character-oriented tokenizers.</summary>
 	public abstract class CharTokenizer:Tokenizer
 	{
-		public CharTokenizer(System.IO.TextReader input):base(input)
+	    protected CharTokenizer(System.IO.TextReader input):base(input)
 		{
-			offsetAtt = (OffsetAttribute) AddAttribute(typeof(OffsetAttribute));
-			termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
+			offsetAtt = AddAttribute<OffsetAttribute>();
+            termAtt = AddAttribute<TermAttribute>();
 		}
-		
-		public CharTokenizer(AttributeSource source, System.IO.TextReader input):base(source, input)
+
+	    protected CharTokenizer(AttributeSource source, System.IO.TextReader input):base(source, input)
 		{
-			offsetAtt = (OffsetAttribute) AddAttribute(typeof(OffsetAttribute));
-			termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
+            offsetAtt = AddAttribute<OffsetAttribute>();
+            termAtt = AddAttribute<TermAttribute>();
 		}
-		
-		public CharTokenizer(AttributeFactory factory, System.IO.TextReader input):base(factory, input)
+
+	    protected CharTokenizer(AttributeFactory factory, System.IO.TextReader input):base(factory, input)
 		{
-			offsetAtt = (OffsetAttribute) AddAttribute(typeof(OffsetAttribute));
-			termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
+            offsetAtt = AddAttribute<OffsetAttribute>();
+            termAtt = AddAttribute<TermAttribute>();
 		}
 		
 		private int offset = 0, bufferIndex = 0, dataLen = 0;
@@ -128,24 +128,6 @@ namespace Lucene.Net.Analysis
 			offsetAtt.SetOffset(finalOffset, finalOffset);
 		}
 		
-		/// <deprecated> Will be removed in Lucene 3.0. This method is final, as it should
-		/// not be overridden. Delegates to the backwards compatibility layer. 
-		/// </deprecated>
-        [Obsolete("Will be removed in Lucene 3.0. This method is final, as it should not be overridden. Delegates to the backwards compatibility layer. ")]
-		public override Token Next(Token reusableToken)
-		{
-			return base.Next(reusableToken);
-		}
-		
-		/// <deprecated> Will be removed in Lucene 3.0. This method is final, as it should
-		/// not be overridden. Delegates to the backwards compatibility layer. 
-		/// </deprecated>
-        [Obsolete("Will be removed in Lucene 3.0. This method is final, as it should not be overridden. Delegates to the backwards compatibility layer. ")]
-		public override Token Next()
-		{
-			return base.Next();
-		}
-		
 		public override void  Reset(System.IO.TextReader input)
 		{
 			base.Reset(input);

Modified: incubator/lucene.net/trunk/src/core/Analysis/ISOLatin1AccentFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/ISOLatin1AccentFilter.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/ISOLatin1AccentFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/ISOLatin1AccentFilter.cs Tue Feb 28 22:43:08 2012
@@ -29,15 +29,17 @@ namespace Lucene.Net.Analysis
 	/// <p/>
 	/// 
 	/// </summary>
-	/// <deprecated> in favor of <see cref="ASCIIFoldingFilter" /> which covers a superset 
-	/// of Latin 1. This class will be removed in Lucene 3.0.
+	/// <deprecated> If you build a new index, use <see cref="ASCIIFoldingFilter"/>
+	/// which covers a superset of Latin 1.
+	/// This class is included for use with existing indexes and will be removed
+	/// in a future release (possible Lucene 4.0)
 	/// </deprecated>
-    [Obsolete("in favor of ASCIIFoldingFilter which covers a superset of Latin 1. This class will be removed in Lucene 3.0.")]
-	public class ISOLatin1AccentFilter:TokenFilter
+    [Obsolete("If you build a new index, use ASCIIFoldingFilter which covers a superset of Latin 1.  This class is included for use with existing indexes and will be removed in a future release (possible Lucene 4.0).")]
+	public class ISOLatin1AccentFilter : TokenFilter
 	{
 		public ISOLatin1AccentFilter(TokenStream input):base(input)
 		{
-			termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
+            termAtt = AddAttribute<TermAttribute>();
 		}
 		
 		private char[] output = new char[256];
@@ -68,24 +70,6 @@ namespace Lucene.Net.Analysis
 				return false;
 		}
 		
-		/// <deprecated> Will be removed in Lucene 3.0. This method is final, as it should
-		/// not be overridden. Delegates to the backwards compatibility layer. 
-		/// </deprecated>
-        [Obsolete("Will be removed in Lucene 3.0. This method is final, as it should not be overridden. Delegates to the backwards compatibility layer. ")]
-		public override Token Next(Token reusableToken)
-		{
-			return base.Next(reusableToken);
-		}
-		
-		/// <deprecated> Will be removed in Lucene 3.0. This method is final, as it should
-		/// not be overridden. Delegates to the backwards compatibility layer. 
-		/// </deprecated>
-        [Obsolete("Will be removed in Lucene 3.0. This method is final, as it should not be overridden. Delegates to the backwards compatibility layer. ")]
-		public override Token Next()
-		{
-			return base.Next();
-		}
-		
 		/// <summary> To replace accented characters in a String by unaccented equivalents.</summary>
 		public void  RemoveAccents(char[] input, int length)
 		{

Modified: incubator/lucene.net/trunk/src/core/Analysis/KeywordAnalyzer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/KeywordAnalyzer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/KeywordAnalyzer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/KeywordAnalyzer.cs Tue Feb 28 22:43:08 2012
@@ -27,7 +27,7 @@ namespace Lucene.Net.Analysis
 	{
 		public KeywordAnalyzer()
 		{
-			SetOverridesTokenStreamMethod(typeof(KeywordAnalyzer));
+            SetOverridesTokenStreamMethod<KeywordAnalyzer>();
 		}
 		public override TokenStream TokenStream(System.String fieldName, System.IO.TextReader reader)
 		{

Modified: incubator/lucene.net/trunk/src/core/Analysis/KeywordTokenizer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/KeywordTokenizer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/KeywordTokenizer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/KeywordTokenizer.cs Tue Feb 28 22:43:08 2012
@@ -25,7 +25,7 @@ namespace Lucene.Net.Analysis
 {
 	
 	/// <summary> Emits the entire input as a single token.</summary>
-	public class KeywordTokenizer:Tokenizer
+	public sealed class KeywordTokenizer:Tokenizer
 	{
 		
 		private const int DEFAULT_BUFFER_SIZE = 256;
@@ -57,8 +57,8 @@ namespace Lucene.Net.Analysis
 		private void  Init(int bufferSize)
 		{
 			this.done = false;
-			termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
-			offsetAtt = (OffsetAttribute) AddAttribute(typeof(OffsetAttribute));
+            termAtt = AddAttribute<TermAttribute>();
+            offsetAtt = AddAttribute<OffsetAttribute>();
 			termAtt.ResizeTermBuffer(bufferSize);
 		}
 		
@@ -93,24 +93,6 @@ namespace Lucene.Net.Analysis
 			offsetAtt.SetOffset(finalOffset, finalOffset);
 		}
 		
-		/// <deprecated> Will be removed in Lucene 3.0. This method is final, as it should
-		/// not be overridden. Delegates to the backwards compatibility layer. 
-		/// </deprecated>
-        [Obsolete("Will be removed in Lucene 3.0. This method is final, as it should not be overridden. Delegates to the backwards compatibility layer. ")]
-		public override Token Next(Token reusableToken)
-		{
-			return base.Next(reusableToken);
-		}
-		
-		/// <deprecated> Will be removed in Lucene 3.0. This method is final, as it should
-		/// not be overridden. Delegates to the backwards compatibility layer. 
-		/// </deprecated>
-        [Obsolete("Will be removed in Lucene 3.0. This method is final, as it should not be overridden. Delegates to the backwards compatibility layer. ")]
-		public override Token Next()
-		{
-			return base.Next();
-		}
-		
 		public override void  Reset(System.IO.TextReader input)
 		{
 			base.Reset(input);

Modified: incubator/lucene.net/trunk/src/core/Analysis/LengthFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/LengthFilter.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/LengthFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/LengthFilter.cs Tue Feb 28 22:43:08 2012
@@ -22,12 +22,7 @@ using TermAttribute = Lucene.Net.Analysi
 namespace Lucene.Net.Analysis
 {
 	
-	/// <summary> Removes words that are too long or too short from the stream.
-	/// 
-	/// 
-	/// </summary>
-	/// <version>  $Id: LengthFilter.java 807201 2009-08-24 13:22:34Z markrmiller $
-	/// </version>
+	/// <summary>Removes words that are too long or too short from the stream.</summary>
 	public sealed class LengthFilter:TokenFilter
 	{
 		
@@ -39,11 +34,12 @@ namespace Lucene.Net.Analysis
 		/// <summary> Build a filter that removes words that are too long or too
 		/// short from the text.
 		/// </summary>
-		public LengthFilter(TokenStream in_Renamed, int min, int max):base(in_Renamed)
+		public LengthFilter(TokenStream in_Renamed, int min, int max)
+            : base(in_Renamed)
 		{
 			this.min = min;
 			this.max = max;
-			termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
+            termAtt = AddAttribute<TermAttribute>();
 		}
 		
 		/// <summary> Returns the next input Token whose term() is the right len</summary>
@@ -59,7 +55,7 @@ namespace Lucene.Net.Analysis
 				}
 				// note: else we ignore it but should we index each part of it?
 			}
-			// reached EOS -- return null
+			// reached EOS -- return false
 			return false;
 		}
 	}

Modified: incubator/lucene.net/trunk/src/core/Analysis/LowerCaseFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/LowerCaseFilter.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/LowerCaseFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/LowerCaseFilter.cs Tue Feb 28 22:43:08 2012
@@ -22,16 +22,12 @@ using TermAttribute = Lucene.Net.Analysi
 namespace Lucene.Net.Analysis
 {
 	
-	/// <summary> Normalizes token text to lower case.
-	/// 
-	/// </summary>
-	/// <version>  $Id: LowerCaseFilter.java 797665 2009-07-24 21:45:48Z buschmi $
-	/// </version>
+	/// <summary>Normalizes token text to lower case.</summary>
 	public sealed class LowerCaseFilter:TokenFilter
 	{
 		public LowerCaseFilter(TokenStream in_Renamed):base(in_Renamed)
 		{
-			termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
+            termAtt = AddAttribute<TermAttribute>();
 		}
 		
 		private TermAttribute termAtt;

Modified: incubator/lucene.net/trunk/src/core/Analysis/MappingCharFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/MappingCharFilter.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/MappingCharFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/MappingCharFilter.cs Tue Feb 28 22:43:08 2012
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 namespace Lucene.Net.Analysis
 {
@@ -25,12 +26,10 @@ namespace Lucene.Net.Analysis
 	/// stream, and correcting the resulting changes to the
 	/// offsets.
 	/// </summary>
-	public class MappingCharFilter:BaseCharFilter
+	public class MappingCharFilter : BaseCharFilter
 	{
-		
 		private NormalizeCharMap normMap;
-		//private LinkedList<Character> buffer;
-		private System.Collections.ArrayList buffer;
+		private System.Collections.Generic.LinkedList<char> buffer;
 		private System.String replacement;
 		private int charPointer;
 		private int nextCharCounter;
@@ -59,7 +58,9 @@ namespace Lucene.Net.Analysis
 				int firstChar = NextChar();
 				if (firstChar == - 1)
 					return - 1;
-				NormalizeCharMap nm = normMap.submap != null?(NormalizeCharMap) normMap.submap[CharacterCache.ValueOf((char) firstChar)]:null;
+			    NormalizeCharMap nm = normMap.submap != null
+			                              ? normMap.submap[(char) firstChar]
+			                              : null;
 				if (nm == null)
 					return firstChar;
 				NormalizeCharMap result = Match(nm);
@@ -69,7 +70,7 @@ namespace Lucene.Net.Analysis
 				charPointer = 0;
 				if (result.diff != 0)
 				{
-					int prevCumulativeDiff = GetLastCumulativeDiff();
+					int prevCumulativeDiff = LastCumulativeDiff;
 					if (result.diff < 0)
 					{
 						for (int i = 0; i < - result.diff; i++)
@@ -88,10 +89,9 @@ namespace Lucene.Net.Analysis
 			nextCharCounter++;
 			if (buffer != null && !(buffer.Count == 0))
 			{
-				System.Object tempObject;
-				tempObject = buffer[0];
-				buffer.RemoveAt(0);
-				return ((System.Char) tempObject);
+				char tempObject = buffer.First.Value;
+				buffer.RemoveFirst();
+				return (tempObject);
 			}
 			return input.Read();
 		}
@@ -101,18 +101,18 @@ namespace Lucene.Net.Analysis
 			nextCharCounter--;
 			if (buffer == null)
 			{
-				buffer = new System.Collections.ArrayList();
+				buffer = new LinkedList<char>();
 			}
-			buffer.Insert(0, (char) c);
+			buffer.AddFirst((char)c);
 		}
 		
 		private void  PushLastChar(int c)
 		{
 			if (buffer == null)
 			{
-				buffer = new System.Collections.ArrayList();
+                buffer = new LinkedList<char>();
 			}
-			buffer.Insert(buffer.Count, (char) c);
+			buffer.AddLast((char)c);
 		}
 		
 		private NormalizeCharMap Match(NormalizeCharMap map)
@@ -123,7 +123,7 @@ namespace Lucene.Net.Analysis
 				int chr = NextChar();
 				if (chr != - 1)
 				{
-					NormalizeCharMap subMap = (NormalizeCharMap) map.submap[CharacterCache.ValueOf((char) chr)];
+					NormalizeCharMap subMap = map.submap[(char)chr];
 					if (subMap != null)
 					{
 						result = Match(subMap);

Modified: incubator/lucene.net/trunk/src/core/Analysis/NormalizeCharMap.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/NormalizeCharMap.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/NormalizeCharMap.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/NormalizeCharMap.cs Tue Feb 28 22:43:08 2012
@@ -16,6 +16,7 @@
  */
 
 using System;
+using Lucene.Net.Support;
 
 namespace Lucene.Net.Analysis
 {
@@ -25,9 +26,7 @@ namespace Lucene.Net.Analysis
 	/// </summary>
 	public class NormalizeCharMap
 	{
-		
-		//Map<Character, NormalizeMap> submap;
-		internal System.Collections.IDictionary submap;
+		internal System.Collections.Generic.IDictionary<char, NormalizeCharMap> submap;
 		internal System.String normStr;
 		internal int diff;
 		
@@ -49,9 +48,9 @@ namespace Lucene.Net.Analysis
 				char c = singleMatch[i];
 				if (currMap.submap == null)
 				{
-					currMap.submap = new System.Collections.Hashtable(1);
+					currMap.submap = new HashMap<char, NormalizeCharMap>(1);
 				}
-				NormalizeCharMap map = (NormalizeCharMap) currMap.submap[CharacterCache.ValueOf(c)];
+				NormalizeCharMap map = currMap.submap[c];
 				if (map == null)
 				{
 					map = new NormalizeCharMap();

Modified: incubator/lucene.net/trunk/src/core/Analysis/NumericTokenStream.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/NumericTokenStream.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/NumericTokenStream.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/NumericTokenStream.cs Tue Feb 28 22:43:08 2012
@@ -16,15 +16,10 @@
  */
 
 using System;
-
+using Lucene.Net.Search;
 using AttributeSource = Lucene.Net.Util.AttributeSource;
 using NumericUtils = Lucene.Net.Util.NumericUtils;
 using NumericField = Lucene.Net.Documents.NumericField;
-// for javadocs
-using NumericRangeQuery = Lucene.Net.Search.NumericRangeQuery;
-using NumericRangeFilter = Lucene.Net.Search.NumericRangeFilter;
-using SortField = Lucene.Net.Search.SortField;
-using FieldCache = Lucene.Net.Search.FieldCache;
 // javadocs
 using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
 using TypeAttribute = Lucene.Net.Analysis.Tokenattributes.TypeAttribute;
@@ -34,8 +29,8 @@ namespace Lucene.Net.Analysis
 {
 	
 	/// <summary> <b>Expert:</b> This class provides a <see cref="TokenStream" />
-	/// for indexing numeric values that can be used by <see cref="NumericRangeQuery" />
-	/// or <see cref="NumericRangeFilter" />.
+	/// for indexing numeric values that can be used by <see cref="NumericRangeQuery{T}" />
+    /// or <see cref="NumericRangeFilter{T}" />.
 	/// 
 	/// <p/>Note that for simple usage, <see cref="NumericField" /> is
 	/// recommended.  <see cref="NumericField" /> disables norms and
@@ -81,7 +76,7 @@ namespace Lucene.Net.Analysis
 	/// than one numeric field, use a separate <c>NumericTokenStream</c>
 	/// instance for each.<p/>
 	/// 
-	/// <p/>See <see cref="NumericRangeQuery" /> for more details on the
+    /// <p/>See <see cref="NumericRangeQuery{T}" /> for more details on the
 	/// <a href="../search/NumericRangeQuery.html#precisionStepDesc"><c>precisionStep</c></a>
 	/// parameter as well as how numeric fields work under the hood.<p/>
 	/// 
@@ -89,13 +84,13 @@ namespace Lucene.Net.Analysis
 	/// might change in incompatible ways in the next release.</font>
 	///   Since 2.9
 	/// </summary>
-	public sealed class NumericTokenStream:TokenStream
+	public sealed class NumericTokenStream : TokenStream
 	{
 		private void  InitBlock()
 		{
-			termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
-			typeAtt = (TypeAttribute) AddAttribute(typeof(TypeAttribute));
-			posIncrAtt = (PositionIncrementAttribute) AddAttribute(typeof(PositionIncrementAttribute));
+            termAtt = AddAttribute<TermAttribute>();
+            typeAtt = AddAttribute<TypeAttribute>();
+            posIncrAtt = AddAttribute<PositionIncrementAttribute>();
 		}
 		
 		/// <summary>The full precision token gets this token type assigned. </summary>
@@ -214,6 +209,11 @@ namespace Lucene.Net.Analysis
 				throw new System.SystemException("call set???Value() before usage");
 			shift = 0;
 		}
+
+        protected override void Dispose(bool disposing)
+        {
+            // Do nothing.
+        }
 		
 		// @Override
 		public override bool IncrementToken()

Modified: incubator/lucene.net/trunk/src/core/Analysis/PerFieldAnalyzerWrapper.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/PerFieldAnalyzerWrapper.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/PerFieldAnalyzerWrapper.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/PerFieldAnalyzerWrapper.cs Tue Feb 28 22:43:08 2012
@@ -16,6 +16,8 @@
  */
 
 using System;
+using System.Collections.Generic;
+using Lucene.Net.Support;
 
 namespace Lucene.Net.Analysis
 {
@@ -42,7 +44,7 @@ namespace Lucene.Net.Analysis
 	public class PerFieldAnalyzerWrapper:Analyzer
 	{
 		private Analyzer defaultAnalyzer;
-		private System.Collections.IDictionary analyzerMap = new System.Collections.Hashtable();
+		private IDictionary<string, Analyzer> analyzerMap = new HashMap<string, Analyzer>();
 		
 		
 		/// <summary> Constructs with default analyzer.
@@ -51,7 +53,8 @@ namespace Lucene.Net.Analysis
 		/// <param name="defaultAnalyzer">Any fields not specifically
 		/// defined to use a different analyzer will use the one provided here.
 		/// </param>
-		public PerFieldAnalyzerWrapper(Analyzer defaultAnalyzer):this(defaultAnalyzer, null)
+		public PerFieldAnalyzerWrapper(Analyzer defaultAnalyzer)
+            : this(defaultAnalyzer, null)
 		{
 		}
 		
@@ -65,18 +68,15 @@ namespace Lucene.Net.Analysis
 		/// <param name="fieldAnalyzers">a Map (String field name to the Analyzer) to be 
 		/// used for those fields 
 		/// </param>
-		public PerFieldAnalyzerWrapper(Analyzer defaultAnalyzer, System.Collections.IDictionary fieldAnalyzers)
+        public PerFieldAnalyzerWrapper(Analyzer defaultAnalyzer, IDictionary<string, Analyzer> fieldAnalyzers)
 		{
 			this.defaultAnalyzer = defaultAnalyzer;
 			if (fieldAnalyzers != null)
 			{
-				System.Collections.ArrayList keys = new System.Collections.ArrayList(fieldAnalyzers.Keys);
-				System.Collections.ArrayList values = new System.Collections.ArrayList(fieldAnalyzers.Values);
-
-				for (int i=0; i < keys.Count; i++)
-					analyzerMap[keys[i]] = values[i];
+				foreach(var entry in fieldAnalyzers)
+					analyzerMap[entry.Key] = entry.Value;
 			}
-			SetOverridesTokenStreamMethod(typeof(PerFieldAnalyzerWrapper));
+            SetOverridesTokenStreamMethod<PerFieldAnalyzerWrapper>();
 		}
 		
 		
@@ -94,7 +94,7 @@ namespace Lucene.Net.Analysis
 		
 		public override TokenStream TokenStream(System.String fieldName, System.IO.TextReader reader)
 		{
-			Analyzer analyzer = (Analyzer) analyzerMap[fieldName];
+			Analyzer analyzer = analyzerMap[fieldName];
 			if (analyzer == null)
 			{
 				analyzer = defaultAnalyzer;
@@ -103,7 +103,7 @@ namespace Lucene.Net.Analysis
 			return analyzer.TokenStream(fieldName, reader);
 		}
 		
-		public override TokenStream ReusableTokenStream(System.String fieldName, System.IO.TextReader reader)
+		public override TokenStream ReusableTokenStream(string fieldName, System.IO.TextReader reader)
 		{
 			if (overridesTokenStreamMethod)
 			{
@@ -112,7 +112,7 @@ namespace Lucene.Net.Analysis
 				// tokenStream but not reusableTokenStream
 				return TokenStream(fieldName, reader);
 			}
-			Analyzer analyzer = (Analyzer) analyzerMap[fieldName];
+			Analyzer analyzer = analyzerMap[fieldName];
 			if (analyzer == null)
 				analyzer = defaultAnalyzer;
 			
@@ -120,9 +120,9 @@ namespace Lucene.Net.Analysis
 		}
 		
 		/// <summary>Return the positionIncrementGap from the analyzer assigned to fieldName </summary>
-		public override int GetPositionIncrementGap(System.String fieldName)
+		public override int GetPositionIncrementGap(string fieldName)
 		{
-			Analyzer analyzer = (Analyzer) analyzerMap[fieldName];
+			Analyzer analyzer = analyzerMap[fieldName];
 			if (analyzer == null)
 				analyzer = defaultAnalyzer;
 			return analyzer.GetPositionIncrementGap(fieldName);
@@ -131,9 +131,7 @@ namespace Lucene.Net.Analysis
         /// <summary> Return the offsetGap from the analyzer assigned to field </summary>
         public override int GetOffsetGap(Lucene.Net.Documents.Fieldable field)
         {
-            Analyzer analyzer = (Analyzer)analyzerMap[field.Name()];
-            if (analyzer == null)
-                analyzer = defaultAnalyzer;
+            Analyzer analyzer = analyzerMap[field.Name()] ?? defaultAnalyzer;
             return analyzer.GetOffsetGap(field);
         }
 		

Modified: incubator/lucene.net/trunk/src/core/Analysis/PorterStemFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/PorterStemFilter.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/PorterStemFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/PorterStemFilter.cs Tue Feb 28 22:43:08 2012
@@ -48,7 +48,7 @@ namespace Lucene.Net.Analysis
 		public PorterStemFilter(TokenStream in_Renamed):base(in_Renamed)
 		{
 			stemmer = new PorterStemmer();
-			termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
+            termAtt = AddAttribute<TermAttribute>();
 		}
 		
 		public override bool IncrementToken()

Modified: incubator/lucene.net/trunk/src/core/Analysis/SimpleAnalyzer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/SimpleAnalyzer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/SimpleAnalyzer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/SimpleAnalyzer.cs Tue Feb 28 22:43:08 2012
@@ -24,7 +24,7 @@ namespace Lucene.Net.Analysis
 	/// with <see cref="LowerCaseFilter" /> 
 	/// </summary>
 	
-	public sealed class SimpleAnalyzer:Analyzer
+	public sealed class SimpleAnalyzer : Analyzer
 	{
 		public override TokenStream TokenStream(System.String fieldName, System.IO.TextReader reader)
 		{

Modified: incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardAnalyzer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardAnalyzer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardAnalyzer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardAnalyzer.cs Tue Feb 28 22:43:08 2012
@@ -17,7 +17,9 @@
 
 using System;
 using System.Collections;
+using System.Collections.Generic;
 using Lucene.Net.Analysis;
+using Lucene.Net.Util;
 using Version = Lucene.Net.Util.Version;
 
 namespace Lucene.Net.Analysis.Standard
@@ -36,106 +38,28 @@ namespace Lucene.Net.Analysis.Standard
 	/// <item>As of 2.4, Tokens incorrectly identified as acronyms are corrected (see
 	/// <a href="https://issues.apache.org/jira/browse/LUCENE-1068">LUCENE-1608</a>)</item>
 	/// </list>
-	/// 
 	/// </summary>
-	/// <version>  $Id: StandardAnalyzer.java 829134 2009-10-23 17:18:53Z mikemccand $
-	/// </version>
 	public class StandardAnalyzer : Analyzer
 	{
-		private System.Collections.Hashtable stopSet;
+		private ISet<string> stopSet;
 		
 		/// <summary> Specifies whether deprecated acronyms should be replaced with HOST type.
-		/// This is false by default to support backward compatibility.
-		/// 
-		/// </summary>
-		/// <deprecated> this should be removed in the next release (3.0).
-		/// 
-		/// See https://issues.apache.org/jira/browse/LUCENE-1068
-		/// </deprecated>
-        [Obsolete("this should be removed in the next release (3.0).")]
-		private bool replaceInvalidAcronym = defaultReplaceInvalidAcronym;
-		
-		private static bool defaultReplaceInvalidAcronym;
-		private bool enableStopPositionIncrements;
-		
-		// @deprecated
-        [Obsolete]
-		private bool useDefaultStopPositionIncrements;
-		
-		/// <summary> </summary>
-		/// <returns> true if new instances of StandardTokenizer will
-		/// replace mischaracterized acronyms
-		/// 
-		/// See https://issues.apache.org/jira/browse/LUCENE-1068
-		/// </returns>
-		/// <deprecated> This will be removed (hardwired to true) in 3.0
-		/// </deprecated>
-        [Obsolete("This will be removed (hardwired to true) in 3.0")]
-		public static bool GetDefaultReplaceInvalidAcronym()
-		{
-			return defaultReplaceInvalidAcronym;
-		}
-		
-		/// <summary> </summary>
-		/// <param name="replaceInvalidAcronym">Set to true to have new
-		/// instances of StandardTokenizer replace mischaracterized
-		/// acronyms by default.  Set to false to preserve the
-		/// previous (before 2.4) buggy behavior.  Alternatively,
-		/// set the system property
-		/// Lucene.Net.Analysis.Standard.StandardAnalyzer.replaceInvalidAcronym
-		/// to false.
-		/// 
-		/// See https://issues.apache.org/jira/browse/LUCENE-1068
-		/// </param>
-		/// <deprecated> This will be removed (hardwired to true) in 3.0
-		/// </deprecated>
-        [Obsolete("This will be removed (hardwired to true) in 3.0")]
-		public static void  SetDefaultReplaceInvalidAcronym(bool replaceInvalidAcronym)
-		{
-			defaultReplaceInvalidAcronym = replaceInvalidAcronym;
-		}
-		
-		
-		/// <summary>An array containing some common English words that are usually not
-		/// useful for searching. 
+        /// See <a href="https://issues.apache.org/jira/browse/LUCENE-1068">https://issues.apache.org/jira/browse/LUCENE-1068</a>
 		/// </summary>
-		/// <deprecated> Use <see cref="STOP_WORDS_SET" /> instead 
-		/// </deprecated>
-        [Obsolete("Use STOP_WORDS_SET instead ")]
-		public static readonly System.String[] STOP_WORDS;
-		
+		private bool replaceInvalidAcronym, enableStopPositionIncrements;
+
 		/// <summary>An unmodifiable set containing some common English words that are usually not
 		/// useful for searching. 
 		/// </summary>
-		public static readonly System.Collections.Hashtable STOP_WORDS_SET;
-		
-		/// <summary>Builds an analyzer with the default stop words 
-		/// (<see cref="STOP_WORDS_SET" />).
-		/// </summary>
-		/// <deprecated> Use <see cref="StandardAnalyzer(Version)" /> instead. 
-		/// </deprecated>
-        [Obsolete("Use StandardAnalyzer(Version) instead")]
-		public StandardAnalyzer():this(Version.LUCENE_24, STOP_WORDS_SET)
-		{
-		}
+		public static readonly ISet<string> STOP_WORDS_SET;
+		private Version matchVersion;
 		
 		/// <summary>Builds an analyzer with the default stop words (<see cref="STOP_WORDS" />).
 		/// </summary>
-		/// <param name="matchVersion">Lucene version to match See <see cref="Version">above</see> />
-		///
-		/// </param>
-		public StandardAnalyzer(Version matchVersion):this(matchVersion, STOP_WORDS_SET)
-		{
-		}
-		
-		/// <summary>Builds an analyzer with the given stop words.</summary>
-		/// <deprecated> Use <see cref="StandardAnalyzer(Version, Hashtable)" />
-		/// instead 
-		/// </deprecated>
-        [Obsolete("Use StandardAnalyzer(Version, Set) instead")]
-		public StandardAnalyzer(System.Collections.Hashtable stopWords):this(Version.LUCENE_24, stopWords)
-		{
-		}
+		/// <param name="matchVersion">Lucene version to match see <see cref="Version">above</see></param>
+		public StandardAnalyzer(Version matchVersion)
+            : this(matchVersion, STOP_WORDS_SET)
+		{ }
 		
 		/// <summary>Builds an analyzer with the given stop words.</summary>
         /// <param name="matchVersion">Lucene version to match See <see cref="Version">above</see> />
@@ -143,31 +67,15 @@ namespace Lucene.Net.Analysis.Standard
 		/// </param>
 		/// <param name="stopWords">stop words 
 		/// </param>
-		public StandardAnalyzer(Version matchVersion, System.Collections.Hashtable stopWords)
+		public StandardAnalyzer(Version matchVersion, ISet<string> stopWords)
 		{
 			stopSet = stopWords;
-			Init(matchVersion);
-		}
-		
-		/// <summary>Builds an analyzer with the given stop words.</summary>
-		/// <deprecated> Use <see cref="StandardAnalyzer(Version, Hashtable)" /> instead 
-		/// </deprecated>
-        [Obsolete("Use StandardAnalyzer(Version, Set) instead")]
-		public StandardAnalyzer(System.String[] stopWords):this(Version.LUCENE_24, StopFilter.MakeStopSet(stopWords))
-		{
-		}
-		
-		/// <summary>Builds an analyzer with the stop words from the given file.</summary>
-		/// <seealso cref="WordlistLoader.GetWordSet(System.IO.FileInfo)">
-		/// </seealso>
-		/// <deprecated> Use <see cref="StandardAnalyzer(Version, System.IO.FileInfo)" />
-		/// instead
-		/// </deprecated>
-        [Obsolete("Use StandardAnalyzer(Version, File) instead")]
-		public StandardAnalyzer(System.IO.FileInfo stopwords):this(Version.LUCENE_24, stopwords)
-		{
+            SetOverridesTokenStreamMethod<StandardAnalyzer>();
+            enableStopPositionIncrements = StopFilter.GetEnablePositionIncrementsVersionDefault(matchVersion);
+            replaceInvalidAcronym = matchVersion.OnOrAfter(Version.LUCENE_24);
+            this.matchVersion = matchVersion;
 		}
-		
+        
 		/// <summary>Builds an analyzer with the stop words from the given file.</summary>
 		/// <seealso cref="WordlistLoader.GetWordSet(System.IO.FileInfo)">
 		/// </seealso>
@@ -177,19 +85,7 @@ namespace Lucene.Net.Analysis.Standard
 		/// <param name="stopwords">File to read stop words from 
 		/// </param>
 		public StandardAnalyzer(Version matchVersion, System.IO.FileInfo stopwords)
-		{
-			stopSet = WordlistLoader.GetWordSet(stopwords);
-			Init(matchVersion);
-		}
-		
-		/// <summary>Builds an analyzer with the stop words from the given reader.</summary>
-        /// <seealso cref="WordlistLoader.GetWordSet(System.IO.TextReader)">
-		/// </seealso>
-		/// <deprecated> Use <see cref="StandardAnalyzer(Version, System.IO.TextReader)" />
-		/// instead
-		/// </deprecated>
-        [Obsolete("Use StandardAnalyzer(Version, Reader) instead")]
-		public StandardAnalyzer(System.IO.TextReader stopwords):this(Version.LUCENE_24, stopwords)
+            : this (matchVersion, WordlistLoader.GetWordSet(stopwords))
 		{
 		}
 		
@@ -202,125 +98,19 @@ namespace Lucene.Net.Analysis.Standard
 		/// <param name="stopwords">Reader to read stop words from 
 		/// </param>
 		public StandardAnalyzer(Version matchVersion, System.IO.TextReader stopwords)
-		{
-			stopSet = WordlistLoader.GetWordSet(stopwords);
-			Init(matchVersion);
-		}
-		
-		/// <summary> </summary>
-		/// <param name="replaceInvalidAcronym">Set to true if this analyzer should replace mischaracterized acronyms in the StandardTokenizer
-		/// 
-		/// See https://issues.apache.org/jira/browse/LUCENE-1068
-		/// 
-		/// </param>
-		/// <deprecated> Remove in 3.X and make true the only valid value
-		/// </deprecated>
-        [Obsolete("Remove in 3.X and make true the only valid value")]
-		public StandardAnalyzer(bool replaceInvalidAcronym):this(Version.LUCENE_24, STOP_WORDS_SET)
-		{
-			this.replaceInvalidAcronym = replaceInvalidAcronym;
-			useDefaultStopPositionIncrements = true;
-		}
-		
-		/// <param name="stopwords">The stopwords to use
-		/// </param>
-		/// <param name="replaceInvalidAcronym">Set to true if this analyzer should replace mischaracterized acronyms in the StandardTokenizer
-		/// 
-		/// See https://issues.apache.org/jira/browse/LUCENE-1068
-		/// 
-		/// </param>
-		/// <deprecated> Remove in 3.X and make true the only valid value
-		/// </deprecated>
-        [Obsolete("Remove in 3.X and make true the only valid value")]
-		public StandardAnalyzer(System.IO.TextReader stopwords, bool replaceInvalidAcronym):this(Version.LUCENE_24, stopwords)
-		{
-			this.replaceInvalidAcronym = replaceInvalidAcronym;
-		}
-		
-		/// <param name="stopwords">The stopwords to use
-		/// </param>
-		/// <param name="replaceInvalidAcronym">Set to true if this analyzer should replace mischaracterized acronyms in the StandardTokenizer
-		/// 
-		/// See https://issues.apache.org/jira/browse/LUCENE-1068
-		/// 
-		/// </param>
-		/// <deprecated> Remove in 3.X and make true the only valid value
-		/// </deprecated>
-        [Obsolete("Remove in 3.X and make true the only valid value")]
-		public StandardAnalyzer(System.IO.FileInfo stopwords, bool replaceInvalidAcronym):this(Version.LUCENE_24, stopwords)
-		{
-			this.replaceInvalidAcronym = replaceInvalidAcronym;
-		}
-		
-		/// <summary> </summary>
-		/// <param name="stopwords">The stopwords to use
-		/// </param>
-		/// <param name="replaceInvalidAcronym">Set to true if this analyzer should replace mischaracterized acronyms in the StandardTokenizer
-		/// 
-		/// See https://issues.apache.org/jira/browse/LUCENE-1068
-		/// 
-		/// </param>
-		/// <deprecated> Remove in 3.X and make true the only valid value
-		/// </deprecated>
-        [Obsolete("Remove in 3.X and make true the only valid value")]
-		public StandardAnalyzer(System.String[] stopwords, bool replaceInvalidAcronym):this(Version.LUCENE_24, StopFilter.MakeStopSet(stopwords))
-		{
-			this.replaceInvalidAcronym = replaceInvalidAcronym;
-		}
-		
-		/// <param name="stopwords">The stopwords to use
-		/// </param>
-		/// <param name="replaceInvalidAcronym">Set to true if this analyzer should replace mischaracterized acronyms in the StandardTokenizer
-		/// 
-		/// See https://issues.apache.org/jira/browse/LUCENE-1068
-		/// 
-		/// </param>
-		/// <deprecated> Remove in 3.X and make true the only valid value
-		/// </deprecated>
-        [Obsolete("Remove in 3.X and make true the only valid value")]
-		public StandardAnalyzer(System.Collections.Hashtable stopwords, bool replaceInvalidAcronym):this(Version.LUCENE_24, stopwords)
-		{
-			this.replaceInvalidAcronym = replaceInvalidAcronym;
-		}
-		
-		private void  Init(Version matchVersion)
-		{
-			SetOverridesTokenStreamMethod(typeof(StandardAnalyzer));
-			if (matchVersion.OnOrAfter(Version.LUCENE_29))
-			{
-				enableStopPositionIncrements = true;
-			}
-			else
-			{
-				useDefaultStopPositionIncrements = true;
-			}
-			if (matchVersion.OnOrAfter(Version.LUCENE_24))
-			{
-				replaceInvalidAcronym = defaultReplaceInvalidAcronym;
-			}
-			else
-			{
-				replaceInvalidAcronym = false;
-			}
-		}
+            : this(matchVersion, WordlistLoader.GetWordSet(stopwords))
+		{ }
 		
 		/// <summary>Constructs a <see cref="StandardTokenizer" /> filtered by a <see cref="StandardFilter" />
 		///, a <see cref="LowerCaseFilter" /> and a <see cref="StopFilter" />. 
 		/// </summary>
 		public override TokenStream TokenStream(System.String fieldName, System.IO.TextReader reader)
 		{
-			StandardTokenizer tokenStream = new StandardTokenizer(reader, replaceInvalidAcronym);
+			StandardTokenizer tokenStream = new StandardTokenizer(matchVersion, reader);
 			tokenStream.SetMaxTokenLength(maxTokenLength);
 			TokenStream result = new StandardFilter(tokenStream);
 			result = new LowerCaseFilter(result);
-			if (useDefaultStopPositionIncrements)
-			{
-				result = new StopFilter(result, stopSet);
-			}
-			else
-			{
-				result = new StopFilter(enableStopPositionIncrements, result, stopSet);
-			}
+			result = new StopFilter(enableStopPositionIncrements, result, stopSet);
 			return result;
 		}
 		
@@ -352,9 +142,6 @@ namespace Lucene.Net.Analysis.Standard
 			return maxTokenLength;
 		}
 		
-		/// <deprecated> Use <see cref="TokenStream" /> instead 
-		/// </deprecated>
-        [Obsolete("Use TokenStream instead")]
 		public override TokenStream ReusableTokenStream(System.String fieldName, System.IO.TextReader reader)
 		{
 			if (overridesTokenStreamMethod)
@@ -369,17 +156,11 @@ namespace Lucene.Net.Analysis.Standard
 			{
 				streams = new SavedStreams();
 				SetPreviousTokenStream(streams);
-				streams.tokenStream = new StandardTokenizer(reader);
+				streams.tokenStream = new StandardTokenizer(matchVersion, reader);
 				streams.filteredTokenStream = new StandardFilter(streams.tokenStream);
 				streams.filteredTokenStream = new LowerCaseFilter(streams.filteredTokenStream);
-				if (useDefaultStopPositionIncrements)
-				{
-					streams.filteredTokenStream = new StopFilter(streams.filteredTokenStream, stopSet);
-				}
-				else
-				{
-					streams.filteredTokenStream = new StopFilter(enableStopPositionIncrements, streams.filteredTokenStream, stopSet);
-				}
+			    streams.filteredTokenStream = new StopFilter(enableStopPositionIncrements, 
+                                                             streams.filteredTokenStream, stopSet);
 			}
 			else
 			{
@@ -391,43 +172,8 @@ namespace Lucene.Net.Analysis.Standard
 			
 			return streams.filteredTokenStream;
 		}
-		
-		/// <summary> </summary>
-		/// <returns> true if this Analyzer is replacing mischaracterized acronyms in the StandardTokenizer
-		/// 
-		/// See https://issues.apache.org/jira/browse/LUCENE-1068
-		/// </returns>
-		/// <deprecated> This will be removed (hardwired to true) in 3.0
-		/// </deprecated>
-        [Obsolete("This will be removed (hardwired to true) in 3.0")]
-		public virtual bool IsReplaceInvalidAcronym()
-		{
-			return replaceInvalidAcronym;
-		}
-		
-		/// <summary> </summary>
-		/// <param name="replaceInvalidAcronym">Set to true if this Analyzer is replacing mischaracterized acronyms in the StandardTokenizer
-		/// 
-		/// See https://issues.apache.org/jira/browse/LUCENE-1068
-		/// </param>
-		/// <deprecated> This will be removed (hardwired to true) in 3.0
-		/// </deprecated>
-        [Obsolete("This will be removed (hardwired to true) in 3.0")]
-		public virtual void  SetReplaceInvalidAcronym(bool replaceInvalidAcronym)
-		{
-			this.replaceInvalidAcronym = replaceInvalidAcronym;
-		}
 		static StandardAnalyzer()
 		{
-			// Default to true (fixed the bug), unless the system prop is set
-			{
-				System.String v = SupportClass.AppSettings.Get("Lucene.Net.Analysis.Standard.StandardAnalyzer.replaceInvalidAcronym", "true");
-				if (v == null || v.Equals("true"))
-					defaultReplaceInvalidAcronym = true;
-				else
-					defaultReplaceInvalidAcronym = false;
-			}
-			STOP_WORDS = StopAnalyzer.ENGLISH_STOP_WORDS;
 			STOP_WORDS_SET = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
 		}
 	}

Modified: incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardFilter.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardFilter.cs Tue Feb 28 22:43:08 2012
@@ -35,8 +35,8 @@ namespace Lucene.Net.Analysis.Standard
 		/// <summary>Construct filtering <i>in</i>. </summary>
 		public StandardFilter(TokenStream in_Renamed):base(in_Renamed)
 		{
-			termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
-			typeAtt = (TypeAttribute) AddAttribute(typeof(TypeAttribute));
+            termAtt = AddAttribute<TermAttribute>();
+			typeAtt = AddAttribute<TypeAttribute>();
 		}
 		
 		private static readonly System.String APOSTROPHE_TYPE;

Modified: incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardTokenizer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardTokenizer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardTokenizer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Standard/StandardTokenizer.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using Lucene.Net.Util;
 using CharReader = Lucene.Net.Analysis.CharReader;
 using Token = Lucene.Net.Analysis.Token;
 using Tokenizer = Lucene.Net.Analysis.Tokenizer;
@@ -56,7 +56,7 @@ namespace Lucene.Net.Analysis.Standard
 	/// </list>
 	/// </summary>
 	
-	public class StandardTokenizer:Tokenizer
+	public sealed class StandardTokenizer:Tokenizer
 	{
 		private void  InitBlock()
 		{
@@ -65,18 +65,17 @@ namespace Lucene.Net.Analysis.Standard
 		/// <summary>A private instance of the JFlex-constructed scanner </summary>
 		private StandardTokenizerImpl scanner;
 		
-		public const int ALPHANUM = 0;
+		public const int ALPHANUM   = 0;
 		public const int APOSTROPHE = 1;
-		public const int ACRONYM = 2;
-		public const int COMPANY = 3;
-		public const int EMAIL = 4;
-		public const int HOST = 5;
-		public const int NUM = 6;
-		public const int CJ = 7;
+		public const int ACRONYM    = 2;
+		public const int COMPANY    = 3;
+		public const int EMAIL      = 4;
+		public const int HOST       = 5;
+		public const int NUM        = 6;
+		public const int CJ         = 7;
 		
 		/// <deprecated> this solves a bug where HOSTs that end with '.' are identified
-		/// as ACRONYMs. It is deprecated and will be removed in the next
-		/// release.
+		/// as ACRONYMs.
 		/// </deprecated>
         [Obsolete("this solves a bug where HOSTs that end with '.' are identified as ACRONYMs. It is deprecated and will be removed in the next release.")]
 		public const int ACRONYM_DEP = 8;
@@ -84,20 +83,6 @@ namespace Lucene.Net.Analysis.Standard
 		/// <summary>String token types that correspond to token type int constants </summary>
 		public static readonly System.String[] TOKEN_TYPES = new System.String[]{"<ALPHANUM>", "<APOSTROPHE>", "<ACRONYM>", "<COMPANY>", "<EMAIL>", "<HOST>", "<NUM>", "<CJ>", "<ACRONYM_DEP>"};
 		
-		/// <deprecated> Please use <see cref="TOKEN_TYPES" /> instead 
-		/// </deprecated>
-        [Obsolete("Please use TOKEN_TYPES instead")]
-		public static readonly System.String[] tokenImage = TOKEN_TYPES;
-		
-		/// <summary> Specifies whether deprecated acronyms should be replaced with HOST type.
-		/// This is false by default to support backward compatibility.
-		/// <p/>
-		/// See http://issues.apache.org/jira/browse/LUCENE-1068
-		/// 
-		/// </summary>
-		/// <deprecated> this should be removed in the next release (3.0).
-		/// </deprecated>
-        [Obsolete("this should be removed in the next release (3.0).")]
 		private bool replaceInvalidAcronym;
 		
 		private int maxTokenLength;
@@ -105,47 +90,17 @@ namespace Lucene.Net.Analysis.Standard
 		/// <summary>Set the max allowed token length.  Any token longer
 		/// than this is skipped. 
 		/// </summary>
-		public virtual void  SetMaxTokenLength(int length)
+		public void SetMaxTokenLength(int length)
 		{
 			this.maxTokenLength = length;
 		}
 		
 		/// <seealso cref="SetMaxTokenLength">
 		/// </seealso>
-		public virtual int GetMaxTokenLength()
+		public int GetMaxTokenLength()
 		{
 			return maxTokenLength;
 		}
-		
-		/// <summary> Creates a new instance of the <see cref="StandardTokenizer" />. Attaches the
-		/// <c>input</c> to a newly created JFlex scanner.
-		/// </summary>
-        /// <deprecated> Use <see cref="StandardTokenizer(Version, System.IO.TextReader)" /> instead
-		/// </deprecated>
-        [Obsolete("Use StandardTokenizer(Version, Reader) instead")]
-		public StandardTokenizer(System.IO.TextReader input):this(Version.LUCENE_24, input)
-		{
-		}
-		
-		/// <summary> Creates a new instance of the <see cref="Lucene.Net.Analysis.Standard.StandardTokenizer" />.  Attaches
-		/// the <c>input</c> to the newly created JFlex scanner.
-		/// 
-		/// </summary>
-		/// <param name="input">The input reader
-		/// </param>
-		/// <param name="replaceInvalidAcronym">Set to true to replace mischaracterized acronyms with HOST.
-		/// 
-		/// See http://issues.apache.org/jira/browse/LUCENE-1068
-		/// </param>
-        /// <deprecated> Use <see cref="StandardTokenizer(Version, System.IO.TextReader)" /> instead
-		/// </deprecated>
-        [Obsolete("Use StandardTokenizer(Version, Reader) instead")]
-		public StandardTokenizer(System.IO.TextReader input, bool replaceInvalidAcronym):base()
-		{
-			InitBlock();
-			this.scanner = new StandardTokenizerImpl(input);
-			Init(input, replaceInvalidAcronym);
-		}
 
 	    /// <summary> Creates a new instance of the
 	    /// <see cref="Lucene.Net.Analysis.Standard.StandardTokenizer" />. Attaches
@@ -163,20 +118,7 @@ namespace Lucene.Net.Analysis.Standard
 			this.scanner = new StandardTokenizerImpl(input);
 			Init(input, matchVersion);
 		}
-		
-		/// <summary> Creates a new StandardTokenizer with a given <see cref="AttributeSource" />. </summary>
-		/// <deprecated> Use
-        /// <see cref="StandardTokenizer(Version, AttributeSource, System.IO.TextReader)" />
-		/// instead
-		/// </deprecated>
-        [Obsolete("Use StandardTokenizer(Version, AttributeSource, Reader) instead")]
-		public StandardTokenizer(AttributeSource source, System.IO.TextReader input, bool replaceInvalidAcronym):base(source)
-		{
-			InitBlock();
-			this.scanner = new StandardTokenizerImpl(input);
-			Init(input, replaceInvalidAcronym);
-		}
-		
+
 		/// <summary> Creates a new StandardTokenizer with a given <see cref="AttributeSource" />.</summary>
 		public StandardTokenizer(Version matchVersion, AttributeSource source, System.IO.TextReader input):base(source)
 		{
@@ -185,19 +127,6 @@ namespace Lucene.Net.Analysis.Standard
 			Init(input, matchVersion);
 		}
 		
-		/// <summary> Creates a new StandardTokenizer with a given <see cref="Lucene.Net.Util.AttributeSource.AttributeFactory" /> </summary>
-		/// <deprecated> Use
-        /// <see cref="StandardTokenizer(Version, AttributeSource.AttributeFactory, System.IO.TextReader)" />
-		/// instead
-		/// </deprecated>
-        [Obsolete("Use StandardTokenizer(Version, Lucene.Net.Util.AttributeSource.AttributeFactory, Reader) instead")]
-		public StandardTokenizer(AttributeFactory factory, System.IO.TextReader input, bool replaceInvalidAcronym):base(factory)
-		{
-			InitBlock();
-			this.scanner = new StandardTokenizerImpl(input);
-			Init(input, replaceInvalidAcronym);
-		}
-		
 		/// <summary> Creates a new StandardTokenizer with a given
 		/// <see cref="Lucene.Net.Util.AttributeSource.AttributeFactory" />
 		/// </summary>
@@ -208,26 +137,21 @@ namespace Lucene.Net.Analysis.Standard
 			Init(input, matchVersion);
 		}
 		
-		private void  Init(System.IO.TextReader input, bool replaceInvalidAcronym)
-		{
-			this.replaceInvalidAcronym = replaceInvalidAcronym;
-			this.input = input;
-			termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
-			offsetAtt = (OffsetAttribute) AddAttribute(typeof(OffsetAttribute));
-			posIncrAtt = (PositionIncrementAttribute) AddAttribute(typeof(PositionIncrementAttribute));
-			typeAtt = (TypeAttribute) AddAttribute(typeof(TypeAttribute));
-		}
-		
 		private void  Init(System.IO.TextReader input, Version matchVersion)
 		{
 			if (matchVersion.OnOrAfter(Version.LUCENE_24))
 			{
-				Init(input, true);
+			    replaceInvalidAcronym = true;
 			}
 			else
 			{
-				Init(input, false);
+			    replaceInvalidAcronym = false;
 			}
+		    this.input = input;
+		    termAtt = AddAttribute<TermAttribute>();
+		    offsetAtt = AddAttribute<OffsetAttribute>();
+		    posIncrAtt = AddAttribute<PositionIncrementAttribute>();
+		    typeAtt = AddAttribute<TypeAttribute>();
 		}
 		
 		// this tokenizer generates three attributes:
@@ -297,25 +221,6 @@ namespace Lucene.Net.Analysis.Standard
 			offsetAtt.SetOffset(finalOffset, finalOffset);
 		}
 		
-		/// <deprecated> Will be removed in Lucene 3.0. This method is final, as it should
-		/// not be overridden. Delegates to the backwards compatibility layer. 
-		/// </deprecated>
-        [Obsolete("Will be removed in Lucene 3.0. This method is final, as it should not be overridden. Delegates to the backwards compatibility layer. ")]
-		public override Token Next(Token reusableToken)
-		{
-			return base.Next(reusableToken);
-		}
-		
-		/// <deprecated> Will be removed in Lucene 3.0. This method is final, as it should
-		/// not be overridden. Delegates to the backwards compatibility layer. 
-		/// </deprecated>
-        [Obsolete("Will be removed in Lucene 3.0. This method is final, as it should not be overridden. Delegates to the backwards compatibility layer. ")]
-		public override Token Next()
-		{
-			return base.Next();
-		}
-		
-				
 		public override void  Reset(System.IO.TextReader reader)
 		{
 			base.Reset(reader);
@@ -331,20 +236,20 @@ namespace Lucene.Net.Analysis.Standard
 		/// <deprecated> Remove in 3.X and make true the only valid value
 		/// </deprecated>
         [Obsolete("Remove in 3.X and make true the only valid value")]
-		public virtual bool IsReplaceInvalidAcronym()
+		public bool IsReplaceInvalidAcronym()
 		{
 			return replaceInvalidAcronym;
 		}
 		
-		/// <summary> </summary>
-		/// <param name="replaceInvalidAcronym">Set to true to replace mischaracterized acronyms as HOST.
-		/// </param>
-		/// <deprecated> Remove in 3.X and make true the only valid value
-		/// 
+
+        /// <summary>
+		/// Remove in 3.X and make true the only valid value
 		/// See https://issues.apache.org/jira/browse/LUCENE-1068
-		/// </deprecated>
+        /// </summary>
+        /// <param name="replaceInvalidAcronym">Set to true to replace mischaracterized acronyms as HOST.
+        /// </param>
         [Obsolete("Remove in 3.X and make true the only valid value. See https://issues.apache.org/jira/browse/LUCENE-1068")]
-		public virtual void  SetReplaceInvalidAcronym(bool replaceInvalidAcronym)
+		public void  SetReplaceInvalidAcronym(bool replaceInvalidAcronym)
 		{
 			this.replaceInvalidAcronym = replaceInvalidAcronym;
 		}



Mime
View raw message