lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnas...@apache.org
Subject [Lucene.Net] svn commit: r1100459 [3/6] - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g: ./ src/core/ src/core/Analysis/ src/core/Analysis/Standard/ src/core/Analysis/Tokenattributes/ src/core/Document/ src/core/Index/ src/core/QueryParser/ src/core/Search/ s...
Date Sat, 07 May 2011 06:22:27 GMT
Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/CRC32.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/CRC32.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/CRC32.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/CRC32.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Support
+{
+    public class CRC32 : Checksum
+    {
+        private static readonly UInt32[] crcTable = InitializeCRCTable();
+
+        private static UInt32[] InitializeCRCTable()
+        {
+            UInt32[] crcTable = new UInt32[256];
+            for (UInt32 n = 0; n < 256; n++)
+            {
+                UInt32 c = n;
+                for (int k = 8; --k >= 0; )
+                {
+                    if ((c & 1) != 0)
+                        c = 0xedb88320 ^ (c >> 1);
+                    else
+                        c = c >> 1;
+                }
+                crcTable[n] = c;
+            }
+            return crcTable;
+        }
+
+        private UInt32 crc = 0;
+
+        public Int64 GetValue()
+        {
+            return (Int64)crc & 0xffffffffL;
+        }
+
+        public void Reset()
+        {
+            crc = 0;
+        }
+
+        public void Update(int bval)
+        {
+            UInt32 c = ~crc;
+            c = crcTable[(c ^ bval) & 0xff] ^ (c >> 8);
+            crc = ~c;
+        }
+
+        public void Update(byte[] buf, int off, int len)
+        {
+            UInt32 c = ~crc;
+            while (--len >= 0)
+                c = crcTable[(c ^ buf[off++]) & 0xff] ^ (c >> 8);
+            crc = ~c;
+        }
+
+        public void Update(byte[] buf)
+        {
+            Update(buf, 0, buf.Length);
+        }
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Character.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Character.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Character.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Character.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Lucene.Net.Support
+{
+    /// <summary>
+    /// Mimics Java's Character class.
+    /// </summary>
+    public class Character
+    {
+        private const char charNull= '\0';
+        private const char charZero = '0';
+        private const char charA = 'a';
+
+        /// <summary>
+        /// </summary>
+        public static int MAX_RADIX
+        {
+            get
+            {
+                return 36;
+            }
+        }
+
+        /// <summary>
+        /// </summary>
+        public static int MIN_RADIX
+        {
+            get
+            {
+                return 2;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="digit"></param>
+        /// <param name="radix"></param>
+        /// <returns></returns>
+        public static char ForDigit(int digit, int radix)
+        {
+            // if radix or digit is out of range,
+            // return the null character.
+            if (radix < Character.MIN_RADIX)
+                return charNull;
+            if (radix > Character.MAX_RADIX)
+                return charNull;
+            if (digit < 0)
+                return charNull;
+            if (digit >= radix)
+                return charNull;
+
+            // if digit is less than 10,
+            // return '0' plus digit
+            if (digit < 10)
+                return (char) ( (int) charZero + digit);
+
+            // otherwise, return 'a' plus digit.
+            return (char) ((int) charA + digit - 10);
+        }
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Checksum.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Checksum.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Checksum.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Checksum.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Support
+{
+    public interface Checksum
+    {
+        void Reset();
+        void Update(int b);
+        void Update(byte[] b);
+        void Update(byte[] b, int offset, int length);
+        Int64 GetValue();
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/CollectionsHelper.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/CollectionsHelper.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/CollectionsHelper.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/CollectionsHelper.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,276 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System.Collections;
+
+namespace Lucene.Net.Support
+{
+    /// <summary>
+    /// Support class used to handle Hashtable addition, which does a check 
+    /// first to make sure the added item is unique in the hash.
+    /// </summary>
+    public class CollectionsHelper
+    {
+        public static void Add(System.Collections.Hashtable hashtable, System.Object item)
+        {
+            hashtable.Add(item, item);
+        }
+
+        public static void AddIfNotContains(System.Collections.Hashtable hashtable, System.Object item)
+        {
+            if (hashtable.Contains(item) == false)
+            {
+                hashtable.Add(item, item);
+            }
+        }
+
+        public static void AddIfNotContains(System.Collections.ArrayList hashtable, System.Object item)
+        {
+            if (hashtable.Contains(item) == false)
+            {
+                hashtable.Add(item);
+            }
+        }
+
+        public static void AddAll(System.Collections.Hashtable hashtable, System.Collections.ICollection items)
+        {
+            System.Collections.IEnumerator iter = items.GetEnumerator();
+            System.Object item;
+            while (iter.MoveNext())
+            {
+                item = iter.Current;
+                hashtable.Add(item, item);
+            }
+        }
+
+        public static void AddAllIfNotContains(System.Collections.Hashtable hashtable, System.Collections.ICollection items)
+        {
+            System.Collections.IEnumerator iter = items.GetEnumerator();
+            System.Object item;
+            while (iter.MoveNext())
+            {
+                item = iter.Current;
+                if (hashtable.Contains(item) == false)
+                {
+                    hashtable.Add(item, item);
+                }
+            }
+        }
+
+        public static void AddAllIfNotContains(System.Collections.Generic.IDictionary<string,string> hashtable, System.Collections.Generic.ICollection<string> items)
+        {
+            foreach (string s in items)
+            {
+                if (hashtable.ContainsKey(s) == false)
+                {
+                    hashtable.Add(s, s);
+                }
+            }
+        }
+
+        public static void AddAll(System.Collections.Generic.IDictionary<string, string> hashtable, System.Collections.Generic.ICollection<string> items)
+        {
+            foreach (string s in items)
+            {
+                hashtable.Add(s, s);
+            }
+        }
+
+        public static System.String CollectionToString<T>(System.Collections.Generic.IList<T> c)
+        {
+            System.Text.StringBuilder sb = new System.Text.StringBuilder();
+            for(int i=0;i<c.Count;i++)
+            {
+                sb.Append(c[i].ToString());
+                if (i != c.Count - 1) sb.Append(", ");
+            }
+            return sb.ToString();
+        }
+
+        public static System.String CollectionToString(System.Collections.Generic.IDictionary<string, string> c)
+        {
+            Hashtable t = new Hashtable();
+            foreach (string key in c.Keys)
+            {
+                t.Add(key, c[key]);
+            }
+            return CollectionToString(t);
+        }
+
+        /// <summary>
+        /// Converts the specified collection to its string representation.
+        /// </summary>
+        /// <param name="c">The collection to convert to string.</param>
+        /// <returns>A string representation of the specified collection.</returns>
+        public static System.String CollectionToString(System.Collections.ICollection c)
+        {
+            System.Text.StringBuilder s = new System.Text.StringBuilder();
+
+            if (c != null)
+            {
+
+                System.Collections.ArrayList l = new System.Collections.ArrayList(c);
+
+                bool isDictionary = (c is System.Collections.BitArray || c is System.Collections.Hashtable || c is System.Collections.IDictionary || c is System.Collections.Specialized.NameValueCollection || (l.Count > 0 && l[0] is System.Collections.DictionaryEntry));
+                for (int index = 0; index < l.Count; index++)
+                {
+                    if (l[index] == null)
+                        s.Append("null");
+                    else if (!isDictionary)
+                        s.Append(l[index]);
+                    else
+                    {
+                        isDictionary = true;
+                        if (c is System.Collections.Specialized.NameValueCollection)
+                            s.Append(((System.Collections.Specialized.NameValueCollection)c).GetKey(index));
+                        else
+                            s.Append(((System.Collections.DictionaryEntry)l[index]).Key);
+                        s.Append("=");
+                        if (c is System.Collections.Specialized.NameValueCollection)
+                            s.Append(((System.Collections.Specialized.NameValueCollection)c).GetValues(index)[0]);
+                        else
+                            s.Append(((System.Collections.DictionaryEntry)l[index]).Value);
+
+                    }
+                    if (index < l.Count - 1)
+                        s.Append(", ");
+                }
+
+                if (isDictionary)
+                {
+                    if (c is System.Collections.ArrayList)
+                        isDictionary = false;
+                }
+                if (isDictionary)
+                {
+                    s.Insert(0, "{");
+                    s.Append("}");
+                }
+                else
+                {
+                    s.Insert(0, "[");
+                    s.Append("]");
+                }
+            }
+            else
+                s.Insert(0, "null");
+            return s.ToString();
+        }
+
+        /// <summary>
+        /// Compares two string arrays for equality.
+        /// </summary>
+        /// <param name="l1">First string array list to compare</param>
+        /// <param name="l2">Second string array list to compare</param>
+        /// <returns>true if the strings are equal in both arrays, false otherwise</returns>
+        public static bool CompareStringArrays(System.String[] l1, System.String[] l2)
+        {
+            if (l1.Length != l2.Length)
+                return false;
+            for (int i = 0; i < l1.Length; i++)
+            {
+                if (l1[i] != l2[i])
+                    return false;
+            }
+            return true;
+        }
+
+        
+
+        public static void Sort<T1>(System.Collections.Generic.IList<T1> list, System.Collections.Generic.IComparer<T1> Comparator)
+        {
+            if (list.IsReadOnly) throw new System.NotSupportedException();
+            if (Comparator == null) ((System.Collections.Generic.List<T1>)list).Sort();
+            else ((System.Collections.Generic.List<T1>)list).Sort(Comparator);
+        }
+
+        /// <summary>
+        /// Fills the array with an specific value from an specific index to an specific index.
+        /// </summary>
+        /// <param name="array">The array to be filled.</param>
+        /// <param name="fromindex">The first index to be filled.</param>
+        /// <param name="toindex">The last index to be filled.</param>
+        /// <param name="val">The value to fill the array with.</param>
+        public static void Fill(System.Array array, System.Int32 fromindex, System.Int32 toindex, System.Object val)
+        {
+            System.Object Temp_Object = val;
+            System.Type elementtype = array.GetType().GetElementType();
+            if (elementtype != val.GetType())
+                Temp_Object = System.Convert.ChangeType(val, elementtype);
+            if (array.Length == 0)
+                throw (new System.NullReferenceException());
+            if (fromindex > toindex)
+                throw (new System.ArgumentException());
+            if ((fromindex < 0) || ((System.Array)array).Length < toindex)
+                throw (new System.IndexOutOfRangeException());
+            for (int index = (fromindex > 0) ? fromindex-- : fromindex; index < toindex; index++)
+                array.SetValue(Temp_Object, index);
+        }
+
+
+        /// <summary>
+        /// Fills the array with an specific value.
+        /// </summary>
+        /// <param name="array">The array to be filled.</param>
+        /// <param name="val">The value to fill the array with.</param>
+        public static void Fill(System.Array array, System.Object val)
+        {
+            Fill(array, 0, array.Length, val);
+        }
+
+        /// <summary>
+        /// Compares the entire members of one array whith the other one.
+        /// </summary>
+        /// <param name="array1">The array to be compared.</param>
+        /// <param name="array2">The array to be compared with.</param>
+        /// <returns>Returns true if the two specified arrays of Objects are equal 
+        /// to one another. The two arrays are considered equal if both arrays 
+        /// contain the same number of elements, and all corresponding pairs of 
+        /// elements in the two arrays are equal. Two objects e1 and e2 are 
+        /// considered equal if (e1==null ? e2==null : e1.equals(e2)). In other 
+        /// words, the two arrays are equal if they contain the same elements in 
+        /// the same order. Also, two array references are considered equal if 
+        /// both are null.</returns>
+        public static bool Equals(System.Array array1, System.Array array2)
+        {
+            bool result = false;
+            if ((array1 == null) && (array2 == null))
+                result = true;
+            else if ((array1 != null) && (array2 != null))
+            {
+                if (array1.Length == array2.Length)
+                {
+                    int length = array1.Length;
+                    result = true;
+                    for (int index = 0; index < length; index++)
+                    {
+                        System.Object o1 = array1.GetValue(index);
+                        System.Object o2 = array2.GetValue(index);
+                        if (o1 == null && o2 == null)
+                            continue;   // they match
+                        else if (o1 == null || !o1.Equals(o2))
+                        {
+                            result = false;
+                            break;
+                        }
+                    }
+                }
+            }
+            return result;
+        }
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Compare.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Compare.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Compare.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Compare.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Lucene.Net.Support
+{
+    /// <summary>
+    /// Summary description for TestSupportClass.
+    /// </summary>
+    public class Compare
+    {
+        /// <summary>
+        /// Compares two Term arrays for equality.
+        /// </summary>
+        /// <param name="t1">First Term array to compare</param>
+        /// <param name="t2">Second Term array to compare</param>
+        /// <returns>true if the Terms are equal in both arrays, false otherwise</returns>
+        public static bool CompareTermArrays(Lucene.Net.Index.Term[] t1, Lucene.Net.Index.Term[] t2)
+        {
+            if (t1.Length != t2.Length)
+                return false;
+            for (int i = 0; i < t1.Length; i++)
+            {
+                if (t1[i].CompareTo(t2[i]) == 0)
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Cryptography.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Cryptography.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Cryptography.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Cryptography.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Lucene.Net.Support
+{
+    public class Cryptography
+    {
+        static public bool FIPSCompliant = false;
+
+        static public System.Security.Cryptography.HashAlgorithm GetHashAlgorithm()
+        {
+            if (FIPSCompliant)
+            {
+                //LUCENENET-175
+                //No Assumptions should be made on the HashAlgorithm. It may change in time.
+                //SHA256 SHA384 SHA512 etc.
+                return System.Security.Cryptography.SHA1.Create();
+            }
+            return System.Security.Cryptography.MD5.Create();
+        }
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Dictionary.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Dictionary.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Dictionary.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Dictionary.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections;
+
+namespace Lucene.Net.Support
+{
+    [Serializable]
+    public class Dictionary<K, V> : System.Collections.Generic.IDictionary<K, V>
+    {
+        System.Collections.Generic.IDictionary<K, V> _Dict = null;
+        
+        public Dictionary()
+        {
+            _Dict = new System.Collections.Generic.Dictionary<K, V>();
+        }
+
+        public Dictionary(bool sortedDictionary)
+        {
+            _Dict = new System.Collections.Generic.SortedDictionary<K, V>();
+        }
+
+        public Dictionary(int capacity)
+        {
+            _Dict = new System.Collections.Generic.Dictionary<K, V>(capacity);
+        }
+
+        public Dictionary(System.Collections.Generic.IDictionary<K,V> dict)
+        {
+            _Dict = new System.Collections.Generic.Dictionary<K, V>(dict);
+        }
+
+        public Dictionary(Dictionary<K, V> dict)
+        {
+            _Dict = new System.Collections.Generic.Dictionary<K, V>(dict);
+        }
+
+        public void Add(K key, V value)
+        {
+            _Dict.Add(key, value);
+        }
+
+        public bool ContainsKey(K key)
+        {
+            return _Dict.ContainsKey(key);
+        }
+
+        public System.Collections.Generic.ICollection<K> Keys
+        {
+            get { return _Dict.Keys; }
+        }
+
+        public bool Remove(K key)
+        {
+            return _Dict.Remove(key);
+        }
+
+        public bool TryGetValue(K key, out V value)
+        {
+            return _Dict.TryGetValue(key, out value);
+        }
+
+        public System.Collections.Generic.ICollection<V> Values
+        {
+            get { return _Dict.Values; }
+        }
+
+        public V this[K key]
+        {
+            get
+            {
+                V val = default(V);
+                _Dict.TryGetValue(key, out val);
+                return val;
+            }
+            set
+            {
+                _Dict[key] = value;
+            }
+        }
+
+        public void Add(System.Collections.Generic.IDictionary<K, V> items)
+        {
+            foreach (K key in items.Keys)
+            {
+                _Dict.Add(key, items[key]);
+            }
+        }
+
+        public void Add(System.Collections.Generic.KeyValuePair<K, V> item)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void Clear()
+        {
+            _Dict.Clear();
+        }
+
+        public bool Contains(System.Collections.Generic.KeyValuePair<K, V> item)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void CopyTo(System.Collections.Generic.KeyValuePair<K, V>[] array, int arrayIndex)
+        {
+            throw new NotImplementedException();
+        }
+
+        public int Count
+        {
+            get { return _Dict.Count; }
+        }
+
+        public bool IsReadOnly
+        {
+            get { return false; }
+        }
+
+        public bool Remove(System.Collections.Generic.KeyValuePair<K, V> item)
+        {
+            throw new NotImplementedException();
+        }
+
+        public System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<K, V>> GetEnumerator()
+        {
+            return _Dict.GetEnumerator();
+        }
+
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Double.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Double.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Double.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Double.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Support
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public class Double
+    {
+        public static System.Double Parse(System.String s)
+        {
+            try
+            {
+                return System.Double.Parse(s.Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator));
+            }
+            catch (OverflowException)
+            {
+                return double.MaxValue;
+            }
+        }
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/EquatableList.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/EquatableList.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/EquatableList.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/EquatableList.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,330 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections;
+
+namespace Lucene.Net.Support
+{
+    /// <summary>Represents a strongly typed list of objects that can be accessed by index.
+    /// Provides methods to search, sort, and manipulate lists. Also provides functionality
+    /// to compare lists against each other through an implementations of
+    /// <see cref="IEquatable{T}"/>.</summary>
+    /// <typeparam name="T">The type of elements in the list.</typeparam>
+    [Serializable]
+    public class EquatableList<T> : System.Collections.Generic.List<T>,
+                                    IEquatable<System.Collections.Generic.IEnumerable<T>>,
+                                    ICloneable
+    {
+        /// <summary>Initializes a new instance of the 
+        /// <see cref="ComparableList{T}"/> class that is empty and has the 
+        /// default initial capacity.</summary>
+        public EquatableList() : base() { }
+
+        /// <summary>Initializes a new instance of the <see cref="ComparableList{T}"/>
+        /// class that contains elements copied from the specified collection and has
+        /// sufficient capacity to accommodate the number of elements copied.</summary>
+        /// <param name="collection">The collection whose elements are copied to the new list.</param>
+        public EquatableList(System.Collections.Generic.IEnumerable<T> collection) : base(collection) { }
+
+        /// <summary>Initializes a new instance of the <see cref="ComparableList{T}"/> 
+        /// class that is empty and has the specified initial capacity.</summary>
+        /// <param name="capacity">The number of elements that the new list can initially store.</param>
+        public EquatableList(int capacity) : base(capacity) { }
+
+        /// <summary>Adds a range of objects represented by the <see cref="ICollection"/>
+        /// implementation.</summary>
+        /// <param name="c">The <see cref="ICollection"/>
+        /// implementation to add to this list.</param>
+        public void AddRange(ICollection c)
+        {
+            // If the collection is null, throw an exception.
+            if (c == null) throw new ArgumentNullException("c");
+
+            // Pre-compute capacity.
+            Capacity = Math.Max(c.Count + Count, Capacity);
+
+            // Cycle through the items and add.
+            foreach (T item in c)
+            {
+                // Add the item.
+                Add(item);
+            }
+        }
+
+        /// <summary>Compares the counts of two <see cref="IEnumerable{T}"/>
+        /// implementations.</summary>
+        /// <remarks>This uses a trick in LINQ, sniffing types for implementations
+        /// of interfaces that might supply shortcuts when trying to make comparisons.
+        /// In this case, that is the <see cref="ICollection{T}"/> and
+        /// <see cref="ICollection"/> interfaces, either of which can provide a count
+        /// which can be used in determining the equality of sequences (if they don't have
+        /// the same count, then they can't be equal).</remarks>
+        /// <param name="x">The <see cref="IEnumerable{T}"/> from the left hand side of the
+        /// comparison to check the count of.</param>
+        /// <param name="y">The <see cref="IEnumerable{T}"/> from the right hand side of the
+        /// comparison to check the count of.</param>
+        /// <returns>Null if the result is indeterminate.  This occurs when either <paramref name="x"/>
+        /// or <paramref name="y"/> doesn't implement <see cref="ICollection"/> or <see cref="ICollection{T}"/>.
+        /// Otherwise, it will get the count from each and return true if they are equal, false otherwise.</returns>
+        private static bool? EnumerableCountsEqual(System.Collections.Generic.IEnumerable<T> x, System.Collections.Generic.IEnumerable<T> y)
+        {
+            // Get the ICollection<T> and ICollection interfaces.
+            System.Collections.Generic.ICollection<T> xOfTCollection = x as System.Collections.Generic.ICollection<T>;
+            System.Collections.Generic.ICollection<T> yOfTCollection = y as System.Collections.Generic.ICollection<T>;
+            ICollection xCollection = x as ICollection;
+            ICollection yCollection = y as ICollection;
+
+            // The count in x and y.
+            int? xCount = xOfTCollection != null ? xOfTCollection.Count : xCollection != null ? xCollection.Count : (int?)null;
+            int? yCount = yOfTCollection != null ? yOfTCollection.Count : yCollection != null ? yCollection.Count : (int?)null;
+
+            // If either are null, return null, the result is indeterminate.
+            if (xCount == null || yCount == null)
+            {
+                // Return null, indeterminate.
+                return null;
+            }
+
+            // Both counts are non-null, compare.
+            return xCount == yCount;
+        }
+
+        /// <summary>Compares the contents of a <see cref="IEnumerable{T}"/>
+        /// implementation to another one to determine equality.</summary>
+        /// <remarks>Thinking of the <see cref="IEnumerable{T}"/> implementation as
+        /// a string with any number of characters, the algorithm checks
+        /// each item in each list.  If any item of the list is not equal (or
+        /// one list contains all the elements of another list), then that list
+        /// element is compared to the other list element to see which
+        /// list is greater.</remarks>
+        /// <param name="x">The <see cref="IEnumerable{T}"/> implementation
+        /// that is considered the left hand side.</param>
+        /// <param name="y">The <see cref="IEnumerable{T}"/> implementation
+        /// that is considered the right hand side.</param>
+        /// <returns>True if the items are equal, false otherwise.</returns>
+        private static bool Equals(System.Collections.Generic.IEnumerable<T> x,
+                                   System.Collections.Generic.IEnumerable<T> y)
+        {
+            // If x and y are null, then return true, they are the same.
+            if (x == null && y == null)
+            {
+                // They are the same, return 0.
+                return true;
+            }
+
+            // If one is null, then return a value based on whether or not
+            // one is null or not.
+            if (x == null || y == null)
+            {
+                // Return false, one is null, the other is not.
+                return false;
+            }
+
+            // Check to see if the counts on the IEnumerable implementations are equal.
+            // This is a shortcut, if they are not equal, then the lists are not equal.
+            // If the result is indeterminate, then get out.
+            bool? enumerableCountsEqual = EnumerableCountsEqual(x, y);
+
+            // If the enumerable counts have been able to be calculated (indicated by
+            // a non-null value) and it is false, then no need to iterate through the items.
+            if (enumerableCountsEqual != null && !enumerableCountsEqual.Value)
+            {
+                // The sequences are not equal.
+                return false;
+            }
+
+            // The counts of the items in the enumerations are equal, or indeterminate
+            // so a full iteration needs to be made to compare each item.
+            // Get the default comparer for T first.
+            System.Collections.Generic.EqualityComparer<T> defaultComparer =
+                System.Collections.Generic.EqualityComparer<T>.Default;
+
+            // Get the enumerator for y.
+            System.Collections.Generic.IEnumerator<T> otherEnumerator = y.GetEnumerator();
+
+            // Call Dispose on IDisposable if there is an implementation on the
+            // IEnumerator<T> returned by a call to y.GetEnumerator().
+            using (otherEnumerator as IDisposable)
+            {
+                // Cycle through the items in this list.
+                foreach (T item in x)
+                {
+                    // If there isn't an item to get, then this has more
+                    // items than that, they are not equal.
+                    if (!otherEnumerator.MoveNext())
+                    {
+                        // Return false.
+                        return false;
+                    }
+
+                    // Perform a comparison.  Must check this on the left hand side
+                    // and that on the right hand side.
+                    bool comparison = defaultComparer.Equals(item, otherEnumerator.Current);
+
+                    // If the value is false, return false.
+                    if (!comparison)
+                    {
+                        // Return the value.
+                        return comparison;
+                    }
+                }
+
+                // If there are no more items, then return true, the sequences
+                // are equal.
+                if (!otherEnumerator.MoveNext())
+                {
+                    // The sequences are equal.
+                    return true;
+                }
+
+                // The other sequence has more items than this one, return
+                // false, these are not equal.
+                return false;
+            }
+        }
+
+        #region IEquatable<IEnumerable<T>> Members
+        /// <summary>Compares this sequence to another <see cref="IEnumerable{T}"/>
+        /// implementation, returning true if they are equal, false otherwise.</summary>
+        /// <param name="other">The other <see cref="IEnumerable{T}"/> implementation
+        /// to compare against.</param>
+        /// <returns>True if the sequence in <paramref name="other"/> 
+        /// is the same as this one.</returns>
+        public bool Equals(System.Collections.Generic.IEnumerable<T> other)
+        {
+            // Compare to the other sequence.  If 0, then equal.
+            return Equals(this, other);
+        }
+        #endregion
+
+        /// <summary>Compares this object for equality against other.</summary>
+        /// <param name="obj">The other object to compare this object against.</param>
+        /// <returns>True if this object and <paramref name="obj"/> are equal, false
+        /// otherwise.</returns>
+        public override bool Equals(object obj)
+        {
+            // Call the strongly typed version.
+            return Equals(obj as System.Collections.Generic.IEnumerable<T>);
+        }
+
+        /// <summary>Gets the hash code for the list.</summary>
+        /// <returns>The hash code value.</returns>
+        public override int GetHashCode()
+        {
+            // Call the static method, passing this.
+            return GetHashCode(this);
+        }
+
+        /// <summary>Gets the hash code for the list.</summary>
+        /// <param name="source">The <see cref="IEnumerable{T}"/>
+        /// implementation which will have all the contents hashed.</param>
+        /// <returns>The hash code value.</returns>
+        public static int GetHashCode(System.Collections.Generic.IEnumerable<T> source)
+        {
+            // If source is null, then return 0.
+            if (source == null) return 0;
+
+            // Seed the hash code with the hash code of the type.
+            // This is done so that you don't have a lot of collisions of empty
+            // ComparableList instances when placed in dictionaries
+            // and things that rely on hashcodes.
+            int hashCode = typeof(T).GetHashCode();
+
+            // Iterate through the items in this implementation.
+            foreach (T item in source)
+            {
+                // Adjust the hash code.
+                hashCode = 31 * hashCode + (item == null ? 0 : item.GetHashCode());
+            }
+
+            // Return the hash code.
+            return hashCode;
+        }
+
+        // TODO: When diverging from Java version of Lucene, can uncomment these to adhere to best practices when overriding the Equals method and implementing IEquatable<T>.
+        ///// <summary>Overload of the == operator, it compares a
+        ///// <see cref="ComparableList{T}"/> to an <see cref="IEnumerable{T}"/>
+        ///// implementation.</summary>
+        ///// <param name="x">The <see cref="ComparableList{T}"/> to compare
+        ///// against <paramref name="y"/>.</param>
+        ///// <param name="y">The <see cref="IEnumerable{T}"/> to compare
+        ///// against <paramref name="x"/>.</param>
+        ///// <returns>True if the instances are equal, false otherwise.</returns>
+        //public static bool operator ==(EquatableList<T> x, System.Collections.Generic.IEnumerable<T> y)
+        //{
+        //    // Call Equals.
+        //    return Equals(x, y);
+        //}
+
+        ///// <summary>Overload of the == operator, it compares a
+        ///// <see cref="ComparableList{T}"/> to an <see cref="IEnumerable{T}"/>
+        ///// implementation.</summary>
+        ///// <param name="y">The <see cref="ComparableList{T}"/> to compare
+        ///// against <paramref name="x"/>.</param>
+        ///// <param name="x">The <see cref="IEnumerable{T}"/> to compare
+        ///// against <paramref name="y"/>.</param>
+        ///// <returns>True if the instances are equal, false otherwise.</returns>
+        //public static bool operator ==(System.Collections.Generic.IEnumerable<T> x, EquatableList<T> y)
+        //{
+        //    // Call equals.
+        //    return Equals(x, y);
+        //}
+
+        ///// <summary>Overload of the != operator, it compares a
+        ///// <see cref="ComparableList{T}"/> to an <see cref="IEnumerable{T}"/>
+        ///// implementation.</summary>
+        ///// <param name="x">The <see cref="ComparableList{T}"/> to compare
+        ///// against <paramref name="y"/>.</param>
+        ///// <param name="y">The <see cref="IEnumerable{T}"/> to compare
+        ///// against <paramref name="x"/>.</param>
+        ///// <returns>True if the instances are not equal, false otherwise.</returns>
+        //public static bool operator !=(EquatableList<T> x, System.Collections.Generic.IEnumerable<T> y)
+        //{
+        //    // Return the negative of the equals operation.
+        //    return !(x == y);
+        //}
+
+        ///// <summary>Overload of the != operator, it compares a
+        ///// <see cref="ComparableList{T}"/> to an <see cref="IEnumerable{T}"/>
+        ///// implementation.</summary>
+        ///// <param name="y">The <see cref="ComparableList{T}"/> to compare
+        ///// against <paramref name="x"/>.</param>
+        ///// <param name="x">The <see cref="IEnumerable{T}"/> to compare
+        ///// against <paramref name="y"/>.</param>
+        ///// <returns>True if the instances are not equal, false otherwise.</returns>
+        //public static bool operator !=(System.Collections.Generic.IEnumerable<T> x, EquatableList<T> y)
+        //{
+        //    // Return the negative of the equals operation.
+        //    return !(x == y);
+        //}
+
+        #region ICloneable Members
+
+        /// <summary>Clones the <see cref="EquatableList{T}"/>.</summary>
+        /// <remarks>This is a shallow clone.</remarks>
+        /// <returns>A new shallow clone of this
+        /// <see cref="EquatableList{T}"/>.</returns>
+        public object Clone()
+        {
+            // Just create a new one, passing this to the constructor.
+            return new EquatableList<T>(this);
+        }
+
+        #endregion
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/FileSupport.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/FileSupport.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/FileSupport.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/FileSupport.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Support
+{
+    /// <summary>
+    /// Represents the methods to support some operations over files.
+    /// </summary>
+    public class FileSupport
+    {
+        /// <summary>
+        /// Returns an array of abstract pathnames representing the files and directories of the specified path.
+        /// </summary>
+        /// <param name="path">The abstract pathname to list it childs.</param>
+        /// <returns>An array of abstract pathnames childs of the path specified or null if the path is not a directory</returns>
+        public static System.IO.FileInfo[] GetFiles(System.IO.FileInfo path)
+        {
+            if ((path.Attributes & System.IO.FileAttributes.Directory) > 0)
+            {																 
+                String[] fullpathnames = System.IO.Directory.GetFileSystemEntries(path.FullName);
+                System.IO.FileInfo[] result = new System.IO.FileInfo[fullpathnames.Length];
+                for (int i = 0; i < result.Length ; i++)
+                    result[i] = new System.IO.FileInfo(fullpathnames[i]);
+                return result;
+            }
+            else
+                return null;
+        }
+
+        /// <summary>
+        /// Returns a list of files in a give directory.
+        /// </summary>
+        /// <param name="fullName">The full path name to the directory.</param>
+        /// <param name="indexFileNameFilter"></param>
+        /// <returns>An array containing the files.</returns>
+        public static System.String[] GetLuceneIndexFiles(System.String fullName, 
+                                                          Lucene.Net.Index.IndexFileNameFilter indexFileNameFilter)
+        {
+            System.IO.DirectoryInfo dInfo = new System.IO.DirectoryInfo(fullName);
+            System.Collections.ArrayList list = new System.Collections.ArrayList();
+            foreach (System.IO.FileInfo fInfo in dInfo.GetFiles())
+            {
+                if (indexFileNameFilter.Accept(fInfo, fInfo.Name) == true)
+                {
+                    list.Add(fInfo.Name);
+                }
+            }
+            System.String[] retFiles = new System.String[list.Count];
+            list.CopyTo(retFiles);
+            return retFiles;
+        }
+
+        // Disable the obsolete warning since we must use FileStream.Handle
+        // because Mono does not support FileSystem.SafeFileHandle at present.
+#pragma warning disable 618
+
+        /// <summary>
+        /// Flushes the specified file stream. Ensures that all buffered
+        /// data is actually written to the file system.
+        /// </summary>
+        /// <param name="fileStream">The file stream.</param>
+        public static void Sync(System.IO.FileStream fileStream)
+        {
+            if (fileStream == null)
+                throw new ArgumentNullException("fileStream");
+
+            fileStream.Flush();
+
+            //if (OS.IsWindows)
+            //{
+            //    if (!FlushFileBuffers(fileStream.Handle))
+            //        throw new System.IO.IOException();
+            //}
+            //else if (OS.IsUnix)
+            //{
+            //    if (fsync(fileStream.Handle) != IntPtr.Zero)
+            //    throw new System.IO.IOException();
+            //}
+            //else
+            //{
+            //    throw new NotImplementedException();
+            //}
+        }
+
+#pragma warning restore 618
+
+        //[System.Runtime.InteropServices.DllImport("libc")]
+        //extern static IntPtr fsync(IntPtr fd);
+
+        //[System.Runtime.InteropServices.DllImport("kernel32.dll")]
+        //extern static bool FlushFileBuffers(IntPtr hFile);
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/GeneralKeyedCollection.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/GeneralKeyedCollection.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/GeneralKeyedCollection.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/GeneralKeyedCollection.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Support
+{
+    /// <summary>A collection of <typeparamref name="TItem"/> which can be
+    /// looked up by instances of <typeparamref name="TKey"/>.</summary>
+    /// <typeparam name="TItem">The type of the items contains in this
+    /// collection.</typeparam>
+    /// <typeparam name="TKey">The type of the keys that can be used to look
+    /// up the items.</typeparam>
+    internal class GeneralKeyedCollection<TKey, TItem> : System.Collections.ObjectModel.KeyedCollection<TKey, TItem>
+    {
+        /// <summary>Creates a new instance of the
+        /// <see cref="GeneralKeyedCollection"/> class.</summary>
+        /// <param name="converter">The <see cref="Converter{TInput, TOutput}"/> which will convert
+        /// instances of <typeparamref name="TItem"/> to <typeparamref name="TKey"/>
+        /// when the override of <see cref="GetKeyForItem(TItem)"/> is called.</param>
+        internal GeneralKeyedCollection(Converter<TItem, TKey> converter) : base()
+        {
+            // If the converter is null, throw an exception.
+            if (converter == null) throw new ArgumentNullException("converter");
+
+            // Store the converter.
+            this.converter = converter;
+
+            // That's all folks.
+            return;
+        }
+
+        /// <summary>The <see cref="Converter{TInput, TOutput}"/> which will convert
+        /// instances of <typeparamref name="TItem"/> to <typeparamref name="TKey"/>
+        /// when the override of <see cref="GetKeyForItem(TItem)"/> is called.</summary>
+        private readonly Converter<TItem, TKey> converter;
+
+        /// <summary>Converts an item that is added to the collection to
+        /// a key.</summary>
+        /// <param name="item">The instance of <typeparamref name="TItem"/>
+        /// to convert into an instance of <typeparamref name="TKey"/>.</param>
+        /// <returns>The instance of <typeparamref name="TKey"/> which is the
+        /// key for this item.</returns>
+        protected override TKey GetKeyForItem(TItem item)
+        {
+            // The converter is not null.
+            System.Diagnostics.Debug.Assert(converter != null);
+
+            // Call the converter.
+            return converter(item);
+        }
+
+        /// <summary>Determines if a key for an item exists in this
+        /// collection.</summary>
+        /// <param name="key">The instance of <typeparamref name="TKey"/>
+        /// to see if it exists in this collection.</param>
+        /// <returns>True if the key exists in the collection, false otherwise.</returns>
+        public bool ContainsKey(TKey key)
+        {
+            // Call the dictionary - it is lazily created when the first item is added
+            if (Dictionary != null)
+            {
+                return Dictionary.ContainsKey(key);
+            }
+            else
+            {
+                return false;
+            }
+        }
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/ICloneable.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/ICloneable.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/ICloneable.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/ICloneable.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace System
+{
+    public interface ICloneable<T>
+    {
+        T Clone();
+    }
+}
+

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/IThreadRunnable.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/IThreadRunnable.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/IThreadRunnable.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/IThreadRunnable.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/// <summary>
+/// This interface should be implemented by any class whose instances are intended 
+/// to be executed by a thread.
+/// </summary>
+public interface IThreadRunnable
+{
+    /// <summary>
+    /// This method has to be implemented in order that starting of the thread causes the object's 
+    /// run method to be called in that separately executing thread.
+    /// </summary>
+    void Run();
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Number.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Number.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Number.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Number.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,247 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Support
+{
+    /// <summary>
+    /// A simple class for number conversions.
+    /// </summary>
+    public class Number
+    {
+        /// <summary>
+        /// Min radix value.
+        /// </summary>
+        public const int MIN_RADIX = 2;
+        /// <summary>
+        /// Max radix value.
+        /// </summary>
+        public const int MAX_RADIX = 36;
+
+        private const System.String digits = "0123456789abcdefghijklmnopqrstuvwxyz";
+
+
+        /// <summary>
+        /// Converts a number to System.String.
+        /// </summary>
+        /// <param name="number"></param>
+        /// <returns></returns>
+        public static System.String ToString(long number)
+        {
+            System.Text.StringBuilder s = new System.Text.StringBuilder();
+
+            if (number == 0)
+            {
+                s.Append("0");
+            }
+            else
+            {
+                if (number < 0)
+                {
+                    s.Append("-");
+                    number = -number;
+                }
+
+                while (number > 0)
+                {
+                    char c = digits[(int)number % 36];
+                    s.Insert(0, c);
+                    number = number / 36;
+                }
+            }
+
+            return s.ToString();
+        }
+           
+
+        /// <summary>
+        /// Converts a number to System.String.
+        /// </summary>
+        /// <param name="f"></param>
+        /// <returns></returns>
+        public static System.String ToString(float f)
+        {
+            if (((float)(int)f) == f)
+            {
+                return ((int)f).ToString() + ".0";
+            }
+            else
+            {
+                return f.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
+            }
+        }
+
+        /// <summary>
+        /// Converts a number to System.String in the specified radix.
+        /// </summary>
+        /// <param name="i">A number to be converted.</param>
+        /// <param name="radix">A radix.</param>
+        /// <returns>A System.String representation of the number in the specified redix.</returns>
+        public static System.String ToString(long i, int radix)
+        {
+            if (radix < MIN_RADIX || radix > MAX_RADIX)
+                radix = 10;
+
+            char[] buf = new char[65];
+            int charPos = 64;
+            bool negative = (i < 0);
+
+            if (!negative) 
+            {
+                i = -i;
+            }
+
+            while (i <= -radix) 
+            {
+                buf[charPos--] = digits[(int)(-(i % radix))];
+                i = i / radix;
+            }
+            buf[charPos] = digits[(int)(-i)];
+
+            if (negative) 
+            {
+                buf[--charPos] = '-';
+            }
+
+            return new System.String(buf, charPos, (65 - charPos)); 
+        }
+
+        /// <summary>
+        /// Parses a number in the specified radix.
+        /// </summary>
+        /// <param name="s">An input System.String.</param>
+        /// <param name="radix">A radix.</param>
+        /// <returns>The parsed number in the specified radix.</returns>
+        public static long Parse(System.String s, int radix)
+        {
+            if (s == null) 
+            {
+                throw new ArgumentException("null");
+            }
+
+            if (radix < MIN_RADIX) 
+            {
+                throw new NotSupportedException("radix " + radix +
+                                                " less than Number.MIN_RADIX");
+            }
+            if (radix > MAX_RADIX) 
+            {
+                throw new NotSupportedException("radix " + radix +
+                                                " greater than Number.MAX_RADIX");
+            }
+
+            long result = 0;
+            long mult = 1;
+
+            s = s.ToLower();
+			
+            for (int i = s.Length - 1; i >= 0; i--)
+            {
+                int weight = digits.IndexOf(s[i]);
+                if (weight == -1)
+                    throw new FormatException("Invalid number for the specified radix");
+
+                result += (weight * mult);
+                mult *= radix;
+            }
+
+            return result;
+        }
+
+        /// <summary>
+        /// Performs an unsigned bitwise right shift with the specified number
+        /// </summary>
+        /// <param name="number">Number to operate on</param>
+        /// <param name="bits">Ammount of bits to shift</param>
+        /// <returns>The resulting number from the shift operation</returns>
+        public static int URShift(int number, int bits)
+        {
+            return (int) (((uint) number) >> bits);
+        }
+
+
+        /// <summary>
+        /// Performs an unsigned bitwise right shift with the specified number
+        /// </summary>
+        /// <param name="number">Number to operate on</param>
+        /// <param name="bits">Ammount of bits to shift</param>
+        /// <returns>The resulting number from the shift operation</returns>
+        public static long URShift(long number, int bits)
+        {
+            return (long) (((ulong) number) >> bits);
+        }
+
+
+        /// <summary>
+        /// Returns the index of the first bit that is set to true that occurs 
+        /// on or after the specified starting index. If no such bit exists 
+        /// then -1 is returned.
+        /// </summary>
+        /// <param name="bits">The BitArray object.</param>
+        /// <param name="fromIndex">The index to start checking from (inclusive).</param>
+        /// <returns>The index of the next set bit.</returns>
+        public static int NextSetBit(System.Collections.BitArray bits, int fromIndex)
+        {
+            for (int i = fromIndex; i < bits.Length; i++)
+            {
+                if (bits[i] == true)
+                {
+                    return i;
+                }
+            }
+            return -1;
+        }
+        
+        /// <summary>
+        /// Converts a System.String number to long.
+        /// </summary>
+        /// <param name="s"></param>
+        /// <returns></returns>
+        public static long ToInt64(System.String s)
+        {
+            long number = 0;
+            long factor;
+
+            // handle negative number
+            if (s.StartsWith("-"))
+            {
+                s = s.Substring(1);
+                factor = -1;
+            }
+            else
+            {
+                factor = 1;
+            }
+
+            // generate number
+            for (int i = s.Length - 1; i > -1; i--)
+            {
+                int n = digits.IndexOf(s[i]);
+
+                // not supporting fractional or scientific notations
+                if (n < 0)
+                    throw new System.ArgumentException("Invalid or unsupported character in number: " + s[i]);
+
+                number += (n * factor);
+                factor *= 36;
+            }
+
+            return number;
+        }
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Os.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Os.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Os.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Os.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Support
+{
+    /// <summary>
+    /// Provides platform infos.
+    /// </summary>
+    public class Os
+    {
+        static bool isUnix;
+        static bool isWindows;
+
+        static Os()
+        {
+            PlatformID pid = Environment.OSVersion.Platform;
+            isWindows = pid == PlatformID.Win32NT || pid == PlatformID.Win32Windows;
+
+            // we use integers instead of enum tags because "MacOS"
+            // requires 2.0 SP2, 3.0 SP2 or 3.5 SP1.
+            // 128 is mono's old platform tag for Unix.
+            int id = (int)pid;
+            isUnix = id == 4 || id == 6 || id == 128;
+        }
+
+        /// <summary>
+        /// Whether we run under a Unix platform.
+        /// </summary>
+        public static bool IsUnix
+        {
+            get { return isUnix; }
+        }
+
+        /// <summary>
+        /// Whether we run under a supported Windows platform.
+        /// </summary>
+        public static bool IsWindows
+        {
+            get { return isWindows; }
+        }
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Set.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Set.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Set.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Set.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Support
+{
+    [Serializable]
+    public class Set<T> : System.Collections.Generic.List<T>
+    {
+        System.Collections.Generic.HashSet<T> _Set = new System.Collections.Generic.HashSet<T>();
+        
+        public new void Add(T item)
+        {
+            if (_Set.Contains(item)) return;
+            _Set.Add(item);
+            base.Add(item);
+        }
+
+        public void Add(Support.Set<T> items)
+        {
+            foreach(T item in items)
+            {
+                if(_Set.Contains(item)) continue;
+                _Set.Add(item);
+                base.Add(item);
+            }
+        }
+
+        public void Add(System.Collections.Generic.IList<T> items)
+        {
+            foreach (T item in items)
+            {
+                if (_Set.Contains(item)) continue;
+                _Set.Add(item);
+                base.Add(item);
+            }
+        }
+
+        public new bool Contains(T item)
+        {
+            return _Set.Contains(item);
+        }
+
+        public new void Clear()
+        {
+            _Set.Clear();
+            base.Clear();
+        }
+
+        public new void Remove(T item)
+        {
+            _Set.Remove(item);
+            base.Remove(item);
+        }
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/SharpZipLib.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/SharpZipLib.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/SharpZipLib.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/SharpZipLib.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Support
+{
+    public class SharpZipLib
+    {
+        static System.Reflection.Assembly asm = null;
+
+        static SharpZipLib()
+        {
+            try
+            {
+                asm = System.Reflection.Assembly.Load("ICSharpCode.SharpZipLib");
+            }
+            catch{}
+        }
+
+        public static Deflater CreateDeflater()
+        {
+            if (asm == null) throw new System.IO.FileNotFoundException("Can not load ICSharpCode.SharpZipLib.dll"); 
+            return new Deflater(asm.CreateInstance("ICSharpCode.SharpZipLib.Zip.Compression.Deflater"));
+        }
+
+        public static Inflater CreateInflater()
+        {
+            if (asm == null) throw new System.IO.FileNotFoundException("Can not load ICSharpCode.SharpZipLib.dll");
+            return new Inflater(asm.CreateInstance("ICSharpCode.SharpZipLib.Zip.Compression.Inflater"));
+        }
+
+
+        public class Inflater
+        {
+            delegate void SetInputDelegate(byte[] buffer);
+            delegate bool GetIsFinishedDelegate();
+            delegate int InflateDelegate(byte[] buffer);
+
+            SetInputDelegate setInputMethod;
+            GetIsFinishedDelegate getIsFinishedMethod;
+            InflateDelegate inflateMethod;
+
+            internal Inflater(object inflaterInstance)
+            {
+                Type type = inflaterInstance.GetType();
+
+                setInputMethod = (SetInputDelegate)Delegate.CreateDelegate(
+                    typeof(SetInputDelegate),
+                    inflaterInstance,
+                    type.GetMethod("SetInput", new Type[] { typeof(byte[]) }));
+
+                getIsFinishedMethod = (GetIsFinishedDelegate)Delegate.CreateDelegate(
+                    typeof(GetIsFinishedDelegate),
+                    inflaterInstance,
+                    type.GetMethod("get_IsFinished", Type.EmptyTypes));
+
+                inflateMethod = (InflateDelegate)Delegate.CreateDelegate(
+                    typeof(InflateDelegate),
+                    inflaterInstance,
+                    type.GetMethod("Inflate", new Type[] { typeof(byte[]) }));
+            }
+
+            public void SetInput(byte[] buffer)
+            {
+                setInputMethod(buffer);
+            }
+
+            public bool IsFinished
+            {
+                get { return getIsFinishedMethod(); }
+            }
+
+            public int Inflate(byte[] buffer)
+            {
+                return inflateMethod(buffer);
+            }
+        }
+
+
+        public class Deflater 
+        {
+            delegate void SetLevelDelegate(int level);
+            delegate void SetInputDelegate(byte[] input, int offset, int count);
+            delegate void FinishDelegate();
+            delegate bool GetIsFinishedDelegate();
+            delegate int DeflateDelegate(byte[] output);
+
+            SetLevelDelegate setLevelMethod;
+            SetInputDelegate setInputMethod;
+            FinishDelegate finishMethod;
+            GetIsFinishedDelegate getIsFinishedMethod;
+            DeflateDelegate deflateMethod;
+
+            public const int BEST_COMPRESSION = 9;
+
+            internal Deflater(object deflaterInstance)
+            {
+                Type type = deflaterInstance.GetType();
+
+                setLevelMethod = (SetLevelDelegate)Delegate.CreateDelegate(
+                    typeof(SetLevelDelegate),
+                    deflaterInstance,
+                    type.GetMethod("SetLevel", new Type[] { typeof(int) }));
+
+                setInputMethod = (SetInputDelegate)Delegate.CreateDelegate(
+                    typeof(SetInputDelegate),
+                    deflaterInstance,
+                    type.GetMethod("SetInput", new Type[] { typeof(byte[]), typeof(int), typeof(int) }));
+
+                finishMethod = (FinishDelegate)Delegate.CreateDelegate(
+                    typeof(FinishDelegate),
+                    deflaterInstance,
+                    type.GetMethod("Finish", Type.EmptyTypes));
+
+                getIsFinishedMethod = (GetIsFinishedDelegate)Delegate.CreateDelegate(
+                    typeof(GetIsFinishedDelegate),
+                    deflaterInstance,
+                    type.GetMethod("get_IsFinished", Type.EmptyTypes));
+
+                deflateMethod = (DeflateDelegate)Delegate.CreateDelegate(
+                    typeof(DeflateDelegate),
+                    deflaterInstance,
+                    type.GetMethod("Deflate", new Type[] { typeof(byte[]) }));
+            }
+            
+            public void SetLevel(int level)
+            {
+                setLevelMethod(level);
+            }
+
+            public void SetInput(byte[] input, int offset, int count)
+            {
+                setInputMethod(input, offset, count);
+            }
+
+            public void Finish()
+            {
+                finishMethod();
+            }
+
+            public bool IsFinished
+            {
+                get { return getIsFinishedMethod(); }
+            }
+
+            public int Deflate(byte[] output)
+            {
+                return deflateMethod(output);
+            }
+        }
+    }
+}
\ No newline at end of file

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Single.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Single.cs?rev=1100459&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Single.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Single.cs Sat May  7 06:22:20 2011
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Lucene.Net.Support
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public class Single
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="s"></param>
+        /// <param name="style"></param>
+        /// <param name="provider"></param>
+        /// <returns></returns>
+        public static System.Single Parse(System.String s, System.Globalization.NumberStyles style, System.IFormatProvider provider)
+        {
+            try
+            {
+                if (s.EndsWith("f") || s.EndsWith("F"))
+                    return System.Single.Parse(s.Substring(0, s.Length - 1), style, provider);
+                else
+                    return System.Single.Parse(s, style, provider);
+            }
+            catch (System.FormatException fex)
+            {
+                throw fex;					
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="s"></param>
+        /// <param name="provider"></param>
+        /// <returns></returns>
+        public static System.Single Parse(System.String s, System.IFormatProvider provider)
+        {
+            try
+            {
+                if (s.EndsWith("f") || s.EndsWith("F"))
+                    return System.Single.Parse(s.Substring(0, s.Length - 1), provider);
+                else
+                    return System.Single.Parse(s, provider);
+            }
+            catch (System.FormatException fex)
+            {
+                throw fex;					
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="s"></param>
+        /// <param name="style"></param>
+        /// <returns></returns>
+        public static System.Single Parse(System.String s, System.Globalization.NumberStyles style)
+        {
+            try
+            {
+                if (s.EndsWith("f") || s.EndsWith("F"))
+                    return System.Single.Parse(s.Substring(0, s.Length - 1), style);
+                else
+                    return System.Single.Parse(s, style);
+            }
+            catch(System.FormatException fex)
+            {
+                throw fex;					
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="s"></param>
+        /// <returns></returns>
+        public static System.Single Parse(System.String s)
+        {
+            try
+            {
+                if (s.EndsWith("f") || s.EndsWith("F"))
+                    return System.Single.Parse(s.Substring(0, s.Length - 1).Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator));
+                else
+                    return System.Single.Parse(s.Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator));
+            }
+            catch(System.FormatException fex)
+            {
+                throw fex;					
+            }
+        }
+
+        public static bool TryParse(System.String s, out float f)
+        {
+            bool ok = false;
+
+            if (s.EndsWith("f") || s.EndsWith("F"))
+                ok = System.Single.TryParse(s.Substring(0, s.Length - 1).Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), out f);
+            else
+                ok = System.Single.TryParse(s.Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), out f);
+
+            return ok;
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="f"></param>
+        /// <returns></returns>
+        public static string ToString(float f)
+        {
+            return f.ToString().Replace(System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, ".");
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="f"></param>
+        /// <param name="format"></param>
+        /// <returns></returns>
+        public static string ToString(float f, string format)
+        {
+            return f.ToString(format).Replace(System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, ".");
+        }
+    }
+}
\ No newline at end of file



Mime
View raw message