commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1572827 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz: Coders.java SevenZMethod.java
Date Fri, 28 Feb 2014 05:47:47 GMT
Author: bodewig
Date: Fri Feb 28 05:47:46 2014
New Revision: 1572827

URL: http://svn.apache.org/r1572827
Log:
COMPRESS-257 add support for x86 BCJ - XZ for Java also supports some of the other BJJs and
Delta

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZMethod.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java?rev=1572827&r1=1572826&r2=1572827&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
Fri Feb 28 05:47:46 2014
@@ -31,7 +31,9 @@ import java.util.zip.InflaterInputStream
 
 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
+import org.tukaani.xz.FinishableWrapperOutputStream;
 import org.tukaani.xz.LZMAInputStream;
+import org.tukaani.xz.X86Options;
 
 class Coders {
     private static final Map<SevenZMethod, CoderBase> CODER_MAP = new HashMap<SevenZMethod,
CoderBase>() {{
@@ -41,6 +43,7 @@ class Coders {
             put(SevenZMethod.DEFLATE, new DeflateDecoder());
             put(SevenZMethod.BZIP2, new BZIP2Decoder());
             put(SevenZMethod.AES256SHA256, new AES256SHA256Decoder());
+            put(SevenZMethod.X86, new X86Decoder());
         }};
 
     static CoderBase findByMethod(SevenZMethod method) {
@@ -94,6 +97,18 @@ class Coders {
         }
     }
     
+    static class X86Decoder extends CoderBase {
+        @Override
+        InputStream decode(final InputStream in, final Coder coder,
+                byte[] password) throws IOException {
+            return new X86Options().getInputStream(in);
+        }
+        @Override
+        OutputStream encode(final OutputStream out, final Object _) {
+            return new X86Options().getOutputStream(new FinishableWrapperOutputStream(out));
+        }
+    }
+    
     static class DeflateDecoder extends CoderBase {
         DeflateDecoder() {
             super(Number.class);

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZMethod.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZMethod.java?rev=1572827&r1=1572826&r2=1572827&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZMethod.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZMethod.java
Fri Feb 28 05:47:46 2014
@@ -37,12 +37,23 @@ public enum SevenZMethod {
      * AES encryption with a key length of 256 bit using SHA256 for
      * hashes - only supported when reading
      */
-    AES256SHA256(new byte[] { (byte)0x06, (byte)0xf1, (byte)0x07, (byte)0x01 });
+    AES256SHA256(new byte[] { (byte)0x06, (byte)0xf1, (byte)0x07, (byte)0x01 }),
+    /**
+     * BCJ x86 version 1.
+     * @since 1.8
+     */
+    X86(new byte[] { 0x03, 0x03, 0x01, 0x03 }, new byte[] { 0x04 });
 
     private final byte[] id;
+    private final byte[] alternativeId;
 
     private SevenZMethod(byte[] id) {
+        this(id, null);
+    }
+
+    private SevenZMethod(byte[] id, byte[] alternativeId) {
         this.id = id;
+        this.alternativeId = alternativeId;
     }
 
     byte[] getId() {
@@ -53,7 +64,8 @@ public enum SevenZMethod {
 
     static SevenZMethod byId(byte[] id) {
         for (SevenZMethod m : SevenZMethod.class.getEnumConstants()) {
-            if (Arrays.equals(m.id, id)) {
+            if (Arrays.equals(m.id, id)
+                || (m.alternativeId != null && Arrays.equals(m.alternativeId, id)))
{
                 return m;
             }
         }



Mime
View raw message