commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject commons-compress git commit: [COMPRESS-392] Add Brotli decoder based on the Google Brotli library.
Date Tue, 02 May 2017 19:22:07 GMT
Repository: commons-compress
Updated Branches:
  refs/heads/master 932d4f899 -> a793612b9


[COMPRESS-392] Add Brotli decoder based on the Google Brotli library.

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

Branch: refs/heads/master
Commit: a793612b9e09795feb253aab9a738bd1f7280700
Parents: 932d4f8
Author: Philippe Mouawad <p.mouawad@ubik-ingenierie.com>
Authored: Tue May 2 12:22:04 2017 -0700
Committer: Gary Gregory <garydgregory@gmail.com>
Committed: Tue May 2 12:22:04 2017 -0700

----------------------------------------------------------------------
 pom.xml                                         |  7 ++++++
 src/changes/changes.xml                         |  3 +++
 .../compressors/CompressorStreamFactory.java    | 25 +++++++++++++++++++-
 3 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/a793612b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9745d1b..4cc629a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,6 +68,12 @@ jar, tar, zip, dump, 7z, arj.
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.brotli</groupId>
+      <artifactId>dec</artifactId>
+      <version>0.1.1</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
       <groupId>org.tukaani</groupId>
       <artifactId>xz</artifactId>
       <version>1.6</version>
@@ -245,6 +251,7 @@ jar, tar, zip, dump, 7z, arj.
         <configuration>
           <instructions>
             <Import-Package>org.tukaani.xz;resolution:=optional</Import-Package>
+            <Import-Package>org.brotli.dec;resolution:=optional</Import-Package>
           </instructions>
         </configuration>
       </plugin>

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/a793612b/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d40a1a8..acd06f0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -103,6 +103,9 @@ The <action> type attribute can be add,update,fix,remove.
         Internal location pointer in ZipFile could get incremented
         even if nothing had been read.
       </action>
+      <action issue="COMPRESS-392" type="add" date="2017-05-02" due-to="Philippe Mouawad">
+        Add Brotli decoder based on the Google Brotli library.
+      </action>
     </release>
     <release version="1.13" date="2016-12-29"
              description="Release 1.13 - API compatible to 1.12 but requires Java 7 at runtime.">

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/a793612b/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 b12fc1a..29cf0cf 100644
--- a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
+++ b/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
@@ -31,6 +31,8 @@ import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
+import org.apache.commons.compress.compressors.brotli.BrotliCompressorInputStream;
+import org.apache.commons.compress.compressors.brotli.BrotliUtils;
 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
 import org.apache.commons.compress.compressors.deflate.DeflateCompressorInputStream;
@@ -93,6 +95,16 @@ public class CompressorStreamFactory implements CompressorStreamProvider
{
 
     private static final CompressorStreamFactory SINGLETON = new CompressorStreamFactory();
 
+
+
+    /**
+     * Constant (value {@value}) used to identify the BROTLI compression
+     * algorithm.
+     * 
+     * @since 1.1
+     */
+    public static final String BROTLI = "br";
+    
     /**
      * Constant (value {@value}) used to identify the BZIP2 compression
      * algorithm.
@@ -263,6 +275,10 @@ public class CompressorStreamFactory implements CompressorStreamProvider
{
     private static ArrayList<CompressorStreamProvider> findCompressorStreamProviders()
{
         return Lists.newArrayList(serviceLoaderIterator());
     }
+
+    public static String getBrotli() {
+        return BROTLI;
+    }
     
     public static String getBzip2() {
         return BZIP2;
@@ -524,6 +540,13 @@ public class CompressorStreamFactory implements CompressorStreamProvider
{
             if (BZIP2.equalsIgnoreCase(name)) {
                 return new BZip2CompressorInputStream(in, actualDecompressConcatenated);
             }
+            
+            if (BROTLI.equalsIgnoreCase(name)) {
+                if (!BrotliUtils.isBrotliCompressionAvailable()) {
+                    throw new CompressorException("Brotli compression is not available.");
+                }
+                return new BrotliCompressorInputStream(in);
+            }
 
             if (XZ.equalsIgnoreCase(name)) {
                 if (!XZUtils.isXZCompressionAvailable()) {
@@ -677,7 +700,7 @@ public class CompressorStreamFactory implements CompressorStreamProvider
{
 
     @Override
     public Set<String> getInputStreamCompressorNames() {
-        return Sets.newHashSet(GZIP, BZIP2, XZ, LZMA, PACK200, DEFLATE, SNAPPY_RAW, SNAPPY_FRAMED,
Z, LZ4_BLOCK,
+        return Sets.newHashSet(GZIP, BROTLI, BZIP2, XZ, LZMA, PACK200, DEFLATE, SNAPPY_RAW,
SNAPPY_FRAMED, Z, LZ4_BLOCK,
             LZ4_FRAMED);
     }
 


Mime
View raw message