lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r885832 - in /incubator/lucene.net/trunk/C#/src/Lucene.Net: Document/CompressionTools.cs SharpZipLibAdapter.cs SupportClass.cs
Date Tue, 01 Dec 2009 16:55:17 GMT
Author: digy
Date: Tue Dec  1 16:55:17 2009
New Revision: 885832

URL: http://svn.apache.org/viewvc?rev=885832&view=rev
Log:
LUCENENET-313 SharpZipLib dependency

Removed:
    incubator/lucene.net/trunk/C#/src/Lucene.Net/SharpZipLibAdapter.cs
Modified:
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Document/CompressionTools.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/SupportClass.cs

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Document/CompressionTools.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Document/CompressionTools.cs?rev=885832&r1=885831&r2=885832&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Document/CompressionTools.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Document/CompressionTools.cs Tue Dec  1 16:55:17
2009
@@ -15,10 +15,18 @@
  * limitations under the License.
  */
 
+
+/// To enable compression support in Lucene.Net ,
+/// you will need to define 'SHARP_ZIP_LIB' and reference the SharpLibZip 
+/// library.  The SharpLibZip library can be downloaded from: 
+/// http://www.icsharpcode.net/OpenSource/SharpZipLib/
+
 using System;
 
+#if SHARP_ZIP_LIB
 using ICSharpCode.SharpZipLib;
 using ICSharpCode.SharpZipLib.Zip.Compression;
+#endif
 
 using UnicodeUtil = Lucene.Net.Util.UnicodeUtil;
 
@@ -47,7 +55,7 @@
 		/// </summary>
 		public static byte[] Compress(byte[] value_Renamed, int offset, int length, int compressionLevel)
 		{
-			
+			#if SHARP_ZIP_LIB
 			/* Create an expandable byte array to hold the compressed data.
 			* You cannot use an array that's the same size as the orginal because
 			* there is no guarantee that the compressed data will be smaller than
@@ -75,24 +83,40 @@
 			}
 			
 			return bos.ToArray();
+            #else
+            throw new System.SystemException("Compression support not configured"); 
+            #endif
 		}
 		
 		/// <summary>Compresses the specified byte range, with default BEST_COMPRESSION level
</summary>
 		public static byte[] Compress(byte[] value_Renamed, int offset, int length)
-		{
+        {
+            #if SHARP_ZIP_LIB
 			return Compress(value_Renamed, offset, length, Deflater.BEST_COMPRESSION);
+            #else
+            throw new System.SystemException("Compression support not configured"); 
+            #endif
 		}
 		
 		/// <summary>Compresses all bytes in the array, with default BEST_COMPRESSION level
</summary>
 		public static byte[] Compress(byte[] value_Renamed)
 		{
+            #if SHARP_ZIP_LIB
 			return Compress(value_Renamed, 0, value_Renamed.Length, Deflater.BEST_COMPRESSION);
+            #else
+            throw new System.SystemException("Compression support not configured"); 
+            #endif
 		}
 		
 		/// <summary>Compresses the String value, with default BEST_COMPRESSION level </summary>
 		public static byte[] CompressString(System.String value_Renamed)
 		{
+			
+            #if SHARP_ZIP_LIB
 			return CompressString(value_Renamed, Deflater.BEST_COMPRESSION);
+            #else
+            throw new System.SystemException("Compression support not configured"); 
+            #endif
 		}
 		
 		/// <summary>Compresses the String value using the specified
@@ -111,6 +135,7 @@
 		/// </summary>
 		public static byte[] Decompress(byte[] value_Renamed)
 		{
+            #if SHARP_ZIP_LIB
 			// Create an expandable byte array to hold the decompressed data
 			System.IO.MemoryStream bos = new System.IO.MemoryStream(value_Renamed.Length);
 			
@@ -133,6 +158,9 @@
 			}
 			
 			return bos.ToArray();
+            #else
+            throw new System.SystemException("Compression support not configured"); 
+            #endif
 		}
 		
 		/// <summary>Decompress the byte array previously returned by
@@ -146,4 +174,5 @@
 			return new System.String(result.result, 0, result.length);
 		}
 	}
-}
\ No newline at end of file
+}
+

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=885832&r1=885831&r2=885832&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/SupportClass.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/SupportClass.cs Tue Dec  1 16:55:17 2009
@@ -1146,52 +1146,6 @@
             return false;
         }
     }
-
-    /// <summary>
-    /// Use for .NET 1.1 Framework only.
-    /// </summary>
-    public class CompressionSupport
-    {
-        public interface ICompressionAdapter
-        {
-            byte[] Compress(byte[] input, int offset, int length);
-            byte[] Uncompress(byte[] input);
-        }
-
-#if SHARP_ZIP_LIB
-        private static ICompressionAdapter compressionAdapter = new Lucene.Net.Index.Compression.SharpZipLibAdapter();
-#else
-        private static ICompressionAdapter compressionAdapter;
-#endif
-
-        public static byte[] Uncompress(byte[] input)
-        {
-            CheckCompressionSupport();
-            return compressionAdapter.Uncompress(input);
-        }
-
-        public static byte[] Compress(byte[] input, int offset, int length)
-        {
-            CheckCompressionSupport();
-            return compressionAdapter.Compress(input, offset, length);
-        }
-
-        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);
-                object compressionAdapterObj = Activator.CreateInstance(compressionLibClass);
-                compressionAdapter = compressionAdapterObj as ICompressionAdapter;
-                if (compressionAdapter == null)
-                    throw new System.SystemException("Compression adapter does not support
the ICompressionAdapter interface");
-            }
-        }
-    }
 	
 	#region WEAKHASHTABLE
     /// <summary>



Mime
View raw message