~ubuntu-branches/ubuntu/utopic/libcommons-compress-java/utopic

« back to all changes in this revision

Viewing changes to src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZMethod.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2013-11-02 13:55:47 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20131102135547-nhcubj3ae7rv6t13
Tags: 1.6-1
* New upstream release
* Updated Standards-Version to 3.9.5 (no changes)
* Build depend on debhelper >= 9
* Removed the unused debian/orig-tar.sh script

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 *  contributor license agreements.  See the NOTICE file distributed with
 
4
 *  this work for additional information regarding copyright ownership.
 
5
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 
6
 *  (the "License"); you may not use this file except in compliance with
 
7
 *  the License.  You may obtain a copy of the License at
 
8
 *
 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
 
10
 *
 
11
 *  Unless required by applicable law or agreed to in writing, software
 
12
 *  distributed under the License is distributed on an "AS IS" BASIS,
 
13
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
 *  See the License for the specific language governing permissions and
 
15
 *  limitations under the License.
 
16
 *
 
17
 */
 
18
package org.apache.commons.compress.archivers.sevenz;
 
19
 
 
20
import org.tukaani.xz.LZMA2Options;
 
21
 
 
22
/**
 
23
 * The (partially) supported compression/encryption methods used in 7z archives.
 
24
 */
 
25
public enum SevenZMethod {
 
26
    /** no compression at all */
 
27
    COPY(new byte[] { (byte)0x00 }),
 
28
    /** LZMA - only supported when reading */
 
29
    LZMA(new byte[] { (byte)0x03, (byte)0x01, (byte)0x01 }),
 
30
    /** LZMA2 */
 
31
    LZMA2(new byte[] { (byte)0x21 }) {
 
32
        @Override
 
33
        byte[] getProperties() {
 
34
            int dictSize = LZMA2Options.DICT_SIZE_DEFAULT;
 
35
            int lead = Integer.numberOfLeadingZeros(dictSize);
 
36
            int secondBit = (dictSize >>> (30 - lead)) - 2;
 
37
            return new byte[] {
 
38
                (byte) ((19 - lead) * 2 + secondBit)
 
39
            };
 
40
        }
 
41
    },
 
42
    /** Deflate */
 
43
    DEFLATE(new byte[] { (byte)0x04, (byte)0x01, (byte)0x08 }),
 
44
    /** BZIP2 */
 
45
    BZIP2(new byte[] { (byte)0x04, (byte)0x02, (byte)0x02 }),
 
46
    /**
 
47
     * AES encryption with a key length of 256 bit using SHA256 for
 
48
     * hashes - only supported when reading
 
49
     */
 
50
    AES256SHA256(new byte[] { (byte)0x06, (byte)0xf1, (byte)0x07, (byte)0x01 });
 
51
 
 
52
    private final byte[] id;
 
53
 
 
54
    private SevenZMethod(byte[] id) {
 
55
        this.id = id;
 
56
    }
 
57
 
 
58
    byte[] getId() {
 
59
        byte[] copy = new byte[id.length];
 
60
        System.arraycopy(id, 0, copy, 0, id.length);
 
61
        return copy;
 
62
    }
 
63
 
 
64
    byte[] getProperties() {
 
65
        return new byte[0];
 
66
    }
 
67
 
 
68
}