lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aro...@apache.org
Subject svn commit: r411501 [23/30] - in /incubator/lucene.net/trunk/C#/src: ./ Demo/DeleteFiles/ Demo/DemoLib/ Demo/DemoLib/HTML/ Demo/IndexFiles/ Demo/IndexHtml/ Demo/SearchFiles/ Lucene.Net/ Lucene.Net/Analysis/ Lucene.Net/Analysis/Standard/ Lucene.Net/Docu...
Date Sun, 04 Jun 2006 02:41:25 GMT
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/RAMDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Store/RAMDirectory.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/RAMDirectory.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/RAMDirectory.cs Sat Jun  3 19:41:13 2006
@@ -13,18 +13,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
+
 namespace Lucene.Net.Store
 {
 	
 	/// <summary> A memory-resident {@link Directory} implementation.
 	/// 
 	/// </summary>
-	/// <version>  $Id: RAMDirectory.java,v 1.15 2004/05/09 12:41:47 ehatcher Exp $
+	/// <version>  $Id: RAMDirectory.java 351779 2005-12-02 17:37:50Z bmesser $
 	/// </version>
 	public sealed class RAMDirectory : Directory
 	{
-		private class AnonymousClassLock:Lock
+		private class AnonymousClassLock : Lock
 		{
 			public AnonymousClassLock(System.String name, RAMDirectory enclosingInstance)
 			{
@@ -51,7 +53,7 @@
 				{
 					if (!Enclosing_Instance.FileExists(name))
 					{
-						Enclosing_Instance.CreateFile(name).Close();
+						Enclosing_Instance.CreateOutput(name).Close();
 						return true;
 					}
 					return false;
@@ -82,26 +84,33 @@
 		/// </summary>
 		/// <param name="dir">a <code>Directory</code> value
 		/// </param>
-		/// <exception cref=""> IOException if an error occurs
+		/// <exception cref="IOException">if an error occurs
 		/// </exception>
-		public RAMDirectory(Directory dir) : this(dir, false)
+		public RAMDirectory(Directory dir):this(dir, false)
 		{
 		}
 		
 		private RAMDirectory(Directory dir, bool closeDir)
 		{
 			System.String[] files = dir.List();
+			byte[] buf = new byte[BufferedIndexOutput.BUFFER_SIZE];
 			for (int i = 0; i < files.Length; i++)
 			{
 				// make place on ram disk
-				OutputStream os = CreateFile(System.IO.Path.GetFileName(files[i]));
+				IndexOutput os = CreateOutput(System.IO.Path.GetFileName(files[i]));
 				// read current file
-				InputStream is_Renamed = dir.OpenFile(files[i]);
+				IndexInput is_Renamed = dir.OpenInput(files[i]);
 				// and copy to ram disk
 				int len = (int) is_Renamed.Length();
-				byte[] buf = new byte[len];
-				is_Renamed.ReadBytes(buf, 0, len);
-				os.WriteBytes(buf, len);
+				int readCount = 0;
+				while (readCount < len)
+				{
+					int toRead = readCount + BufferedIndexOutput.BUFFER_SIZE > len?len - readCount:BufferedIndexOutput.BUFFER_SIZE;
+					is_Renamed.ReadBytes(buf, 0, toRead);
+					os.WriteBytes(buf, toRead);
+					readCount += toRead;
+				}
+				
 				// graceful cleanup
 				is_Renamed.Close();
 				os.Close();
@@ -161,7 +170,7 @@
 			//     final boolean MONITOR = false;
 			
 			RAMFile file = (RAMFile) files[name];
-			long ts2, ts1 = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
+			long ts2, ts1 = System.DateTime.Now.Ticks;
 			do 
 			{
 				try
@@ -171,7 +180,7 @@
 				catch (System.Threading.ThreadInterruptedException)
 				{
 				}
-				ts2 = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
+				ts2 = System.DateTime.Now.Ticks;
 				//       if (MONITOR) {
 				//         count++;
 				//       }
@@ -208,7 +217,7 @@
 		/// <summary>Creates a new, empty file in the directory with the given name.
 		/// Returns a stream writing this file. 
 		/// </summary>
-		public override OutputStream CreateFile(System.String name)
+		public override IndexOutput CreateOutput(System.String name)
 		{
 			RAMFile file = new RAMFile();
 			files[name] = file;
@@ -216,7 +225,7 @@
 		}
 		
 		/// <summary>Returns a stream reading an existing file. </summary>
-		public override InputStream OpenFile(System.String name)
+		public override IndexInput OpenInput(System.String name)
 		{
 			RAMFile file = (RAMFile) files[name];
 			return new RAMInputStream(file);

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/RAMFile.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Store/RAMFile.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/RAMFile.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/RAMFile.cs Sat Jun  3 19:41:13 2006
@@ -13,7 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
+
 namespace Lucene.Net.Store
 {
 	
@@ -21,6 +23,6 @@
 	{
 		internal System.Collections.ArrayList buffers = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
 		internal long length;
-		internal long lastModified = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
+		internal long lastModified = System.DateTime.Now.Ticks;
 	}
 }

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/RAMInputStream.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Store/RAMInputStream.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/RAMInputStream.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/RAMInputStream.cs Sat Jun  3 19:41:13 2006
@@ -13,19 +13,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
+
 namespace Lucene.Net.Store
 {
-	/// <summary> A memory-resident {@link InputStream} implementation.
+	
+	/// <summary> A memory-resident {@link IndexInput} implementation.
 	/// 
 	/// </summary>
-	/// <version>  $Id: RAMInputStream.java,v 1.2 2004/03/29 22:48:05 cutting Exp $
+	/// <version>  $Id: RAMInputStream.java 150537 2004-09-28 20:45:26Z cutting $
 	/// </version>
 	
-	class RAMInputStream:InputStream, System.ICloneable
+	class RAMInputStream : BufferedIndexInput, System.ICloneable
 	{
 		private RAMFile file;
 		private int pointer = 0;
+		private long length;
 		
 		public RAMInputStream(RAMFile f)
 		{
@@ -60,11 +64,27 @@
 		{
 			pointer = (int) pos;
 		}
-        /*
-		override public System.Object Clone()
+		
+		public override long Length()
 		{
-			return null;
+			return length;
 		}
+
+        /*
+        // {{Aroush-1.9}} Do we need this Clone()?!
+		public override System.Object Clone()
+		{
+            SegmentTermEnum clone = null;
+            try
+            {
+                clone = (SegmentTermEnum) base.MemberwiseClone();
+            }
+            catch (System.Exception)
+            {
+            }
+
+            return clone;
+        }
         */
 	}
 }

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/RAMOutputStream.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Store/RAMOutputStream.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/RAMOutputStream.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/RAMOutputStream.cs Sat Jun  3 19:41:13 2006
@@ -13,23 +13,25 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
+
 namespace Lucene.Net.Store
 {
 	
-	/// <summary> A memory-resident {@link OutputStream} implementation.
+	/// <summary> A memory-resident {@link IndexOutput} implementation.
 	/// 
 	/// </summary>
-	/// <version>  $Id: RAMOutputStream.java,v 1.2 2004/03/29 22:48:05 cutting Exp $
+	/// <version>  $Id: RAMOutputStream.java 150537 2004-09-28 20:45:26Z cutting $
 	/// </version>
 	
-	public class RAMOutputStream:OutputStream
+	public class RAMOutputStream : BufferedIndexOutput
 	{
 		private RAMFile file;
 		private int pointer = 0;
 		
 		/// <summary>Construct an empty output buffer. </summary>
-		public RAMOutputStream():this(new RAMFile())
+		public RAMOutputStream() : this(new RAMFile())
 		{
 		}
 		
@@ -39,7 +41,7 @@
 		}
 		
 		/// <summary>Copy the current contents of this buffer to the named output. </summary>
-		public virtual void  WriteTo(OutputStream out_Renamed)
+		public virtual void  WriteTo(IndexOutput out_Renamed)
 		{
 			Flush();
 			long end = file.length;
@@ -60,7 +62,7 @@
 		}
 		
 		/// <summary>Resets this to an empty buffer. </summary>
-		public virtual void  Leset()
+		public virtual void  Reset()
 		{
 			try
 			{
@@ -103,7 +105,7 @@
 			if (pointer > file.length)
 				file.length = pointer;
 			
-			file.lastModified = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
+			file.lastModified = System.DateTime.Now.Ticks;
 		}
 		
 		public override void  Close()

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/SupportClass.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/SupportClass.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/SupportClass.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/SupportClass.cs Sat Jun  3 19:41:13 2006
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
 
 /// <summary>
@@ -272,6 +273,31 @@
     }
 
     /// <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>
     /// A simple class for number conversions.
     /// </summary>
     public class Number
@@ -375,6 +401,40 @@
 
             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)
+        {
+            if (number >= 0)
+                return number >> bits;
+            else
+                return (number >> bits) + (2 << ~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>
@@ -594,6 +654,69 @@
                 return defValue;
             }
             return theValue;
+        }
+    }
+
+    public static System.Collections.SortedList TailMap(System.Collections.SortedList list, System.Object limit)
+    {
+        System.Collections.Comparer comparer = System.Collections.Comparer.Default;
+        System.Collections.SortedList newList = new System.Collections.SortedList();
+
+        if (list != null)
+        {
+            if (list.Count > 0)
+            {
+                int index = 0;
+                while (comparer.Compare(list.GetKey(index), limit) < 0)
+                    index++;
+
+                for (; index < list.Count; index++)
+                    newList.Add(list.GetKey(index), list[list.GetKey(index)]);
+            }
+        }
+
+        return newList;
+    }
+
+    /// <summary>
+    /// Use for .NET 1.1 Framework only.
+    /// </summary>
+    public class CompressionSupport
+    {
+        public interface ICompressionAdapter
+        {
+            byte[] Compress(byte[] input);
+            byte[] Uncompress(byte[] input);
+        }
+
+        private static ICompressionAdapter compressionAdapter;
+
+        public static byte[] Uncompress(byte[] input)
+        {
+            CheckCompressionSupport();
+            return compressionAdapter.Uncompress(input);
+        }
+
+        public static byte[] Compress(byte[] input)
+        {
+            CheckCompressionSupport();
+            return compressionAdapter.Compress(input);
+        }
+
+        private static void CheckCompressionSupport()
+        {
+            if (compressionAdapter == null)
+            {
+                System.String compressionLibClassName = SupportClass.AppSettings.Get("Lucene.Net.CompressionLib.class", null);
+                if (compressionLibClassName == null)
+                    throw new System.SystemException("Compression support not configured"); 
+
+                Type compressionLibClass = Type.GetType(compressionLibClassName, true);
+                System.Object compressionAdapterObj = Activator.CreateInstance(compressionLibClass);
+                compressionAdapter = compressionAdapterObj as ICompressionAdapter;
+                if (compressionAdapter == null)
+                    throw new System.SystemException("Compression adapter does not support the ICompressionAdapter interface");
+            }
         }
     }
 }

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/BitVector.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/BitVector.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/BitVector.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/BitVector.cs Sat Jun  3 19:41:13 2006
@@ -13,10 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
 using Directory = Lucene.Net.Store.Directory;
-using InputStream = Lucene.Net.Store.InputStream;
-using OutputStream = Lucene.Net.Store.OutputStream;
+using IndexInput = Lucene.Net.Store.IndexInput;
+using IndexOutput = Lucene.Net.Store.IndexOutput;
+
 namespace Lucene.Net.Util
 {
 	
@@ -30,7 +32,7 @@
 	/// </summary>
 	/// <author>  Doug Cutting
 	/// </author>
-	/// <version>  $Id: BitVector.java,v 1.4 2004/03/29 22:48:05 cutting Exp $
+	/// <version>  $Id: BitVector.java 150536 2004-09-28 18:15:52Z cutting $
 	/// </version>
 	public sealed class BitVector
 	{
@@ -56,7 +58,7 @@
 		/// <summary>Sets the value of <code>bit</code> to zero. </summary>
 		public void  Clear(int bit)
 		{
-			bits[bit >> 3] &= (byte) ~ (1 << (bit & 7));
+			bits[bit >> 3] &= (byte) (~ (1 << (bit & 7)));
 			count = - 1;
 		}
 		
@@ -103,7 +105,7 @@
 		/// </summary>
 		public void  Write(Directory d, System.String name)
 		{
-			OutputStream output = d.CreateFile(name);
+			IndexOutput output = d.CreateOutput(name);
 			try
 			{
 				output.WriteInt(Size()); // write size
@@ -121,7 +123,7 @@
 		/// </summary>
 		public BitVector(Directory d, System.String name)
 		{
-			InputStream input = d.OpenFile(name);
+			IndexInput input = d.OpenInput(name);
 			try
 			{
 				size = input.ReadInt(); // read size

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/Constants.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs Sat Jun  3 19:41:13 2006
@@ -13,15 +13,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
+
 namespace Lucene.Net.Util
 {
+	
 	/// <summary> Some useful constants.
 	/// 
 	/// </summary>
 	/// <author>   Doug Cutting
 	/// </author>
-	/// <version>  $Id: Constants.java,v 1.3 2004/03/29 22:48:05 cutting Exp $
+	/// <version>  $Id: Constants.java 189792 2005-06-09 18:58:30Z bmesser $
 	/// 
 	/// </version>
 	
@@ -32,7 +35,7 @@
 		} // can't construct
 		
 		/// <summary>The value of <tt>System.getProperty("java.version")<tt>. *</summary>
-		public static readonly System.String JAVA_VERSION = System.Configuration.ConfigurationSettings.AppSettings.Get("java.version");
+		public static readonly System.String JAVA_VERSION = System.Configuration.ConfigurationSettings.AppSettings.Get("java.version");     // {{Aroush-1.9}}
 		/// <summary>True iff this is Java version 1.1. </summary>
 		public static readonly bool JAVA_1_1 = JAVA_VERSION.StartsWith("1.1.");
 		/// <summary>True iff this is Java version 1.2. </summary>

Added: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Parameter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/Parameter.cs?rev=411501&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Parameter.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Parameter.cs Sat Jun  3 19:41:13 2006
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ * 
+ * Licensed 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.Util
+{
+	
+	/// <summary> A serializable Enum class.</summary>
+	[Serializable]
+	public abstract class Parameter
+	{
+		internal static System.Collections.IDictionary allParameters = new System.Collections.Hashtable();
+		
+		private System.String name;
+		
+		private Parameter()
+		{
+			// typesafe enum pattern, no public constructor
+		}
+		
+		protected internal Parameter(System.String name)
+		{
+			// typesafe enum pattern, no public constructor
+			this.name = name;
+			System.String key = MakeKey(name);
+			
+			if (allParameters.Contains(key))
+				throw new System.ArgumentException("Parameter name " + key + " already used!");
+			
+			allParameters[key] = this;
+		}
+		
+		private System.String MakeKey(System.String name)
+		{
+			return GetType() + " " + name;
+		}
+		
+		public override System.String ToString()
+		{
+			return name;
+		}
+		
+		/// <summary> Resolves the deserialized instance to the local reference for accurate
+		/// equals() and == comparisons.
+		/// 
+		/// </summary>
+		/// <returns> a reference to Parameter as resolved in the local VM
+		/// </returns>
+		/// <throws>  ObjectStreamException </throws>
+		protected internal virtual System.Object ReadResolve()
+		{
+			System.Object par = allParameters[MakeKey(name)];
+			
+			if (par == null)
+				throw new System.IO.IOException("Unknown parameter value: " + name);
+			
+			return par;
+		}
+	}
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/PriorityQueue.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/PriorityQueue.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/PriorityQueue.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/PriorityQueue.cs Sat Jun  3 19:41:13 2006
@@ -13,9 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
+
 namespace Lucene.Net.Util
 {
+	
 	/// <summary>A PriorityQueue maintains a partial ordering of its elements such that the
 	/// least element can always be found in constant time.  Put()'s and pop()'s
 	/// require log(size) time. 
@@ -54,7 +57,7 @@
 		/// <summary> Adds element to the PriorityQueue in log(size) time if either
 		/// the PriorityQueue is not full, or not lessThan(element, top()).
 		/// </summary>
-		/// <param name="">element
+		/// <param name="element">
 		/// </param>
 		/// <returns> true if element is added, false otherwise.
 		/// </returns>
@@ -133,12 +136,12 @@
 		{
 			int i = size;
 			System.Object node = heap[i]; // save bottom node
-            int j = (int) (((uint) i) >> 1);
+			int j = SupportClass.Number.URShift(i, 1);
 			while (j > 0 && LessThan(node, heap[j]))
 			{
 				heap[i] = heap[j]; // shift parents down
 				i = j;
-                j = (int) (((uint) j) >> 1);
+				j = SupportClass.Number.URShift(j, 1);
 			}
 			heap[i] = node; // install saved node
 		}

Added: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/SmallFloat.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/SmallFloat.cs?rev=411501&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/SmallFloat.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/SmallFloat.cs Sat Jun  3 19:41:13 2006
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ * 
+ * Licensed 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.Util
+{
+	
+	
+	/// <summary>Floating point numbers smaller than 32 bits.
+	/// 
+	/// </summary>
+	/// <author>  yonik
+	/// </author>
+	/// <version>  $Id$
+	/// </version>
+	public class SmallFloat
+	{
+		
+		/// <summary>Converts a 32 bit float to an 8 bit float.
+		/// <br>Values less than zero are all mapped to zero.
+		/// <br>Values are truncated (rounded down) to the nearest 8 bit value.
+		/// <br>Values between zero and the smallest representable value
+		/// are rounded up.
+		/// 
+		/// </summary>
+		/// <param name="f">the 32 bit float to be converted to an 8 bit float (byte)
+		/// </param>
+		/// <param name="numMantissaBits">the number of mantissa bits to use in the byte, with the remainder to be used in the exponent
+		/// </param>
+		/// <param name="zeroExp">the zero-point in the range of exponent values
+		/// </param>
+		/// <returns> the 8 bit float representation
+		/// </returns>
+		public static sbyte FloatToByte(float f, int numMantissaBits, int zeroExp)
+		{
+			// Adjustment from a float zero exponent to our zero exponent,
+			// shifted over to our exponent position.
+			int fzero = (63 - zeroExp) << numMantissaBits;
+            int bits = System.BitConverter.ToInt32(System.BitConverter.GetBytes(f), 0);
+			int smallfloat = bits >> (24 - numMantissaBits);
+			if (smallfloat < fzero)
+			{
+				return (bits <= 0) ? (sbyte) 0 : (sbyte) 1; // underflow is mapped to smallest non-zero number.
+			}
+			else if (smallfloat >= fzero + 0x100)
+			{
+				return - 1; // overflow maps to largest number
+			}
+			else
+			{
+				return (sbyte) (smallfloat - fzero);
+			}
+		}
+		
+		/// <summary>Converts an 8 bit float to a 32 bit float. </summary>
+		public static float ByteToFloat(byte b, int numMantissaBits, int zeroExp)
+		{
+			// on Java1.5 & 1.6 JVMs, prebuilding a decoding array and doing a lookup
+			// is only a little bit faster (anywhere from 0% to 7%)
+			if (b == 0)
+				return 0.0f;
+			int bits = (b & 0xff) << (24 - numMantissaBits);
+			bits += ((63 - zeroExp) << 24);
+			return BitConverter.ToSingle(BitConverter.GetBytes(bits), 0);
+		}
+		
+		
+		//
+		// Some specializations of the generic functions follow.
+		// The generic functions are just as fast with current (1.5)
+		// -server JVMs, but still slower with client JVMs.
+		//
+		
+		/// <summary>floatToByte(b, mantissaBits=3, zeroExponent=15)
+		/// <br>smallest non-zero value = 5.820766E-10
+		/// <br>largest value = 7.5161928E9
+		/// <br>epsilon = 0.125
+		/// </summary>
+		public static sbyte FloatToByte315(float f)
+		{
+            int bits = System.BitConverter.ToInt32(System.BitConverter.GetBytes(f), 0);
+			int smallfloat = bits >> (24 - 3);
+			if (smallfloat < (63 - 15) << 3)
+			{
+				return (bits <= 0) ? (sbyte) 0 : (sbyte) 1;
+			}
+			if (smallfloat >= ((63 - 15) << 3) + 0x100)
+			{
+				return - 1;
+			}
+			return (sbyte) (smallfloat - ((63 - 15) << 3));
+		}
+		
+		/// <summary>byteToFloat(b, mantissaBits=3, zeroExponent=15) </summary>
+		public static float Byte315ToFloat(byte b)
+		{
+			// on Java1.5 & 1.6 JVMs, prebuilding a decoding array and doing a lookup
+			// is only a little bit faster (anywhere from 0% to 7%)
+			if (b == 0)
+				return 0.0f;
+			int bits = (b & 0xff) << (24 - 3);
+			bits += ((63 - 15) << 24);
+			return BitConverter.ToSingle(BitConverter.GetBytes(bits), 0);
+		}
+		
+		
+		/// <summary>floatToByte(b, mantissaBits=5, zeroExponent=2)
+		/// <br>smallest nonzero value = 0.033203125
+		/// <br>largest value = 1984.0
+		/// <br>epsilon = 0.03125
+		/// </summary>
+		public static sbyte FloatToByte52(float f)
+		{
+            int bits = System.BitConverter.ToInt32(System.BitConverter.GetBytes(f), 0);
+			int smallfloat = bits >> (24 - 5);
+			if (smallfloat < (63 - 2) << 5)
+			{
+				return (bits <= 0) ? (sbyte) 0 : (sbyte) 1;
+			}
+			if (smallfloat >= ((63 - 2) << 5) + 0x100)
+			{
+				return - 1;
+			}
+			return (sbyte) (smallfloat - ((63 - 2) << 5));
+		}
+		
+		/// <summary>byteToFloat(b, mantissaBits=5, zeroExponent=2) </summary>
+		public static float Byte52ToFloat(byte b)
+		{
+			// on Java1.5 & 1.6 JVMs, prebuilding a decoding array and doing a lookup
+			// is only a little bit faster (anywhere from 0% to 7%)
+			if (b == 0)
+				return 0.0f;
+			int bits = (b & 0xff) << (24 - 5);
+			bits += ((63 - 2) << 24);
+			return BitConverter.ToSingle(BitConverter.GetBytes(bits), 0);
+		}
+	}
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/StringHelper.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/StringHelper.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/StringHelper.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/StringHelper.cs Sat Jun  3 19:41:13 2006
@@ -13,12 +13,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
+
 namespace Lucene.Net.Util
 {
+	
+	
 	/// <summary> Methods for manipulating strings.
 	/// 
-	/// $Id: StringHelper.java,v 1.2 2004/03/25 13:39:59 otis Exp $
+	/// $Id: StringHelper.java 150248 2004-03-25 13:39:59Z otis $
 	/// </summary>
 	public abstract class StringHelper
 	{

Added: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/ToStringUtils.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/ToStringUtils.cs?rev=411501&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/ToStringUtils.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/ToStringUtils.cs Sat Jun  3 19:41:13 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ * 
+ * Licensed 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.Util
+{
+	
+	public class ToStringUtils
+	{
+		public static System.String Boost(float boost)
+		{
+			if (boost != 1.0f)
+			{
+				return "^" + boost.ToString();
+			}
+			else
+				return "";
+		}
+	}
+}
\ No newline at end of file

Added: incubator/lucene.net/trunk/C#/src/README.txt
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/README.txt?rev=411501&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/README.txt (added)
+++ incubator/lucene.net/trunk/C#/src/README.txt Sat Jun  3 19:41:13 2006
@@ -0,0 +1,32 @@
+Lucene README file
+
+$Id: README.txt 164119 2005-04-21 20:47:18Z dnaber $
+
+INTRODUCTION
+
+Lucene is a Java full-text search engine.  Lucene is not a complete
+application, but rather a code library and API that can easily be used
+to add search capabilities to applications.
+
+The Lucene web site is at:
+  http://lucene.apache.org/
+
+Please join the Lucene-User mailing list by sending a message to:
+  java-user-subscribe@lucene.apache.org
+
+FILES
+
+lucene-XX.jar
+  The compiled lucene library.
+
+docs/index.html
+  The contents of the Lucene website.
+
+docs/api/index.html
+  The Javadoc Lucene API documentation.
+
+src/java
+  The Lucene source code.
+
+src/demo
+  Some example code.

Modified: incubator/lucene.net/trunk/C#/src/Test/Analysis/TestAnalyzers.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Analysis/TestAnalyzers.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Analysis/TestAnalyzers.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Analysis/TestAnalyzers.cs Sat Jun  3 19:41:13 2006
@@ -13,15 +13,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
 using NUnit.Framework;
-using Lucene.Net;
-using Lucene.Net.Analysis;
+
 namespace Lucene.Net.Analysis
 {
+	
 	[TestFixture]
-	public class TestAnalyzers
+    public class TestAnalyzers
 	{
+		
 		public virtual void  AssertAnalyzesTo(Analyzer a, System.String input, System.String[] output)
 		{
 			TokenStream ts = a.TokenStream("dummy", new System.IO.StringReader(input));

Added: incubator/lucene.net/trunk/C#/src/Test/Analysis/TestISOLatin1AccentFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Analysis/TestISOLatin1AccentFilter.cs?rev=411501&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Analysis/TestISOLatin1AccentFilter.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Analysis/TestISOLatin1AccentFilter.cs Sat Jun  3 19:41:13 2006
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ * 
+ * Licensed 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 NUnit.Framework;
+
+namespace Lucene.Net.Analysis
+{
+	[TestFixture]
+	public class TestISOLatin1AccentFilter
+	{
+        [Test]
+		public virtual void  TestU()
+		{
+			TokenStream stream = new WhitespaceTokenizer(new System.IO.StringReader("Des mot clés À LA CHAÎNE À Ã? Â Ã Ä Å Æ Ç È É Ê Ë Ì Ã? Î Ã? Ã? Ñ Ò Ó Ô Õ Ö Ø Œ Þ Ù Ú Û Ü Ã? Ÿ à á â ã ä Ã¥ æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ø œ ß þ ù ú û ü ý ÿ"));
+			ISOLatin1AccentFilter filter = new ISOLatin1AccentFilter(stream);
+			Assert.AreEqual("Des", filter.Next().TermText());
+			Assert.AreEqual("mot", filter.Next().TermText());
+			Assert.AreEqual("cles", filter.Next().TermText());
+			Assert.AreEqual("A", filter.Next().TermText());
+			Assert.AreEqual("LA", filter.Next().TermText());
+			Assert.AreEqual("CHAINE", filter.Next().TermText());
+			Assert.AreEqual("A", filter.Next().TermText());
+			Assert.AreEqual("A", filter.Next().TermText());
+			Assert.AreEqual("A", filter.Next().TermText());
+			Assert.AreEqual("A", filter.Next().TermText());
+			Assert.AreEqual("A", filter.Next().TermText());
+			Assert.AreEqual("A", filter.Next().TermText());
+			Assert.AreEqual("AE", filter.Next().TermText());
+			Assert.AreEqual("C", filter.Next().TermText());
+			Assert.AreEqual("E", filter.Next().TermText());
+			Assert.AreEqual("E", filter.Next().TermText());
+			Assert.AreEqual("E", filter.Next().TermText());
+			Assert.AreEqual("E", filter.Next().TermText());
+			Assert.AreEqual("I", filter.Next().TermText());
+			Assert.AreEqual("I", filter.Next().TermText());
+			Assert.AreEqual("I", filter.Next().TermText());
+			Assert.AreEqual("I", filter.Next().TermText());
+			Assert.AreEqual("D", filter.Next().TermText());
+			Assert.AreEqual("N", filter.Next().TermText());
+			Assert.AreEqual("O", filter.Next().TermText());
+			Assert.AreEqual("O", filter.Next().TermText());
+			Assert.AreEqual("O", filter.Next().TermText());
+			Assert.AreEqual("O", filter.Next().TermText());
+			Assert.AreEqual("O", filter.Next().TermText());
+			Assert.AreEqual("O", filter.Next().TermText());
+			Assert.AreEqual("OE", filter.Next().TermText());
+			Assert.AreEqual("TH", filter.Next().TermText());
+			Assert.AreEqual("U", filter.Next().TermText());
+			Assert.AreEqual("U", filter.Next().TermText());
+			Assert.AreEqual("U", filter.Next().TermText());
+			Assert.AreEqual("U", filter.Next().TermText());
+			Assert.AreEqual("Y", filter.Next().TermText());
+			Assert.AreEqual("Y", filter.Next().TermText());
+			Assert.AreEqual("a", filter.Next().TermText());
+			Assert.AreEqual("a", filter.Next().TermText());
+			Assert.AreEqual("a", filter.Next().TermText());
+			Assert.AreEqual("a", filter.Next().TermText());
+			Assert.AreEqual("a", filter.Next().TermText());
+			Assert.AreEqual("a", filter.Next().TermText());
+			Assert.AreEqual("ae", filter.Next().TermText());
+			Assert.AreEqual("c", filter.Next().TermText());
+			Assert.AreEqual("e", filter.Next().TermText());
+			Assert.AreEqual("e", filter.Next().TermText());
+			Assert.AreEqual("e", filter.Next().TermText());
+			Assert.AreEqual("e", filter.Next().TermText());
+			Assert.AreEqual("i", filter.Next().TermText());
+			Assert.AreEqual("i", filter.Next().TermText());
+			Assert.AreEqual("i", filter.Next().TermText());
+			Assert.AreEqual("i", filter.Next().TermText());
+			Assert.AreEqual("d", filter.Next().TermText());
+			Assert.AreEqual("n", filter.Next().TermText());
+			Assert.AreEqual("o", filter.Next().TermText());
+			Assert.AreEqual("o", filter.Next().TermText());
+			Assert.AreEqual("o", filter.Next().TermText());
+			Assert.AreEqual("o", filter.Next().TermText());
+			Assert.AreEqual("o", filter.Next().TermText());
+			Assert.AreEqual("o", filter.Next().TermText());
+			Assert.AreEqual("oe", filter.Next().TermText());
+			Assert.AreEqual("ss", filter.Next().TermText());
+			Assert.AreEqual("th", filter.Next().TermText());
+			Assert.AreEqual("u", filter.Next().TermText());
+			Assert.AreEqual("u", filter.Next().TermText());
+			Assert.AreEqual("u", filter.Next().TermText());
+			Assert.AreEqual("u", filter.Next().TermText());
+			Assert.AreEqual("y", filter.Next().TermText());
+			Assert.AreEqual("y", filter.Next().TermText());
+			Assert.IsNull(filter.Next());
+		}
+	}
+}
\ No newline at end of file

Added: incubator/lucene.net/trunk/C#/src/Test/Analysis/TestKeywordAnalyzer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Analysis/TestKeywordAnalyzer.cs?rev=411501&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Analysis/TestKeywordAnalyzer.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Analysis/TestKeywordAnalyzer.cs Sat Jun  3 19:41:13 2006
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ * 
+ * Licensed 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 NUnit.Framework;
+using Document = Lucene.Net.Documents.Document;
+using Field = Lucene.Net.Documents.Field;
+using IndexWriter = Lucene.Net.Index.IndexWriter;
+using QueryParser = Lucene.Net.QueryParsers.QueryParser;
+using Hits = Lucene.Net.Search.Hits;
+using IndexSearcher = Lucene.Net.Search.IndexSearcher;
+using Query = Lucene.Net.Search.Query;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+
+namespace Lucene.Net.Analysis
+{
+	[TestFixture]
+	public class TestKeywordAnalyzer
+	{
+		
+		private RAMDirectory directory;
+		private IndexSearcher searcher;
+		
+        [TestFixtureSetUp]
+		public virtual void  SetUp()
+		{
+			directory = new RAMDirectory();
+			IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), true);
+			
+			Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
+			doc.Add(new Field("partnum", "Q36", Field.Store.YES, Field.Index.UN_TOKENIZED));
+			doc.Add(new Field("description", "Illidium Space Modulator", Field.Store.YES, Field.Index.TOKENIZED));
+			writer.AddDocument(doc);
+			
+			writer.Close();
+			
+			searcher = new IndexSearcher(directory);
+		}
+		
+        [Test]
+		public virtual void  TestPerFieldAnalyzer()
+		{
+			PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new SimpleAnalyzer());
+			analyzer.AddAnalyzer("partnum", new KeywordAnalyzer());
+			
+			Lucene.Net.QueryParsers.QueryParser queryParser = new Lucene.Net.QueryParsers.QueryParser("description", analyzer);
+			Query query = queryParser.Parse("partnum:Q36 AND SPACE");
+			
+			Hits hits = searcher.Search(query);
+			Assert.AreEqual("+partnum:Q36 +space", query.ToString("description"), "Q36 kept as-is");
+			Assert.AreEqual(1, hits.Length(), "doc found!");
+		}
+	}
+}
\ No newline at end of file

Added: incubator/lucene.net/trunk/C#/src/Test/Analysis/TestLengthFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Analysis/TestLengthFilter.cs?rev=411501&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Analysis/TestLengthFilter.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Analysis/TestLengthFilter.cs Sat Jun  3 19:41:13 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ * 
+ * Licensed 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 NUnit.Framework;
+
+namespace Lucene.Net.Analysis
+{
+	[TestFixture]
+	public class TestLengthFilter
+	{
+		[Test]
+		public virtual void  TestFilter()
+		{
+			TokenStream stream = new WhitespaceTokenizer(new System.IO.StringReader("short toolong evenmuchlongertext a ab toolong foo"));
+			LengthFilter filter = new LengthFilter(stream, 2, 6);
+			Assert.AreEqual("short", filter.Next().TermText());
+			Assert.AreEqual("ab", filter.Next().TermText());
+			Assert.AreEqual("foo", filter.Next().TermText());
+			Assert.IsNull(filter.Next());
+		}
+	}
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Test/Analysis/TestPerFieldAnalzyerWrapper.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Analysis/TestPerFieldAnalzyerWrapper.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Analysis/TestPerFieldAnalzyerWrapper.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Analysis/TestPerFieldAnalzyerWrapper.cs Sat Jun  3 19:41:13 2006
@@ -13,11 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
 using NUnit.Framework;
+
 namespace Lucene.Net.Analysis
 {
-    [TestFixture]
+    [TestFixture]	
 	public class TestPerFieldAnalzyerWrapper
 	{
         [Test]
@@ -27,7 +29,7 @@
 			PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new WhitespaceAnalyzer());
 			analyzer.AddAnalyzer("special", new SimpleAnalyzer());
 			
-			TokenStream tokenStream = analyzer.TokenStream("Field", new System.IO.StringReader(text));
+			TokenStream tokenStream = analyzer.TokenStream("field", new System.IO.StringReader(text));
 			Token token = tokenStream.Next();
 			Assert.AreEqual("Qwerty", token.TermText(), "WhitespaceAnalyzer does not lowercase");
 			

Added: incubator/lucene.net/trunk/C#/src/Test/Analysis/TestStandardAnalyzer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Analysis/TestStandardAnalyzer.cs?rev=411501&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Analysis/TestStandardAnalyzer.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Analysis/TestStandardAnalyzer.cs Sat Jun  3 19:41:13 2006
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ * 
+ * Licensed 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 NUnit.Framework;
+using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
+
+namespace Lucene.Net.Analysis
+{
+	[TestFixture]
+	public class TestStandardAnalyzer
+	{
+		
+		public virtual void  AssertAnalyzesTo(Analyzer a, System.String input, System.String[] expected)
+		{
+			TokenStream ts = a.TokenStream("dummy", new System.IO.StringReader(input));
+			for (int i = 0; i < expected.Length; i++)
+			{
+				Token t = ts.Next();
+				Assert.IsNotNull(t);
+				Assert.AreEqual(expected[i], t.TermText());
+			}
+			Assert.IsNull(ts.Next());
+			ts.Close();
+		}
+		
+		[Test]
+		public virtual void  TestStandard()
+		{
+			Analyzer a = new StandardAnalyzer();
+			
+			// alphanumeric tokens
+			AssertAnalyzesTo(a, "B2B", new System.String[]{"b2b"});
+			AssertAnalyzesTo(a, "2B", new System.String[]{"2b"});
+			
+			// underscores are delimiters, but not in email addresses (below)
+			AssertAnalyzesTo(a, "word_having_underscore", new System.String[]{"word", "having", "underscore"});
+			AssertAnalyzesTo(a, "word_with_underscore_and_stopwords", new System.String[]{"word", "underscore", "stopwords"});
+			
+			// other delimiters: "-", "/", ","
+			AssertAnalyzesTo(a, "some-dashed-phrase", new System.String[]{"some", "dashed", "phrase"});
+			AssertAnalyzesTo(a, "dogs,chase,cats", new System.String[]{"dogs", "chase", "cats"});
+			AssertAnalyzesTo(a, "ac/dc", new System.String[]{"ac", "dc"});
+			
+			// internal apostrophes: O'Reilly, you're, O'Reilly's
+			// possessives are actually removed by StardardFilter, not the tokenizer
+			AssertAnalyzesTo(a, "O'Reilly", new System.String[]{"o'reilly"});
+			AssertAnalyzesTo(a, "you're", new System.String[]{"you're"});
+			AssertAnalyzesTo(a, "O'Reilly's", new System.String[]{"o'reilly"});
+			
+			// company names
+			AssertAnalyzesTo(a, "AT&T", new System.String[]{"at&t"});
+			AssertAnalyzesTo(a, "Excite@Home", new System.String[]{"excite@home"});
+			
+			// domain names
+			AssertAnalyzesTo(a, "www.nutch.org", new System.String[]{"www.nutch.org"});
+			
+			// email addresses, possibly with underscores, periods, etc
+			AssertAnalyzesTo(a, "test@example.com", new System.String[]{"test@example.com"});
+			AssertAnalyzesTo(a, "first.lastname@example.com", new System.String[]{"first.lastname@example.com"});
+			AssertAnalyzesTo(a, "first_lastname@example.com", new System.String[]{"first_lastname@example.com"});
+			
+			// floating point, serial, model numbers, ip addresses, etc.
+			// every other segment must have at least one digit
+			AssertAnalyzesTo(a, "21.35", new System.String[]{"21.35"});
+			AssertAnalyzesTo(a, "R2D2 C3PO", new System.String[]{"r2d2", "c3po"});
+			AssertAnalyzesTo(a, "216.239.63.104", new System.String[]{"216.239.63.104"});
+			AssertAnalyzesTo(a, "1-2-3", new System.String[]{"1-2-3"});
+			AssertAnalyzesTo(a, "a1-b2-c3", new System.String[]{"a1-b2-c3"});
+			AssertAnalyzesTo(a, "a1-b-c3", new System.String[]{"a1-b-c3"});
+			
+			// numbers
+			AssertAnalyzesTo(a, "David has 5000 bones", new System.String[]{"david", "has", "5000", "bones"});
+			
+			// various
+			AssertAnalyzesTo(a, "C embedded developers wanted", new System.String[]{"c", "embedded", "developers", "wanted"});
+			AssertAnalyzesTo(a, "foo bar FOO BAR", new System.String[]{"foo", "bar", "foo", "bar"});
+			AssertAnalyzesTo(a, "foo      bar .  FOO <> BAR", new System.String[]{"foo", "bar", "foo", "bar"});
+			AssertAnalyzesTo(a, "\"QUOTED\" word", new System.String[]{"quoted", "word"});
+			
+			// acronyms have their dots stripped
+			AssertAnalyzesTo(a, "U.S.A.", new System.String[]{"usa"});
+			
+			// It would be nice to change the grammar in StandardTokenizer.jj to make "C#" and "C++" end up as tokens.
+			AssertAnalyzesTo(a, "C++", new System.String[]{"c"});
+			AssertAnalyzesTo(a, "C#", new System.String[]{"c"});
+			
+			// Korean words
+			AssertAnalyzesTo(a, "안녕하세요 한글입니다", new System.String[]{"안녕하세요", "한글입니다"});
+		}
+	}
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Test/Analysis/TestStopAnalyzer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Analysis/TestStopAnalyzer.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Analysis/TestStopAnalyzer.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Analysis/TestStopAnalyzer.cs Sat Jun  3 19:41:13 2006
@@ -13,19 +13,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
 using NUnit.Framework;
+
 namespace Lucene.Net.Analysis
 {
 	[TestFixture]
 	public class TestStopAnalyzer
 	{
-		private StopAnalyzer stop = new StopAnalyzer();
 		
+		private StopAnalyzer stop = new StopAnalyzer();
 		private System.Collections.Hashtable inValidTokens = new System.Collections.Hashtable();
 		
         [TestFixtureSetUp]
-		protected virtual void  SetUp()
+		public virtual void  SetUp()
 		{
 			for (int i = 0; i < StopAnalyzer.ENGLISH_STOP_WORDS.Length; i++)
 			{
@@ -41,16 +43,9 @@
 			TokenStream stream = stop.TokenStream("test", reader);
 			Assert.IsTrue(stream != null);
 			Token token = null;
-			try
-			{
-				while ((token = stream.Next()) != null)
-				{
-					Assert.IsTrue(inValidTokens.Contains(token.TermText()) == false);
-				}
-			}
-			catch (System.IO.IOException e)
+			while ((token = stream.Next()) != null)
 			{
-				Assert.IsTrue(false);
+				Assert.IsFalse(inValidTokens.Contains(token.TermText()));
 			}
 		}
 		
@@ -61,30 +56,15 @@
 			stopWordsSet.Add("good", "good");
 			stopWordsSet.Add("test", "test");
 			stopWordsSet.Add("analyzer", "analyzer");
-
-            // {{Aroush  how can we copy 'stopWordsSet' to 'System.String[]'?
-            System.String[] arrStopWordsSet = new System.String[3];
-            arrStopWordsSet[0] = "good";
-            arrStopWordsSet[1] = "test";
-            arrStopWordsSet[2] = "analyzer";
-            // Aroush}}
-
-			StopAnalyzer newStop = new StopAnalyzer(arrStopWordsSet);
+			StopAnalyzer newStop = new StopAnalyzer(stopWordsSet);
 			System.IO.StringReader reader = new System.IO.StringReader("This is a good test of the english stop analyzer");
 			TokenStream stream = newStop.TokenStream("test", reader);
-			Assert.IsTrue(stream != null);
+			Assert.IsNotNull(stream);
 			Token token = null;
-			try
-			{
-				while ((token = stream.Next()) != null)
-				{
-					System.String text = token.TermText();
-					Assert.IsTrue(stopWordsSet.Contains(text) == false);
-				}
-			}
-			catch (System.IO.IOException e)
+			while ((token = stream.Next()) != null)
 			{
-				Assert.IsTrue(false);
+				System.String text = token.TermText();
+				Assert.IsFalse(stopWordsSet.Contains(text));
 			}
 		}
 	}

Added: incubator/lucene.net/trunk/C#/src/Test/Analysis/TestStopFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Analysis/TestStopFilter.cs?rev=411501&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Analysis/TestStopFilter.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Analysis/TestStopFilter.cs Sat Jun  3 19:41:13 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ * 
+ * Licensed 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 NUnit.Framework;
+
+namespace Lucene.Net.Analysis
+{
+	
+	/// <author>  yonik
+	/// </author>
+	[TestFixture]
+    public class TestStopFilter
+	{
+		
+		// other StopFilter functionality is already tested by TestStopAnalyzer
+		[Test]
+		public virtual void  TestExactCase()
+		{
+			System.IO.StringReader reader = new System.IO.StringReader("Now is The Time");
+			System.String[] stopWords = new System.String[]{"is", "the", "Time"};
+			TokenStream stream = new StopFilter(new WhitespaceTokenizer(reader), stopWords);
+			Assert.AreEqual("Now", stream.Next().TermText());
+			Assert.AreEqual("The", stream.Next().TermText());
+			Assert.AreEqual(null, stream.Next());
+		}
+		
+		public virtual void  TestIgnoreCase()
+		{
+			System.IO.StringReader reader = new System.IO.StringReader("Now is The Time");
+			System.String[] stopWords = new System.String[]{"is", "the", "Time"};
+			TokenStream stream = new StopFilter(new WhitespaceTokenizer(reader), stopWords, true);
+			Assert.AreEqual("Now", stream.Next().TermText());
+			Assert.AreEqual(null, stream.Next());
+		}
+	}
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Test/AnalysisTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/AnalysisTest.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/AnalysisTest.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/AnalysisTest.cs Sat Jun  3 19:41:13 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004 The Apache Software Foundation
+ * Copyright 2005 The Apache Software Foundation
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,11 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
 using Analyzer = Lucene.Net.Analysis.Analyzer;
 using SimpleAnalyzer = Lucene.Net.Analysis.SimpleAnalyzer;
 using Token = Lucene.Net.Analysis.Token;
 using TokenStream = Lucene.Net.Analysis.TokenStream;
+
 namespace Lucene.Net
 {
 	

Modified: incubator/lucene.net/trunk/C#/src/Test/AssemblyInfo.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/AssemblyInfo.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/AssemblyInfo.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/AssemblyInfo.cs Sat Jun  3 19:41:13 2006
@@ -26,7 +26,7 @@
 // You can specify all the values or you can default the Revision and Build Numbers 
 // by using the '*' as shown below:
 
-[assembly: AssemblyVersion("1.4.3.003")]
+[assembly: AssemblyVersion("1.9.0.003")]
 
 //
 // In order to sign your assembly you must specify a key to use. Refer to the 

Added: incubator/lucene.net/trunk/C#/src/Test/Document/TestBinaryDocument.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Document/TestBinaryDocument.cs?rev=411501&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Document/TestBinaryDocument.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Document/TestBinaryDocument.cs Sat Jun  3 19:41:13 2006
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ * 
+ * Licensed 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 NUnit.Framework;
+using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
+using Document = Lucene.Net.Documents.Document;
+using Field = Lucene.Net.Documents.Field;
+using IndexReader = Lucene.Net.Index.IndexReader;
+using IndexWriter = Lucene.Net.Index.IndexWriter;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+
+namespace Lucene.Net.Document
+{
+	
+	/// <summary> Tests {@link Document} class.
+	/// 
+	/// </summary>
+	/// <author>  Bernhard Messer
+	/// </author>
+	/// <version>  $Id: TestBinaryDocument.java 150546 2004-09-30 12:40:28Z goller $
+	/// </version>
+	[TestFixture]
+    public class TestBinaryDocument
+	{
+		
+		internal System.String binaryValStored = "this text will be stored as a byte array in the index";
+		internal System.String binaryValCompressed = "this text will be also stored and compressed as a byte array in the index";
+		
+		[Test]
+        public virtual void  TestBinaryFieldInIndex()
+		{
+			Field binaryFldStored = new Field("binaryStored", System.Text.UTF8Encoding.UTF8.GetBytes(binaryValStored), Field.Store.YES);
+			Field binaryFldCompressed = new Field("binaryCompressed", System.Text.UTF8Encoding.UTF8.GetBytes(binaryValCompressed), Field.Store.COMPRESS);
+			Field stringFldStored = new Field("stringStored", binaryValStored, Field.Store.YES, Field.Index.NO, Field.TermVector.NO);
+			Field stringFldCompressed = new Field("stringCompressed", binaryValCompressed, Field.Store.COMPRESS, Field.Index.NO, Field.TermVector.NO);
+			
+			try
+			{
+				// binary fields with store off are not allowed
+				new Field("fail", System.Text.UTF8Encoding.UTF8.GetBytes(binaryValCompressed), Field.Store.NO);
+				Assert.Fail();
+			}
+			catch (System.ArgumentException iae)
+			{
+				;
+			}
+			
+			Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
+			
+			doc.Add(binaryFldStored);
+			doc.Add(binaryFldCompressed);
+			
+			doc.Add(stringFldStored);
+			doc.Add(stringFldCompressed);
+			
+			/** test for field count */
+            System.Collections.IEnumerator iter = doc.Fields();
+            int count = 0;
+            while (iter.MoveNext()) count++;
+            Assert.AreEqual(4, count);
+			
+			/** add the doc to a ram index */
+			RAMDirectory dir = new RAMDirectory();
+			IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true);
+			writer.AddDocument(doc);
+			writer.Close();
+			
+			/** open a reader and fetch the document */
+			IndexReader reader = IndexReader.Open(dir);
+			Lucene.Net.Documents.Document docFromReader = reader.Document(0);
+			Assert.IsTrue(docFromReader != null);
+			
+			/** fetch the binary stored field and compare it's content with the original one */
+			System.String binaryFldStoredTest = docFromReader.GetBinaryValue("binaryStored").ToString();
+			Assert.IsTrue(binaryFldStoredTest.Equals(binaryValStored));
+			
+			/** fetch the binary compressed field and compare it's content with the original one */
+			System.String binaryFldCompressedTest = docFromReader.GetBinaryValue("binaryCompressed").ToString();
+			Assert.IsTrue(binaryFldCompressedTest.Equals(binaryValCompressed));
+			
+			/** fetch the string field and compare it's content with the original one */
+			System.String stringFldStoredTest = new System.Text.StringBuilder(docFromReader.Get("stringStored")).ToString();
+			Assert.IsTrue(stringFldStoredTest.Equals(binaryValStored));
+			
+			/** fetch the compressed string field and compare it's content with the original one */
+			System.String stringFldCompressedTest = new System.Text.StringBuilder(docFromReader.Get("stringCompressed")).ToString();
+			Assert.IsTrue(stringFldCompressedTest.Equals(binaryValCompressed));
+			
+			/** delete the document from index */
+			reader.Delete(0);
+			Assert.AreEqual(0, reader.NumDocs());
+			
+			reader.Close();
+		}
+	}
+}
\ No newline at end of file

Added: incubator/lucene.net/trunk/C#/src/Test/Document/TestDateTools.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Document/TestDateTools.cs?rev=411501&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Document/TestDateTools.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Document/TestDateTools.cs Sat Jun  3 19:41:13 2006
@@ -0,0 +1,196 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ * 
+ * Licensed 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 DateTools = Lucene.Net.Documents.DateTools;
+using NUnit.Framework;
+
+namespace Lucene.Net.Document
+{
+	[TestFixture]
+	public class TestDateTools
+	{
+		[Test]
+		public virtual void  TestStringToDate()
+		{
+			
+			System.DateTime d;
+			d = DateTools.StringToDate("2004");
+			Assert.AreEqual("2004-01-01 00:00:00:000", IsoFormat(d));
+			d = DateTools.StringToDate("20040705");
+			Assert.AreEqual("2004-07-05 00:00:00:000", IsoFormat(d));
+			d = DateTools.StringToDate("200407050910");
+			Assert.AreEqual("2004-07-05 09:10:00:000", IsoFormat(d));
+			d = DateTools.StringToDate("20040705091055990");
+			Assert.AreEqual("2004-07-05 09:10:55:990", IsoFormat(d));
+			
+			try
+			{
+				d = DateTools.StringToDate("97"); // no date
+				Assert.Fail();
+			}
+			catch (System.FormatException e)
+			{
+				/* expected exception */
+			}
+			try
+			{
+				d = DateTools.StringToDate("200401011235009999"); // no date
+				Assert.Fail();
+			}
+			catch (System.FormatException e)
+			{
+				/* expected exception */
+			}
+			try
+			{
+				d = DateTools.StringToDate("aaaa"); // no date
+				Assert.Fail();
+			}
+			catch (System.FormatException e)
+			{
+				/* expected exception */
+			}
+		}
+		
+        [Test]
+		public virtual void  TestStringtoTime()
+		{
+			long time = DateTools.StringToTime("197001010000");
+
+            System.DateTime cal = new System.DateTime(1970, 1, 1, 0, 0, 0, 0, new System.Globalization.GregorianCalendar());  // hour, minute, second
+            Assert.AreEqual(cal.Ticks, time);
+
+            cal = new System.DateTime(1980, 2, 2, 11, 5, 0, 0, new System.Globalization.GregorianCalendar()); // hour, minute, second
+			time = DateTools.StringToTime("198002021105");
+			Assert.AreEqual(cal.Ticks, time);
+		}
+		
+        [Test]
+		public virtual void  TestDateAndTimetoString()
+		{
+            System.DateTime cal = new System.DateTime(2004, 2, 3, 22, 8, 56, 333, new System.Globalization.GregorianCalendar());
+			
+			System.String dateString;
+			System.DateTime tempAux = new System.DateTime(cal.Ticks);
+			dateString = DateTools.DateToString(tempAux, DateTools.Resolution.YEAR);
+			Assert.AreEqual("2004", dateString);
+			System.DateTime tempAux2 = DateTools.StringToDate(dateString);
+			Assert.AreEqual("2004-01-01 00:00:00:000", IsoFormat(tempAux2));
+			
+			System.DateTime tempAux3 = new System.DateTime(cal.Ticks);
+			dateString = DateTools.DateToString(tempAux3, DateTools.Resolution.MONTH);
+			Assert.AreEqual("200402", dateString);
+			System.DateTime tempAux4 = DateTools.StringToDate(dateString);
+			Assert.AreEqual("2004-02-01 00:00:00:000", IsoFormat(tempAux4));
+			
+			System.DateTime tempAux5 = new System.DateTime(cal.Ticks);
+			dateString = DateTools.DateToString(tempAux5, DateTools.Resolution.DAY);
+			Assert.AreEqual("20040203", dateString);
+			System.DateTime tempAux6 = DateTools.StringToDate(dateString);
+			Assert.AreEqual("2004-02-03 00:00:00:000", IsoFormat(tempAux6));
+			
+			System.DateTime tempAux7 = new System.DateTime(cal.Ticks);
+			dateString = DateTools.DateToString(tempAux7, DateTools.Resolution.HOUR);
+			Assert.AreEqual("2004020322", dateString);
+			System.DateTime tempAux8 = DateTools.StringToDate(dateString);
+			Assert.AreEqual("2004-02-03 22:00:00:000", IsoFormat(tempAux8));
+			
+			System.DateTime tempAux9 = new System.DateTime(cal.Ticks);
+			dateString = DateTools.DateToString(tempAux9, DateTools.Resolution.MINUTE);
+			Assert.AreEqual("200402032208", dateString);
+			System.DateTime tempAux10 = DateTools.StringToDate(dateString);
+			Assert.AreEqual("2004-02-03 22:08:00:000", IsoFormat(tempAux10));
+			
+			System.DateTime tempAux11 = new System.DateTime(cal.Ticks);
+			dateString = DateTools.DateToString(tempAux11, DateTools.Resolution.SECOND);
+			Assert.AreEqual("20040203220856", dateString);
+			System.DateTime tempAux12 = DateTools.StringToDate(dateString);
+			Assert.AreEqual("2004-02-03 22:08:56:000", IsoFormat(tempAux12));
+			
+			System.DateTime tempAux13 = new System.DateTime(cal.Ticks);
+			dateString = DateTools.DateToString(tempAux13, DateTools.Resolution.MILLISECOND);
+			Assert.AreEqual("20040203220856333", dateString);
+			System.DateTime tempAux14 = DateTools.StringToDate(dateString);
+			Assert.AreEqual("2004-02-03 22:08:56:333", IsoFormat(tempAux14));
+			
+			// date before 1970:
+            cal = new System.DateTime(1961, 3, 5, 23, 9, 51, 444, new System.Globalization.GregorianCalendar());
+			System.DateTime tempAux15 = new System.DateTime(cal.Ticks);
+			dateString = DateTools.DateToString(tempAux15, DateTools.Resolution.MILLISECOND);
+			Assert.AreEqual("19610305230951444", dateString);
+			System.DateTime tempAux16 = DateTools.StringToDate(dateString);
+			Assert.AreEqual("1961-03-05 23:09:51:444", IsoFormat(tempAux16));
+			
+			System.DateTime tempAux17 = new System.DateTime(cal.Ticks);
+			dateString = DateTools.DateToString(tempAux17, DateTools.Resolution.HOUR);
+			Assert.AreEqual("1961030523", dateString);
+			System.DateTime tempAux18 = DateTools.StringToDate(dateString);
+			Assert.AreEqual("1961-03-05 23:00:00:000", IsoFormat(tempAux18));
+			
+			// timeToString:
+            cal = new System.DateTime(1970, 1, 1, 0, 0, 0, 0, new System.Globalization.GregorianCalendar());
+			dateString = DateTools.TimeToString(cal.Ticks, DateTools.Resolution.MILLISECOND);
+			Assert.AreEqual("19700101000000000", dateString);
+			
+            cal = new System.DateTime(1970, 1, 1, 1, 2, 3, 0, new System.Globalization.GregorianCalendar());
+			dateString = DateTools.TimeToString(cal.Ticks, DateTools.Resolution.MILLISECOND);
+			Assert.AreEqual("19700101010203000", dateString);
+		}
+		
+        [Test]
+		public virtual void  TestRound()
+		{
+            System.DateTime date = new System.DateTime(2004, 2, 3, 22, 8, 56, 333, new System.Globalization.GregorianCalendar());
+			Assert.AreEqual("2004-02-03 22:08:56:333", IsoFormat(date));
+			
+			System.DateTime dateYear = DateTools.Round(date, DateTools.Resolution.YEAR);
+			Assert.AreEqual("2004-01-01 00:00:00:000", IsoFormat(dateYear));
+			
+			System.DateTime dateMonth = DateTools.Round(date, DateTools.Resolution.MONTH);
+			Assert.AreEqual("2004-02-01 00:00:00:000", IsoFormat(dateMonth));
+			
+			System.DateTime dateDay = DateTools.Round(date, DateTools.Resolution.DAY);
+			Assert.AreEqual("2004-02-03 00:00:00:000", IsoFormat(dateDay));
+			
+			System.DateTime dateHour = DateTools.Round(date, DateTools.Resolution.HOUR);
+			Assert.AreEqual("2004-02-03 22:00:00:000", IsoFormat(dateHour));
+			
+			System.DateTime dateMinute = DateTools.Round(date, DateTools.Resolution.MINUTE);
+			Assert.AreEqual("2004-02-03 22:08:00:000", IsoFormat(dateMinute));
+			
+			System.DateTime dateSecond = DateTools.Round(date, DateTools.Resolution.SECOND);
+			Assert.AreEqual("2004-02-03 22:08:56:000", IsoFormat(dateSecond));
+			
+			System.DateTime dateMillisecond = DateTools.Round(date, DateTools.Resolution.MILLISECOND);
+			Assert.AreEqual("2004-02-03 22:08:56:333", IsoFormat(dateMillisecond));
+			
+			// long parameter:
+			long dateYearLong = DateTools.Round(date.Ticks, DateTools.Resolution.YEAR);
+			System.DateTime tempAux = new System.DateTime(dateYearLong);
+			Assert.AreEqual("2004-01-01 00:00:00:000", IsoFormat(tempAux));
+			
+			long dateMillisecondLong = DateTools.Round(date.Ticks, DateTools.Resolution.MILLISECOND);
+			System.DateTime tempAux2 = new System.DateTime(dateMillisecondLong);
+			Assert.AreEqual("2004-02-03 22:08:56:333", IsoFormat(tempAux2));
+		}
+		
+		private System.String IsoFormat(System.DateTime date)
+		{
+            return date.ToString("yyyy-MM-dd HH:mm:ss:fff");
+        }
+	}
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Test/Document/TestDocument.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Document/TestDocument.cs?rev=411501&r1=411500&r2=411501&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Document/TestDocument.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Document/TestDocument.cs Sat Jun  3 19:41:13 2006
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
 using NUnit.Framework;
 using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
@@ -26,20 +27,84 @@
 using Searcher = Lucene.Net.Search.Searcher;
 using TermQuery = Lucene.Net.Search.TermQuery;
 using RAMDirectory = Lucene.Net.Store.RAMDirectory;
-namespace Lucene.Net.Documents
+
+namespace Lucene.Net.Document
 {
+	
 	/// <summary> Tests {@link Document} class.
 	/// 
 	/// </summary>
 	/// <author>  Otis Gospodnetic
 	/// </author>
-	/// <version>  $Id: TestDocument.java,v 1.4 2004/04/20 17:26:16 goller Exp $
+	/// <version>  $Id: TestDocument.java 208846 2005-07-02 16:40:44Z dnaber $
 	/// </version>
 	[TestFixture]
-	public class TestDocument
+    public class TestDocument
 	{
 		
-		/// <summary> Tests {@link Document#remove()} method for a brand new Document
+		internal System.String binaryVal = "this text will be stored as a byte array in the index";
+		internal System.String binaryVal2 = "this text will be also stored as a byte array in the index";
+		
+        [Test]
+		public virtual void  TestBinaryField()
+		{
+			Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
+			Field stringFld = new Field("string", binaryVal, Field.Store.YES, Field.Index.NO);
+			Field binaryFld = new Field("binary", (new System.Text.ASCIIEncoding()).GetBytes(binaryVal), Field.Store.YES);
+			Field binaryFld2 = new Field("binary", (new System.Text.ASCIIEncoding()).GetBytes(binaryVal2), Field.Store.YES);
+
+			doc.Add(stringFld);
+			doc.Add(binaryFld);
+
+            System.Collections.IEnumerator iter = doc.Fields();
+            int count = 0;
+            while (iter.MoveNext()) count++;
+            Assert.AreEqual(2, count);
+			
+			Assert.IsTrue(binaryFld.IsBinary());
+			Assert.IsTrue(binaryFld.IsStored());
+			Assert.IsFalse(binaryFld.IsIndexed());
+			Assert.IsFalse(binaryFld.IsTokenized());
+			
+            System.String binaryTest = (new System.Text.ASCIIEncoding()).GetString(doc.GetBinaryValue("binary"));
+			Assert.IsTrue(binaryTest.Equals(binaryVal));
+			
+			System.String stringTest = doc.Get("string");
+			Assert.IsTrue(binaryTest.Equals(stringTest));
+			
+			doc.Add(binaryFld2);
+			
+            iter = doc.Fields();
+            count = 0;
+            while (iter.MoveNext()) count++;
+            Assert.AreEqual(3, count);
+			
+			byte[][] binaryTests = doc.GetBinaryValues("binary");
+			
+			Assert.AreEqual(2, binaryTests.Length);
+			
+			binaryTest = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(binaryTests[0]));
+			System.String binaryTest2 = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(binaryTests[1]));
+			
+			Assert.IsFalse(binaryTest.Equals(binaryTest2));
+			
+			Assert.IsTrue(binaryTest.Equals(binaryVal));
+			Assert.IsTrue(binaryTest2.Equals(binaryVal2));
+			
+			doc.RemoveField("string");
+            iter = doc.Fields();
+            count = 0;
+            while (iter.MoveNext()) count++;
+            Assert.AreEqual(2, count);
+			
+			doc.RemoveFields("binary");
+            iter = doc.Fields();
+            count = 0;
+            while (iter.MoveNext()) count++;
+            Assert.AreEqual(0, count);
+		}
+		
+		/// <summary> Tests {@link Document#RemoveField(String)} method for a brand new Document
 		/// that has not been indexed yet.
 		/// 
 		/// </summary>
@@ -47,41 +112,80 @@
 		[Test]
 		public virtual void  TestRemoveForNewDocument()
 		{
-			Document doc = MakeDocumentWithFields();
-			Assert.AreEqual(8, doc.fields.Count);
+            int count;
+            System.Collections.IEnumerator iter;
+
+			Lucene.Net.Documents.Document doc = MakeDocumentWithFields();
+            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
+            Assert.AreEqual(8, count);
 			doc.RemoveFields("keyword");
-			Assert.AreEqual(6, doc.fields.Count);
+            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
+            Assert.AreEqual(6, count);
 			doc.RemoveFields("doesnotexists"); // removing non-existing fields is siltenlty ignored
-			doc.RemoveFields("keyword"); // removing a Field more than once
-			Assert.AreEqual(6, doc.fields.Count);
+			doc.RemoveFields("keyword"); // removing a field more than once
+            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
+            Assert.AreEqual(6, count);
 			doc.RemoveField("text");
-			Assert.AreEqual(5, doc.fields.Count);
+            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
+            Assert.AreEqual(5, count);
 			doc.RemoveField("text");
-			Assert.AreEqual(4, doc.fields.Count);
+            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
+            Assert.AreEqual(4, count);
 			doc.RemoveField("text");
-			Assert.AreEqual(4, doc.fields.Count);
+            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
+            Assert.AreEqual(4, count);
 			doc.RemoveField("doesnotexists"); // removing non-existing fields is siltenlty ignored
-			Assert.AreEqual(4, doc.fields.Count);
+            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
+            Assert.AreEqual(4, count);
 			doc.RemoveFields("unindexed");
-			Assert.AreEqual(2, doc.fields.Count);
+            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
+			Assert.AreEqual(2, count);
 			doc.RemoveFields("unstored");
-			Assert.AreEqual(0, doc.fields.Count);
+            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
+            Assert.AreEqual(0, count);
 			doc.RemoveFields("doesnotexists"); // removing non-existing fields is siltenlty ignored
-			Assert.AreEqual(0, doc.fields.Count);
+            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
+            Assert.AreEqual(0, count);
+		}
+		
+        [Test]
+		public virtual void  TestConstructorExceptions()
+		{
+			new Field("name", "value", Field.Store.YES, Field.Index.NO); // okay
+			new Field("name", "value", Field.Store.NO, Field.Index.UN_TOKENIZED); // okay
+			try
+			{
+				new Field("name", "value", Field.Store.NO, Field.Index.NO);
+				Assert.Fail();
+			}
+			catch (System.ArgumentException e)
+			{
+				// expected exception
+			}
+			new Field("name", "value", Field.Store.YES, Field.Index.NO, Field.TermVector.NO); // okay
+			try
+			{
+				new Field("name", "value", Field.Store.YES, Field.Index.NO, Field.TermVector.YES);
+				Assert.Fail();
+			}
+			catch (System.ArgumentException e)
+			{
+				// expected exception
+			}
 		}
 		
-		/// <summary> Tests {@link Document#getValues()} method for a brand new Document
+		/// <summary> Tests {@link Document#GetValues(String)} method for a brand new Document
 		/// that has not been indexed yet.
 		/// 
 		/// </summary>
 		/// <throws>  Exception on error </throws>
 		[Test]
-		public virtual void  TestGetValuesForNewDocument()
+        public virtual void  TestGetValuesForNewDocument()
 		{
 			DoAssert(MakeDocumentWithFields(), false);
 		}
 		
-		/// <summary> Tests {@link Document#getValues()} method for a Document retrieved from
+		/// <summary> Tests {@link Document#GetValues(String)} method for a Document retrieved from
 		/// an index.
 		/// 
 		/// </summary>
@@ -103,36 +207,25 @@
 			Hits hits = searcher.Search(query);
 			Assert.AreEqual(1, hits.Length());
 			
-			try
-			{
-				DoAssert(hits.Doc(0), true);
-			}
-			catch (System.Exception e)
-			{
-                System.Console.Error.WriteLine(e.StackTrace);
-				System.Console.Error.Write("\n");
-			}
-			finally
-			{
-				searcher.Close();
-			}
+			DoAssert(hits.Doc(0), true);
+			searcher.Close();
 		}
 		
-		private Document MakeDocumentWithFields()
+		private Lucene.Net.Documents.Document MakeDocumentWithFields()
 		{
-			Document doc = new Document();
-			doc.Add(Field.Keyword("keyword", "test1"));
-			doc.Add(Field.Keyword("keyword", "test2"));
-			doc.Add(Field.Text("text", "test1"));
-			doc.Add(Field.Text("text", "test2"));
-			doc.Add(Field.UnIndexed("unindexed", "test1"));
-			doc.Add(Field.UnIndexed("unindexed", "test2"));
-			doc.Add(Field.UnStored("unstored", "test1"));
-			doc.Add(Field.UnStored("unstored", "test2"));
+			Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
+			doc.Add(new Field("keyword", "test1", Field.Store.YES, Field.Index.UN_TOKENIZED));
+			doc.Add(new Field("keyword", "test2", Field.Store.YES, Field.Index.UN_TOKENIZED));
+			doc.Add(new Field("text", "test1", Field.Store.YES, Field.Index.TOKENIZED));
+			doc.Add(new Field("text", "test2", Field.Store.YES, Field.Index.TOKENIZED));
+			doc.Add(new Field("unindexed", "test1", Field.Store.YES, Field.Index.NO));
+			doc.Add(new Field("unindexed", "test2", Field.Store.YES, Field.Index.NO));
+			doc.Add(new Field("unstored", "test1", Field.Store.NO, Field.Index.TOKENIZED));
+			doc.Add(new Field("unstored", "test2", Field.Store.NO, Field.Index.TOKENIZED));
 			return doc;
 		}
 		
-		private void  DoAssert(Document doc, bool fromIndex)
+		private void  DoAssert(Lucene.Net.Documents.Document doc, bool fromIndex)
 		{
 			System.String[] keywordFieldValues = doc.GetValues("keyword");
 			System.String[] textFieldValues = doc.GetValues("text");

Added: incubator/lucene.net/trunk/C#/src/Test/Document/TestNumberTools.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Document/TestNumberTools.cs?rev=411501&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Document/TestNumberTools.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Document/TestNumberTools.cs Sat Jun  3 19:41:13 2006
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ * 
+ * Licensed 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 NumberTools = Lucene.Net.Documents.NumberTools;
+using NUnit.Framework;
+
+namespace Lucene.Net.Document
+{
+	[TestFixture]
+	public class TestNumberTools
+	{
+        [Test]
+		public virtual void  TestNearZero()
+		{
+			for (int i = - 100; i <= 100; i++)
+			{
+				for (int j = - 100; j <= 100; j++)
+				{
+					SubtestTwoLongs(i, j);
+				}
+			}
+		}
+		
+        [Test]
+		public virtual void  TestMax()
+		{
+			// make sure the constants convert to their equivelents
+			Assert.AreEqual(System.Int64.MaxValue, NumberTools.StringToLong(NumberTools.MAX_STRING_VALUE));
+			Assert.AreEqual(NumberTools.MAX_STRING_VALUE, NumberTools.LongToString(System.Int64.MaxValue));
+			
+			// test near MAX, too
+			for (long l = System.Int64.MaxValue; l > System.Int64.MaxValue - 10000; l--)
+			{
+				SubtestTwoLongs(l, l - 1);
+			}
+		}
+		
+        [Test]
+		public virtual void  TestMin()
+		{
+			// make sure the constants convert to their equivelents
+			Assert.AreEqual(System.Int64.MinValue, NumberTools.StringToLong(NumberTools.MIN_STRING_VALUE));
+			Assert.AreEqual(NumberTools.MIN_STRING_VALUE, NumberTools.LongToString(System.Int64.MinValue));
+			
+			// test near MIN, too
+			for (long l = System.Int64.MinValue; l < System.Int64.MinValue + 10000; l++)
+			{
+				SubtestTwoLongs(l, l + 1);
+			}
+		}
+		
+		private static void  SubtestTwoLongs(long i, long j)
+		{
+			// convert to strings
+			System.String a = NumberTools.LongToString(i);
+			System.String b = NumberTools.LongToString(j);
+			
+			// are they the right length?
+			Assert.AreEqual(NumberTools.STR_SIZE, a.Length);
+			Assert.AreEqual(NumberTools.STR_SIZE, b.Length);
+			
+			// are they the right order?
+			if (i < j)
+			{
+				Assert.IsTrue(String.CompareOrdinal(a, b) < 0);
+			}
+			else if (i > j)
+			{
+				Assert.IsTrue(String.CompareOrdinal(a, b) > 0);
+			}
+			else
+			{
+				Assert.AreEqual(a, b);
+			}
+			
+			// can we convert them back to longs?
+			long i2 = NumberTools.StringToLong(a);
+			long j2 = NumberTools.StringToLong(b);
+			
+			Assert.AreEqual(i, i2);
+			Assert.AreEqual(j, j2);
+		}
+	}
+}
\ No newline at end of file



Mime
View raw message