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
9
* http://www.apache.org/licenses/LICENSE-2.0
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.
18
package org.apache.commons.compress.archivers.zip;
20
import java.util.Collections;
21
import java.util.HashMap;
23
import java.util.zip.ZipEntry;
26
* List of known compression methods
28
* Many of these methods are currently not supported by commons compress
32
public enum ZipMethod {
35
* Compression method 0 for uncompressed entries.
37
* @see ZipEntry#STORED
39
STORED(ZipEntry.STORED),
43
* dynamic Lempel-Ziv-Welch-Algorithm
45
* @see <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">Explanation of fields: compression
46
* method: (2 bytes)</a>
51
* Reduced with compression factor 1.
53
* @see <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">Explanation of fields: compression
54
* method: (2 bytes)</a>
59
* Reduced with compression factor 2.
61
* @see <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">Explanation of fields: compression
62
* method: (2 bytes)</a>
67
* Reduced with compression factor 3.
69
* @see <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">Explanation of fields: compression
70
* method: (2 bytes)</a>
75
* Reduced with compression factor 4.
77
* @see <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">Explanation of fields: compression
78
* method: (2 bytes)</a>
85
* @see <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">Explanation of fields: compression
86
* method: (2 bytes)</a>
93
* @see <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">Explanation of fields: compression
94
* method: (2 bytes)</a>
99
* Compression method 8 for compressed (deflated) entries.
101
* @see ZipEntry#DEFLATED
103
DEFLATED(ZipEntry.DEFLATED),
106
* Compression Method 9 for enhanced deflate.
108
* @see "http://www.winzip.com/wz54.htm"
110
ENHANCED_DEFLATED(9),
113
* PKWARE Data Compression Library Imploding.
115
* @see "http://www.winzip.com/wz54.htm"
117
PKWARE_IMPLODING(10),
120
* Compression Method 12 for bzip2.
122
* @see "http://www.winzip.com/wz54.htm"
127
* Compression Method 14 for LZMA.
129
* @see "http://www.7-zip.org/sdk.html"
130
* @see "http://www.winzip.com/wz54.htm"
136
* Compression Method 96 for Jpeg compression.
138
* @see "http://www.winzip.com/wz54.htm"
143
* Compression Method 97 for WavPack.
145
* @see "http://www.winzip.com/wz54.htm"
150
* Compression Method 98 for PPMd.
152
* @see "http://www.winzip.com/wz54.htm"
158
* Compression Method 99 for AES encryption.
160
* @see "http://www.winzip.com/wz54.htm"
165
* Unknown compression method.
169
private final int code;
171
private static final Map<Integer, ZipMethod> codeToEnum;
174
Map<Integer, ZipMethod> cte = new HashMap<Integer, ZipMethod>();
175
for (ZipMethod method : values()) {
176
cte.put(Integer.valueOf(method.getCode()), method);
178
codeToEnum = Collections.unmodifiableMap(cte);
182
* private constructor for enum style class.
184
ZipMethod(int code) {
189
* the code of the compression method.
191
* @see ZipArchiveEntry#getMethod()
193
* @return an integer code for the method
195
public int getCode() {
201
* returns the {@link ZipMethod} for the given code or null if the
202
* method is not known.
204
public static ZipMethod getMethodByCode(int code) {
205
return codeToEnum.get(Integer.valueOf(code));