commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject commons-compress git commit: Add DEFLATE64 support to CompressorStreamfactory.
Date Fri, 05 Jan 2018 06:01:33 GMT
Repository: commons-compress
Updated Branches:
  refs/heads/COMPRESS-380 ccc3067f5 -> 53ec58298


Add DEFLATE64 support to CompressorStreamfactory.


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/53ec5829
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/53ec5829
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/53ec5829

Branch: refs/heads/COMPRESS-380
Commit: 53ec5829855e8a80b2857b7cfef8bce3e63058a7
Parents: ccc3067
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Fri Jan 5 07:00:54 2018 +0100
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Fri Jan 5 07:00:54 2018 +0100

----------------------------------------------------------------------
 .../compressors/CompressorStreamFactory.java    | 24 ++++++++++++++++++--
 .../Deflate64CompressorInputStreamTest.java     | 19 ++++++++++++++++
 2 files changed, 41 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/53ec5829/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
b/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
index e6a4400..7118744 100644
--- a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
+++ b/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
@@ -37,6 +37,7 @@ import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
 import org.apache.commons.compress.compressors.deflate.DeflateCompressorInputStream;
 import org.apache.commons.compress.compressors.deflate.DeflateCompressorOutputStream;
+import org.apache.commons.compress.compressors.deflate64.Deflate64CompressorInputStream;
 import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
 import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
 import org.apache.commons.compress.compressors.lz4.BlockLZ4CompressorInputStream;
@@ -178,6 +179,13 @@ public class CompressorStreamFactory implements CompressorStreamProvider
{
     public static final String DEFLATE = "deflate";
 
     /**
+     * Constant (value {@value}) used to identify the Deflate64 compress method.
+     *
+     * @since 1.16
+     */
+    public static final String DEFLATE64 = "deflate64";
+
+    /**
      * Constant (value {@value}) used to identify the block LZ4
      * compression method.
      *
@@ -307,6 +315,13 @@ public class CompressorStreamFactory implements CompressorStreamProvider
{
         return DEFLATE;
     }
 
+    /**
+     * @since 1.16
+     */
+    public static String getDeflate64() {
+        return DEFLATE64;
+    }
+
     public static String getGzip() {
         return GZIP;
     }
@@ -534,7 +549,8 @@ public class CompressorStreamFactory implements CompressorStreamProvider
{
      *            of the compressor, i.e. {@value #GZIP}, {@value #BZIP2},
      *            {@value #XZ}, {@value #LZMA}, {@value #PACK200},
      *            {@value #SNAPPY_RAW}, {@value #SNAPPY_FRAMED}, {@value #Z},
-     *            {@value #LZ4_BLOCK}, {@value #LZ4_FRAMED}, {@value #ZSTANDARD}
+     *            {@value #LZ4_BLOCK}, {@value #LZ4_FRAMED}, {@value #ZSTANDARD},
+     *            {@value #DEFLATE64}
      *            or {@value #DEFLATE}
      * @param in
      *            the input stream
@@ -616,6 +632,10 @@ public class CompressorStreamFactory implements CompressorStreamProvider
{
                 return new DeflateCompressorInputStream(in);
             }
 
+            if (DEFLATE64.equalsIgnoreCase(name)) {
+                return new Deflate64CompressorInputStream(in);
+            }
+
             if (LZ4_BLOCK.equalsIgnoreCase(name)) {
                 return new BlockLZ4CompressorInputStream(in);
             }
@@ -738,7 +758,7 @@ public class CompressorStreamFactory implements CompressorStreamProvider
{
     @Override
     public Set<String> getInputStreamCompressorNames() {
         return Sets.newHashSet(GZIP, BROTLI, BZIP2, XZ, LZMA, PACK200, DEFLATE, SNAPPY_RAW,
SNAPPY_FRAMED, Z, LZ4_BLOCK,
-            LZ4_FRAMED, ZSTANDARD);
+            LZ4_FRAMED, ZSTANDARD, DEFLATE64);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/53ec5829/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64CompressorInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64CompressorInputStreamTest.java
b/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64CompressorInputStreamTest.java
index 1e32b42..0232b06 100644
--- a/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64CompressorInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64CompressorInputStreamTest.java
@@ -17,6 +17,7 @@
  */
 package org.apache.commons.compress.compressors.deflate64;
 
+import org.apache.commons.compress.compressors.CompressorStreamFactory;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -25,6 +26,7 @@ import org.mockito.runners.MockitoJUnitRunner;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 
 import static org.junit.Assert.assertEquals;
@@ -101,6 +103,23 @@ public class Deflate64CompressorInputStreamTest {
    }
 
    @Test
+   public void uncompressedBlockViaFactory() throws Exception
+   {
+      byte[] data = {
+         1, 11, 0, -12, -1,
+         'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'
+      };
+
+      try (InputStream input = new CompressorStreamFactory()
+           .createCompressorInputStream(CompressorStreamFactory.DEFLATE64, new ByteArrayInputStream(data));
+           BufferedReader br = new BufferedReader(new InputStreamReader(input)))
+      {
+         assertEquals("Hello World", br.readLine());
+         assertEquals(null, br.readLine());
+      }
+   }
+
+   @Test
    public void uncompressedBlockAvailable() throws Exception
    {
       byte[] data = {


Mime
View raw message