From 5d99d57cab6d90d2c91594d8755164261b8283b4 Mon Sep 17 00:00:00 2001 From: norman Date: Fri, 2 Mar 2012 13:28:54 +0100 Subject: [PATCH] Fix checkstyle problems --- .../io/netty/util/internal/jzlib/Adler32.java | 4 + .../io/netty/util/internal/jzlib/CRC32.java | 4 + .../io/netty/util/internal/jzlib/Deflate.java | 10 +- .../netty/util/internal/jzlib/InfBlocks.java | 108 ++++++++---------- .../netty/util/internal/jzlib/InfCodes.java | 2 +- .../io/netty/util/internal/jzlib/InfTree.java | 6 +- .../io/netty/util/internal/jzlib/Inflate.java | 4 +- .../io/netty/util/internal/jzlib/JZlib.java | 4 + .../util/internal/jzlib/package-info.java | 21 ++++ 9 files changed, 92 insertions(+), 71 deletions(-) create mode 100644 common/src/main/java/io/netty/util/internal/jzlib/package-info.java diff --git a/common/src/main/java/io/netty/util/internal/jzlib/Adler32.java b/common/src/main/java/io/netty/util/internal/jzlib/Adler32.java index 8e5f00c834..234d25404d 100644 --- a/common/src/main/java/io/netty/util/internal/jzlib/Adler32.java +++ b/common/src/main/java/io/netty/util/internal/jzlib/Adler32.java @@ -112,4 +112,8 @@ final class Adler32 { } return s2 << 16 | s1; } + + private Adler32() { + // Utility Class + } } diff --git a/common/src/main/java/io/netty/util/internal/jzlib/CRC32.java b/common/src/main/java/io/netty/util/internal/jzlib/CRC32.java index c6b17f0876..6af6a37545 100644 --- a/common/src/main/java/io/netty/util/internal/jzlib/CRC32.java +++ b/common/src/main/java/io/netty/util/internal/jzlib/CRC32.java @@ -92,4 +92,8 @@ final class CRC32 { crc32 ^= 0xffffffff; return crc32; } + + private CRC32() { + // Utility Class + } } diff --git a/common/src/main/java/io/netty/util/internal/jzlib/Deflate.java b/common/src/main/java/io/netty/util/internal/jzlib/Deflate.java index 4d45145b86..ca714f06d3 100644 --- a/common/src/main/java/io/netty/util/internal/jzlib/Deflate.java +++ b/common/src/main/java/io/netty/util/internal/jzlib/Deflate.java @@ -96,7 +96,7 @@ final class Deflate { "data error", // Z_DATA_ERROR (-3) "insufficient memory", // Z_MEM_ERROR (-4) "buffer error", // Z_BUF_ERROR (-5) - "incompatible version",// Z_VERSION_ERROR (-6) + "incompatible version", // Z_VERSION_ERROR (-6) "" }; // block not completed, need more input or more output @@ -342,7 +342,7 @@ final class Deflate { // Scan a literal or distance tree to determine the frequencies of the codes // in the bit length tree. - private void scan_tree(short[] tree,// the tree to be scanned + private void scan_tree(short[] tree, // the tree to be scanned int max_code // and its largest code of non zero frequency ) { int n; // iterates over all tree elements @@ -437,7 +437,7 @@ final class Deflate { // Send a literal or distance tree in compressed form, using the codes in // bl_tree. - private void send_tree(short[] tree,// the tree to be sent + private void send_tree(short[] tree, // the tree to be sent int max_code // and its largest code of non zero frequency ) { int n; // iterates over all tree elements @@ -514,7 +514,7 @@ final class Deflate { private void send_code(int c, short[] tree) { int c2 = c * 2; - send_bits((tree[c2] & 0xffff), (tree[c2 + 1] & 0xffff)); + send_bits(tree[c2] & 0xffff, tree[c2 + 1] & 0xffff); } private void send_bits(int value, int length) { @@ -804,7 +804,7 @@ final class Deflate { int stored_len, // length of input block boolean eof // true if this is the last block for a file ) { - int opt_lenb, static_lenb;// opt_len and static_len in bytes + int opt_lenb, static_lenb; // opt_len and static_len in bytes int max_blindex = 0; // index of last bit length code of non zero freq // Build the Huffman trees unless a stored block is forced diff --git a/common/src/main/java/io/netty/util/internal/jzlib/InfBlocks.java b/common/src/main/java/io/netty/util/internal/jzlib/InfBlocks.java index b387ffbb1c..e51d5ee454 100644 --- a/common/src/main/java/io/netty/util/internal/jzlib/InfBlocks.java +++ b/common/src/main/java/io/netty/util/internal/jzlib/InfBlocks.java @@ -61,7 +61,7 @@ final class InfBlocks { private static final int TYPE = 0; // get type bits (3, including end bit) private static final int LENS = 1; // get lengths for stored - private static final int STORED = 2;// processing stored block + private static final int STORED = 2; // processing stored block private static final int TABLE = 3; // get table lengths private static final int BTREE = 4; // get bit lengths tree for a dynamic block private static final int DTREE = 5; // get length, distance trees for a dynamic block @@ -124,16 +124,15 @@ final class InfBlocks { int m; // bytes to end of window or read pointer // copy input/output information to locals (UPDATE macro restores) - { - p = z.next_in_index; - n = z.avail_in; - b = bitb; - k = bitk; - } - { - q = write; - m = q < read? read - q - 1 : end - q; - } + + p = z.next_in_index; + n = z.avail_in; + b = bitb; + k = bitk; + + q = write; + m = q < read? read - q - 1 : end - q; + // process input based on current state while (true) { @@ -161,20 +160,17 @@ final class InfBlocks { switch (t >>> 1) { case 0: // stored - { + b >>>= 3; k -= 3; - } + t = k & 7; // go to byte boundary - { - b >>>= t; - k -= t; - } + b >>>= t; + k -= t; mode = LENS; // get length of stored block break; case 1: // fixed - { int[] bl = new int[1]; int[] bd = new int[1]; int[][] tl = new int[1][]; @@ -182,30 +178,24 @@ final class InfBlocks { InfTree.inflate_trees_fixed(bl, bd, tl, td); codes.init(bl[0], bd[0], tl[0], 0, td[0], 0); - } - { - b >>>= 3; - k -= 3; - } + b >>>= 3; + k -= 3; mode = CODES; break; case 2: // dynamic - { b >>>= 3; k -= 3; - } mode = TABLE; break; case 3: // illegal - { b >>>= 3; k -= 3; - } + mode = BAD; z.msg = "invalid block type"; r = JZlib.Z_DATA_ERROR; @@ -352,10 +342,9 @@ final class InfBlocks { } } - { - b >>>= 14; - k -= 14; - } + + b >>>= 14; + k -= 14; index = 0; mode = BTREE; @@ -380,10 +369,9 @@ final class InfBlocks { blens[border[index ++]] = b & 7; - { - b >>>= 3; - k -= 3; - } + b >>>= 3; + k -= 3; + } while (index < 19) { @@ -505,36 +493,36 @@ final class InfBlocks { } tb[0] = -1; - { - int[] bl = new int[1]; - int[] bd = new int[1]; - int[] tl = new int[1]; - int[] td = new int[1]; - bl[0] = 9; // must be <= 9 for lookahead assumptions - bd[0] = 6; // must be <= 9 for lookahead assumptions - t = table; - t = inftree.inflate_trees_dynamic(257 + (t & 0x1f), - 1 + (t >> 5 & 0x1f), blens, bl, bd, tl, td, hufts, - z); + int[] bl = new int[1]; + int[] bd = new int[1]; + int[] tl = new int[1]; + int[] td = new int[1]; + bl[0] = 9; // must be <= 9 for lookahead assumptions + bd[0] = 6; // must be <= 9 for lookahead assumptions - if (t != JZlib.Z_OK) { - if (t == JZlib.Z_DATA_ERROR) { - blens = null; - mode = BAD; - } - r = t; + t = table; + t = inftree.inflate_trees_dynamic(257 + (t & 0x1f), + 1 + (t >> 5 & 0x1f), blens, bl, bd, tl, td, hufts, + z); - bitb = b; - bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - write = q; - return inflate_flush(z, r); + if (t != JZlib.Z_OK) { + if (t == JZlib.Z_DATA_ERROR) { + blens = null; + mode = BAD; } - codes.init(bl[0], bd[0], hufts, tl[0], hufts, td[0]); + r = t; + + bitb = b; + bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + write = q; + return inflate_flush(z, r); } + codes.init(bl[0], bd[0], hufts, tl[0], hufts, td[0]); + mode = CODES; case CODES: bitb = b; diff --git a/common/src/main/java/io/netty/util/internal/jzlib/InfCodes.java b/common/src/main/java/io/netty/util/internal/jzlib/InfCodes.java index ef979b57a3..6e6ea3ab2a 100644 --- a/common/src/main/java/io/netty/util/internal/jzlib/InfCodes.java +++ b/common/src/main/java/io/netty/util/internal/jzlib/InfCodes.java @@ -71,7 +71,7 @@ final class InfCodes { // mode dependent information private int len; private int[] tree; // pointer into tree - private int tree_index = 0; + private int tree_index; private int need; // bits needed private int lit; // if EXT or COPY, where and how much diff --git a/common/src/main/java/io/netty/util/internal/jzlib/InfTree.java b/common/src/main/java/io/netty/util/internal/jzlib/InfTree.java index 313c1789f6..67012e3dea 100644 --- a/common/src/main/java/io/netty/util/internal/jzlib/InfTree.java +++ b/common/src/main/java/io/netty/util/internal/jzlib/InfTree.java @@ -180,8 +180,8 @@ final class InfTree { int[] e, // list of extra bits for non-simple codes int[] t, // result: starting table int[] m, // maximum lookup bits, returns actual - int[] hp,// space for trees - int[] hn,// hufts used in space + int[] hp, // space for trees + int[] hn, // hufts used in space int[] v // working area: values in order of bit length ) { // Given a list of code lengths and a maximum table size, make a set of @@ -437,7 +437,7 @@ final class InfTree { static int inflate_trees_fixed(int[] bl, //literal desired/actual bit depth int[] bd, //distance desired/actual bit depth - int[][] tl,//literal/length tree result + int[][] tl, //literal/length tree result int[][] td //distance tree result ) { bl[0] = fixed_bl; diff --git a/common/src/main/java/io/netty/util/internal/jzlib/Inflate.java b/common/src/main/java/io/netty/util/internal/jzlib/Inflate.java index c496533203..c18dc1592f 100644 --- a/common/src/main/java/io/netty/util/internal/jzlib/Inflate.java +++ b/common/src/main/java/io/netty/util/internal/jzlib/Inflate.java @@ -76,7 +76,7 @@ final class Inflate { private static final int GZIP_FNAME = 21; private static final int GZIP_FCOMMENT = 22; private static final int GZIP_FHCRC = 23; - private static final int GZIP_CRC32= 24; + private static final int GZIP_CRC32 = 24; private static final int GZIP_ISIZE = 25; private int mode; // current inflate mode @@ -305,7 +305,7 @@ final class Inflate { break; } else if (z.istate.wrapperType == WrapperType.ZLIB) { z.istate.mode = CHECK4; - } else if (z.istate.wrapperType == WrapperType.GZIP){ + } else if (z.istate.wrapperType == WrapperType.GZIP) { gzipCRC32 = 0; gzipISize = 0; gzipBytesToRead = 4; diff --git a/common/src/main/java/io/netty/util/internal/jzlib/JZlib.java b/common/src/main/java/io/netty/util/internal/jzlib/JZlib.java index b97f96a878..5d74519f5b 100644 --- a/common/src/main/java/io/netty/util/internal/jzlib/JZlib.java +++ b/common/src/main/java/io/netty/util/internal/jzlib/JZlib.java @@ -105,4 +105,8 @@ public final class JZlib { enum WrapperType { NONE, ZLIB, GZIP, ZLIB_OR_NONE } + + private JZlib() { + // Utility class + } } diff --git a/common/src/main/java/io/netty/util/internal/jzlib/package-info.java b/common/src/main/java/io/netty/util/internal/jzlib/package-info.java new file mode 100644 index 0000000000..758bc4e1fe --- /dev/null +++ b/common/src/main/java/io/netty/util/internal/jzlib/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2011 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +/** + * Internal-use-only utilities which is not allowed to be used + * outside Netty. + */ +package io.netty.util.internal.jzlib;