1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.netty.handler.codec.compression;
17
18 import org.jboss.netty.util.internal.jzlib.JZlib;
19 import org.jboss.netty.util.internal.jzlib.ZStream;
20
21
22
23
24
25
26
27
28 final class ZlibUtil {
29
30 static void fail(ZStream z, String message, int resultCode) {
31 throw exception(z, message, resultCode);
32 }
33
34 static CompressionException exception(ZStream z, String message, int resultCode) {
35 return new CompressionException(message + " (" + resultCode + ")" +
36 (z.msg != null? ": " + z.msg : ""));
37 }
38
39 static Enum<?> convertWrapperType(ZlibWrapper wrapper) {
40 Enum<?> convertedWrapperType;
41 switch (wrapper) {
42 case NONE:
43 convertedWrapperType = JZlib.W_NONE;
44 break;
45 case ZLIB:
46 convertedWrapperType = JZlib.W_ZLIB;
47 break;
48 case GZIP:
49 convertedWrapperType = JZlib.W_GZIP;
50 break;
51 case ZLIB_OR_NONE:
52 convertedWrapperType = JZlib.W_ZLIB_OR_NONE;
53 break;
54 default:
55 throw new Error();
56 }
57 return convertedWrapperType;
58 }
59
60 private ZlibUtil() {
61 super();
62 }
63 }