You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2016/04/10 06:18:58 UTC
[42/46] commons-compress git commit: Add final modifier to local
variables.
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
index d66d068..e9c78c6 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
@@ -115,7 +115,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
public ZipArchiveEntry(final java.util.zip.ZipEntry entry) throws ZipException {
super(entry);
setName(entry.getName());
- byte[] extra = entry.getExtra();
+ final byte[] extra = entry.getExtra();
if (extra != null) {
setExtraFields(ExtraFieldUtils.parse(extra, true,
ExtraFieldUtils
@@ -143,7 +143,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
setExternalAttributes(entry.getExternalAttributes());
setExtraFields(getAllExtraFieldsNoCopy());
setPlatform(entry.getPlatform());
- GeneralPurposeBit other = entry.getGeneralPurposeBit();
+ final GeneralPurposeBit other = entry.getGeneralPurposeBit();
setGeneralPurposeBit(other == null ? null :
(GeneralPurposeBit) other.clone());
}
@@ -181,7 +181,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
*/
@Override
public Object clone() {
- ZipArchiveEntry e = (ZipArchiveEntry) super.clone();
+ final ZipArchiveEntry e = (ZipArchiveEntry) super.clone();
e.setInternalAttributes(getInternalAttributes());
e.setExternalAttributes(getExternalAttributes());
@@ -321,8 +321,8 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
* @param fields an array of extra fields
*/
public void setExtraFields(final ZipExtraField[] fields) {
- List<ZipExtraField> newFields = new ArrayList<ZipExtraField>();
- for (ZipExtraField field : fields) {
+ final List<ZipExtraField> newFields = new ArrayList<ZipExtraField>();
+ for (final ZipExtraField field : fields) {
if (field instanceof UnparseableExtraFieldData) {
unparseableExtra = (UnparseableExtraFieldData) field;
} else {
@@ -390,7 +390,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
}
private ZipExtraField[] copyOf(final ZipExtraField[] src, final int length) {
- ZipExtraField[] cpy = new ZipExtraField[length];
+ final ZipExtraField[] cpy = new ZipExtraField[length];
System.arraycopy(src, 0, cpy, 0, Math.min(src.length, length));
return cpy;
}
@@ -449,8 +449,8 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
if (getExtraField(ze.getHeaderId()) != null){
removeExtraField(ze.getHeaderId());
}
- ZipExtraField[] copy = extraFields;
- int newLen = extraFields != null ? extraFields.length + 1: 1;
+ final ZipExtraField[] copy = extraFields;
+ final int newLen = extraFields != null ? extraFields.length + 1: 1;
extraFields = new ZipExtraField[newLen];
extraFields[0] = ze;
if (copy != null){
@@ -469,8 +469,8 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
throw new java.util.NoSuchElementException();
}
- List<ZipExtraField> newResult = new ArrayList<ZipExtraField>();
- for (ZipExtraField extraField : extraFields) {
+ final List<ZipExtraField> newResult = new ArrayList<ZipExtraField>();
+ for (final ZipExtraField extraField : extraFields) {
if (!type.equals(extraField.getHeaderId())){
newResult.add( extraField);
}
@@ -503,7 +503,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
*/
public ZipExtraField getExtraField(final ZipShort type) {
if (extraFields != null) {
- for (ZipExtraField extraField : extraFields) {
+ for (final ZipExtraField extraField : extraFields) {
if (type.equals(extraField.getHeaderId())) {
return extraField;
}
@@ -534,11 +534,11 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
@Override
public void setExtra(final byte[] extra) throws RuntimeException {
try {
- ZipExtraField[] local =
+ final ZipExtraField[] local =
ExtraFieldUtils.parse(extra, true,
ExtraFieldUtils.UnparseableExtraField.READ);
mergeExtraFields(local, true);
- } catch (ZipException e) {
+ } catch (final ZipException e) {
// actually this is not possible as of Commons Compress 1.1
throw new RuntimeException("Error parsing extra fields for entry: "
+ getName() + " - " + e.getMessage(), e);
@@ -561,11 +561,11 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
*/
public void setCentralDirectoryExtra(final byte[] b) {
try {
- ZipExtraField[] central =
+ final ZipExtraField[] central =
ExtraFieldUtils.parse(b, false,
ExtraFieldUtils.UnparseableExtraField.READ);
mergeExtraFields(central, false);
- } catch (ZipException e) {
+ } catch (final ZipException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
@@ -575,7 +575,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
* @return the extra data for local file
*/
public byte[] getLocalFileDataExtra() {
- byte[] extra = getExtra();
+ final byte[] extra = getExtra();
return extra != null ? extra : EMPTY;
}
@@ -671,7 +671,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
*/
public byte[] getRawName() {
if (rawName != null) {
- byte[] b = new byte[rawName.length];
+ final byte[] b = new byte[rawName.length];
System.arraycopy(rawName, 0, b, 0, rawName.length);
return b;
}
@@ -723,7 +723,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
if (extraFields == null) {
setExtraFields(f);
} else {
- for (ZipExtraField element : f) {
+ for (final ZipExtraField element : f) {
ZipExtraField existing;
if (element instanceof UnparseableExtraFieldData) {
existing = unparseableExtra;
@@ -734,10 +734,10 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
addExtraField(element);
} else {
if (local) {
- byte[] b = element.getLocalFileDataData();
+ final byte[] b = element.getLocalFileDataData();
existing.parseFromLocalFileData(b, 0, b.length);
} else {
- byte[] b = element.getCentralDirectoryData();
+ final byte[] b = element.getCentralDirectoryData();
existing.parseFromCentralDirectoryData(b, 0, b.length);
}
}
@@ -770,9 +770,9 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
if (obj == null || getClass() != obj.getClass()) {
return false;
}
- ZipArchiveEntry other = (ZipArchiveEntry) obj;
- String myName = getName();
- String otherName = other.getName();
+ final ZipArchiveEntry other = (ZipArchiveEntry) obj;
+ final String myName = getName();
+ final String otherName = other.getName();
if (myName == null) {
if (otherName != null) {
return false;
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
index d0eb5f1..d64ae4e 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
@@ -235,11 +235,11 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
} else {
readFully(LFH_BUF);
}
- } catch (EOFException e) {
+ } catch (final EOFException e) {
return null;
}
- ZipLong sig = new ZipLong(LFH_BUF);
+ final ZipLong sig = new ZipLong(LFH_BUF);
if (sig.equals(ZipLong.CFH_SIG) || sig.equals(ZipLong.AED_SIG)) {
hitCentralDirectory = true;
skipRemainderOfArchive();
@@ -251,7 +251,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
int off = WORD;
current = new CurrentEntry();
- int versionMadeBy = ZipShort.getValue(LFH_BUF, off);
+ final int versionMadeBy = ZipShort.getValue(LFH_BUF, off);
off += SHORT;
current.entry.setPlatform((versionMadeBy >> ZipFile.BYTE_SHIFT) & ZipFile.NIBLET_MASK);
@@ -266,7 +266,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
current.entry.setMethod(ZipShort.getValue(LFH_BUF, off));
off += SHORT;
- long time = ZipUtil.dosToJavaTime(ZipLong.getValue(LFH_BUF, off));
+ final long time = ZipUtil.dosToJavaTime(ZipLong.getValue(LFH_BUF, off));
current.entry.setTime(time);
off += WORD;
@@ -284,18 +284,18 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
off += 3 * WORD;
}
- int fileNameLen = ZipShort.getValue(LFH_BUF, off);
+ final int fileNameLen = ZipShort.getValue(LFH_BUF, off);
off += SHORT;
- int extraLen = ZipShort.getValue(LFH_BUF, off);
+ final int extraLen = ZipShort.getValue(LFH_BUF, off);
off += SHORT;
- byte[] fileName = new byte[fileNameLen];
+ final byte[] fileName = new byte[fileNameLen];
readFully(fileName);
current.entry.setName(entryEncoding.decode(fileName), fileName);
- byte[] extraData = new byte[extraLen];
+ final byte[] extraData = new byte[extraLen];
readFully(extraData);
current.entry.setExtra(extraData);
@@ -329,7 +329,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
*/
private void readFirstLocalFileHeader(final byte[] lfh) throws IOException {
readFully(lfh);
- ZipLong sig = new ZipLong(lfh);
+ final ZipLong sig = new ZipLong(lfh);
if (sig.equals(ZipLong.DD_SIG)) {
throw new UnsupportedZipFeatureException(UnsupportedZipFeatureException.Feature.SPLITTING);
}
@@ -337,7 +337,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
if (sig.equals(ZipLong.SINGLE_SEGMENT_SPLIT_MARKER)) {
// The archive is not really split as only one segment was
// needed in the end. Just skip over the marker.
- byte[] missedLfhBytes = new byte[4];
+ final byte[] missedLfhBytes = new byte[4];
readFully(missedLfhBytes);
System.arraycopy(lfh, 4, lfh, 0, LFH_LEN - 4);
System.arraycopy(missedLfhBytes, 0, lfh, LFH_LEN - 4, 4);
@@ -350,7 +350,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
* doesn't use a data descriptor.
*/
private void processZip64Extra(final ZipLong size, final ZipLong cSize) {
- Zip64ExtendedInformationExtraField z64 =
+ final Zip64ExtendedInformationExtraField z64 =
(Zip64ExtendedInformationExtraField)
current.entry.getExtraField(Zip64ExtendedInformationExtraField.HEADER_ID);
current.usesZip64 = z64 != null;
@@ -381,7 +381,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
@Override
public boolean canReadEntryData(final ArchiveEntry ae) {
if (ae instanceof ZipArchiveEntry) {
- ZipArchiveEntry ze = (ZipArchiveEntry) ae;
+ final ZipArchiveEntry ze = (ZipArchiveEntry) ae;
return ZipUtil.canHandleEntryData(ze)
&& supportsDataDescriptorFor(ze);
@@ -443,14 +443,14 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
return lastStoredEntry.read(buffer, offset, length);
}
- long csize = current.entry.getSize();
+ final long csize = current.entry.getSize();
if (current.bytesRead >= csize) {
return -1;
}
if (buf.position() >= buf.limit()) {
buf.position(0);
- int l = in.read(buf.array());
+ final int l = in.read(buf.array());
if (l == -1) {
return -1;
}
@@ -474,7 +474,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
* Implementation of read for DEFLATED entries.
*/
private int readDeflated(final byte[] buffer, final int offset, final int length) throws IOException {
- int read = readFromInflater(buffer, offset, length);
+ final int read = readFromInflater(buffer, offset, length);
if (read <= 0) {
if (inf.finished()) {
return -1;
@@ -497,7 +497,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
int read = 0;
do {
if (inf.needsInput()) {
- int l = fill();
+ final int l = fill();
if (l > 0) {
current.bytesReadFromStream += buf.limit();
} else if (l == -1) {
@@ -508,7 +508,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
}
try {
read = inf.inflate(buffer, offset, length);
- } catch (DataFormatException e) {
+ } catch (final DataFormatException e) {
throw (IOException) new ZipException(e.getMessage()).initCause(e);
}
} while (read == 0 && inf.needsInput());
@@ -547,8 +547,8 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
if (value >= 0) {
long skipped = 0;
while (skipped < value) {
- long rem = value - skipped;
- int x = read(SKIP_BUF, 0, (int) (SKIP_BUF.length > rem ? rem : SKIP_BUF.length));
+ final long rem = value - skipped;
+ final int x = read(SKIP_BUF, 0, (int) (SKIP_BUF.length > rem ? rem : SKIP_BUF.length));
if (x == -1) {
return skipped;
}
@@ -621,12 +621,12 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
} else {
skip(Long.MAX_VALUE);
- long inB = current.entry.getMethod() == ZipArchiveOutputStream.DEFLATED
+ final long inB = current.entry.getMethod() == ZipArchiveOutputStream.DEFLATED
? getBytesInflated() : current.bytesRead;
// this is at most a single read() operation and can't
// exceed the range of int
- int diff = (int) (current.bytesReadFromStream - inB);
+ final int diff = (int) (current.bytesReadFromStream - inB);
// Pushback any required bytes
if (diff > 0) {
@@ -651,7 +651,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
private void drainCurrentEntryData() throws IOException {
long remaining = current.entry.getCompressedSize() - current.bytesReadFromStream;
while (remaining > 0) {
- long n = in.read(buf.array(), 0, (int) Math.min(buf.capacity(), remaining));
+ final long n = in.read(buf.array(), 0, (int) Math.min(buf.capacity(), remaining));
if (n < 0) {
throw new EOFException("Truncated ZIP entry: " + current.entry.getName());
}
@@ -689,7 +689,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
if (closed) {
throw new IOException("The stream is closed");
}
- int length = in.read(buf.array());
+ final int length = in.read(buf.array());
if (length > 0) {
buf.limit(length);
count(buf.limit());
@@ -699,7 +699,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
}
private void readFully(final byte[] b) throws IOException {
- int count = IOUtils.readFully(in, b);
+ final int count = IOUtils.readFully(in, b);
count(count);
if (count < b.length) {
throw new EOFException();
@@ -728,7 +728,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
// If so, push back eight bytes and assume sizes are four
// bytes, otherwise sizes are eight bytes each.
readFully(TWO_DWORD_BUF);
- ZipLong potentialSig = new ZipLong(TWO_DWORD_BUF, DWORD);
+ final ZipLong potentialSig = new ZipLong(TWO_DWORD_BUF, DWORD);
if (potentialSig.equals(ZipLong.CFH_SIG) || potentialSig.equals(ZipLong.LFH_SIG)) {
pushback(TWO_DWORD_BUF, DWORD, DWORD);
current.entry.setCompressedSize(ZipLong.getValue(TWO_DWORD_BUF));
@@ -771,15 +771,15 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
* next local file or central directory header.</p>
*/
private void readStoredEntry() throws IOException {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
int off = 0;
boolean done = false;
// length of DD without signature
- int ddLen = current.usesZip64 ? WORD + 2 * DWORD : 3 * WORD;
+ final int ddLen = current.usesZip64 ? WORD + 2 * DWORD : 3 * WORD;
while (!done) {
- int r = in.read(buf.array(), off, ZipArchiveOutputStream.BUFFER_SIZE - off);
+ final int r = in.read(buf.array(), off, ZipArchiveOutputStream.BUFFER_SIZE - off);
if (r <= 0) {
// read the whole archive without ever finding a
// central directory
@@ -797,7 +797,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
}
}
- byte[] b = bos.toByteArray();
+ final byte[] b = bos.toByteArray();
lastStoredEntry = new ByteArrayInputStream(b);
}
@@ -952,8 +952,8 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
if (value >= 0) {
long skipped = 0;
while (skipped < value) {
- long rem = value - skipped;
- int x = in.read(SKIP_BUF, 0, (int) (SKIP_BUF.length > rem ? rem : SKIP_BUF.length));
+ final long rem = value - skipped;
+ final int x = in.read(SKIP_BUF, 0, (int) (SKIP_BUF.length > rem ? rem : SKIP_BUF.length));
if (x == -1) {
return;
}
@@ -972,7 +972,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
* Also updates bytes-read counter.
*/
private int readOneByte() throws IOException {
- int b = in.read();
+ final int b = in.read();
if (b != -1) {
count(1);
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
index 873de5c..68b962d 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
@@ -285,7 +285,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
try {
_raf = new RandomAccessFile(file, "rw");
_raf.setLength(0);
- } catch (IOException e) {
+ } catch (final IOException e) {
IOUtils.closeQuietly(_raf);
_raf = null;
o = new FileOutputStream(file);
@@ -451,10 +451,10 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
}
private void writeCentralDirectoryInChunks() throws IOException {
- int NUM_PER_WRITE = 1000;
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(70 * NUM_PER_WRITE);
+ final int NUM_PER_WRITE = 1000;
+ final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(70 * NUM_PER_WRITE);
int count = 0;
- for (ZipArchiveEntry ze : entries) {
+ for (final ZipArchiveEntry ze : entries) {
byteArrayOutputStream.write(createCentralFileHeader(ze));
if (++count > NUM_PER_WRITE){
writeCounted(byteArrayOutputStream.toByteArray());
@@ -478,8 +478,8 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
flushDeflater();
- long bytesWritten = streamCompressor.getTotalBytesWritten() - entry.dataStart;
- long realCrc = streamCompressor.getCrc32();
+ final long bytesWritten = streamCompressor.getTotalBytesWritten() - entry.dataStart;
+ final long realCrc = streamCompressor.getCrc32();
entry.bytesRead = streamCompressor.getBytesRead();
final Zip64Mode effectiveMode = getEffectiveZip64Mode(entry.entry);
final boolean actuallyNeedsZip64 = handleSizesAndCrc(bytesWritten, realCrc, effectiveMode);
@@ -500,8 +500,8 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
private void closeCopiedEntry(final boolean phased) throws IOException {
preClose();
entry.bytesRead = entry.entry.getSize();
- Zip64Mode effectiveMode = getEffectiveZip64Mode(entry.entry);
- boolean actuallyNeedsZip64 = checkIfNeedsZip64(effectiveMode);
+ final Zip64Mode effectiveMode = getEffectiveZip64Mode(entry.entry);
+ final boolean actuallyNeedsZip64 = checkIfNeedsZip64(effectiveMode);
closeEntry(actuallyNeedsZip64, phased);
}
@@ -543,14 +543,14 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
*/
public void addRawArchiveEntry(final ZipArchiveEntry entry, final InputStream rawStream)
throws IOException {
- ZipArchiveEntry ae = new ZipArchiveEntry(entry);
+ final ZipArchiveEntry ae = new ZipArchiveEntry(entry);
if (hasZip64Extra(ae)) {
// Will be re-added as required. this may make the file generated with this method
// somewhat smaller than standard mode,
// since standard mode is unable to remove the zip 64 header.
ae.removeExtraField(Zip64ExtendedInformationExtraField.HEADER_ID);
}
- boolean is2PhaseSource = ae.getCrc() != ZipArchiveEntry.CRC_UNKNOWN
+ final boolean is2PhaseSource = ae.getCrc() != ZipArchiveEntry.CRC_UNKNOWN
&& ae.getSize() != ArchiveEntry.SIZE_UNKNOWN
&& ae.getCompressedSize() != ArchiveEntry.SIZE_UNKNOWN;
putArchiveEntry(ae, is2PhaseSource);
@@ -640,7 +640,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
*/
private void rewriteSizesAndCrc(final boolean actuallyNeedsZip64)
throws IOException {
- long save = raf.getFilePointer();
+ final long save = raf.getFilePointer();
raf.seek(entry.localDataStart);
writeOut(ZipLong.getBytes(entry.entry.getCrc()));
@@ -653,8 +653,8 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
}
if (hasZip64Extra(entry.entry)) {
- ByteBuffer name = getName(entry.entry);
- int nameLen = name.limit() - name.position();
+ final ByteBuffer name = getName(entry.entry);
+ final int nameLen = name.limit() - name.position();
// seek to ZIP64 extra, skip header and size information
raf.seek(entry.localDataStart + 3 * WORD + 2 * SHORT
+ nameLen + 2 * SHORT);
@@ -728,7 +728,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
if (shouldAddZip64Extra(entry.entry, effectiveMode)) {
- Zip64ExtendedInformationExtraField z64 = getZip64Extra(entry.entry);
+ final Zip64ExtendedInformationExtraField z64 = getZip64Extra(entry.entry);
// just a placeholder, real data will be in data
// descriptor or inserted later via RandomAccessFile
@@ -867,7 +867,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
@Override
public boolean canWriteEntryData(final ArchiveEntry ae) {
if (ae instanceof ZipArchiveEntry) {
- ZipArchiveEntry zae = (ZipArchiveEntry) ae;
+ final ZipArchiveEntry zae = (ZipArchiveEntry) ae;
return zae.getMethod() != ZipMethod.IMPLODING.getCode()
&& zae.getMethod() != ZipMethod.UNSHRINKING.getCode()
&& ZipUtil.canHandleEntryData(zae);
@@ -888,7 +888,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
throw new IllegalStateException("No current entry");
}
ZipUtil.checkRequestedFeatures(entry.entry);
- long writtenThisTime = streamCompressor.write(b, offset, length, entry.entry.getMethod());
+ final long writtenThisTime = streamCompressor.write(b, offset, length, entry.entry.getMethod());
count(writtenThisTime);
}
@@ -991,15 +991,15 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
}
private void writeLocalFileHeader(final ZipArchiveEntry ze, final boolean phased) throws IOException {
- boolean encodable = zipEncoding.canEncode(ze.getName());
- ByteBuffer name = getName(ze);
+ final boolean encodable = zipEncoding.canEncode(ze.getName());
+ final ByteBuffer name = getName(ze);
if (createUnicodeExtraFields != UnicodeExtraFieldPolicy.NEVER) {
addUnicodeExtraFields(ze, encodable, name);
}
final byte[] localHeader = createLocalFileHeader(ze, name, encodable, phased);
- long localHeaderStart = streamCompressor.getTotalBytesWritten();
+ final long localHeaderStart = streamCompressor.getTotalBytesWritten();
offsets.put(ze, localHeaderStart);
entry.localDataStart = localHeaderStart + LFH_CRC_OFFSET; // At crc offset
writeCounted(localHeader);
@@ -1009,10 +1009,10 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
private byte[] createLocalFileHeader(final ZipArchiveEntry ze, final ByteBuffer name, final boolean encodable,
final boolean phased) {
- byte[] extra = ze.getLocalFileDataExtra();
+ final byte[] extra = ze.getLocalFileDataExtra();
final int nameLen = name.limit() - name.position();
- int len= LFH_FILENAME_OFFSET + nameLen + extra.length;
- byte[] buf = new byte[len];
+ final int len= LFH_FILENAME_OFFSET + nameLen + extra.length;
+ final byte[] buf = new byte[len];
System.arraycopy(LFH_SIG, 0, buf, LFH_SIG_OFFSET, WORD);
@@ -1025,7 +1025,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
putShort(versionNeededToExtract(zipMethod, hasZip64Extra(ze)), buf, LFH_VERSION_NEEDED_OFFSET);
}
- GeneralPurposeBit generalPurposeBit = getGeneralPurposeBits(zipMethod, !encodable && fallbackToUTF8);
+ final GeneralPurposeBit generalPurposeBit = getGeneralPurposeBits(zipMethod, !encodable && fallbackToUTF8);
generalPurposeBit.encode(buf, LFH_GPB_OFFSET);
// compression method
@@ -1091,14 +1091,14 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
- name.position()));
}
- String comm = ze.getComment();
+ final String comm = ze.getComment();
if (comm != null && !"".equals(comm)) {
- boolean commentEncodable = zipEncoding.canEncode(comm);
+ final boolean commentEncodable = zipEncoding.canEncode(comm);
if (createUnicodeExtraFields == UnicodeExtraFieldPolicy.ALWAYS
|| !commentEncodable) {
- ByteBuffer commentB = getEntryEncoding(ze).encode(comm);
+ final ByteBuffer commentB = getEntryEncoding(ze).encode(comm);
ze.addExtraField(new UnicodeCommentExtraField(comm,
commentB.array(),
commentB.arrayOffset(),
@@ -1138,7 +1138,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
* Zip64Mode#Never}.
*/
protected void writeCentralFileHeader(final ZipArchiveEntry ze) throws IOException {
- byte[] centralFileHeader = createCentralFileHeader(ze);
+ final byte[] centralFileHeader = createCentralFileHeader(ze);
writeCounted(centralFileHeader);
}
@@ -1174,7 +1174,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
*/
private byte[] createCentralFileHeader(final ZipArchiveEntry ze, final ByteBuffer name, final long lfhOffset,
final boolean needsZip64Extra) throws IOException {
- byte[] extra = ze.getCentralDirectoryExtra();
+ final byte[] extra = ze.getCentralDirectoryExtra();
// file comment length
String comm = ze.getComment();
@@ -1182,11 +1182,11 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
comm = "";
}
- ByteBuffer commentB = getEntryEncoding(ze).encode(comm);
+ final ByteBuffer commentB = getEntryEncoding(ze).encode(comm);
final int nameLen = name.limit() - name.position();
final int commentLen = commentB.limit() - commentB.position();
- int len= CFH_FILENAME_OFFSET + nameLen + extra.length + commentLen;
- byte[] buf = new byte[len];
+ final int len= CFH_FILENAME_OFFSET + nameLen + extra.length + commentLen;
+ final byte[] buf = new byte[len];
System.arraycopy(CFH_SIG, 0, buf, CFH_SIG_OFFSET, WORD);
@@ -1247,10 +1247,10 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
// file name
System.arraycopy(name.array(), name.arrayOffset(), buf, CFH_FILENAME_OFFSET, nameLen);
- int extraStart = CFH_FILENAME_OFFSET + nameLen;
+ final int extraStart = CFH_FILENAME_OFFSET + nameLen;
System.arraycopy(extra, 0, buf, extraStart, extra.length);
- int commentStart = extraStart + extra.length;
+ final int commentStart = extraStart + extra.length;
// file comment
System.arraycopy(commentB.array(), commentB.arrayOffset(), buf, commentStart, commentLen);
@@ -1264,7 +1264,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
private void handleZip64Extra(final ZipArchiveEntry ze, final long lfhOffset,
final boolean needsZip64Extra) {
if (needsZip64Extra) {
- Zip64ExtendedInformationExtraField z64 = getZip64Extra(ze);
+ final Zip64ExtendedInformationExtraField z64 = getZip64Extra(ze);
if (ze.getCompressedSize() >= ZIP64_MAGIC
|| ze.getSize() >= ZIP64_MAGIC
|| zip64Mode == Zip64Mode.Always) {
@@ -1297,7 +1297,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
writeCounted(ZERO);
// number of entries
- int numberOfEntries = entries.size();
+ final int numberOfEntries = entries.size();
if (numberOfEntries > ZIP64_MAGIC_SHORT
&& zip64Mode == Zip64Mode.Never) {
throw new Zip64RequiredException(Zip64RequiredException
@@ -1308,7 +1308,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
.ARCHIVE_TOO_BIG_MESSAGE);
}
- byte[] num = ZipShort.getBytes(Math.min(numberOfEntries,
+ final byte[] num = ZipShort.getBytes(Math.min(numberOfEntries,
ZIP64_MAGIC_SHORT));
writeCounted(num);
writeCounted(num);
@@ -1318,8 +1318,8 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
writeCounted(ZipLong.getBytes(Math.min(cdOffset, ZIP64_MAGIC)));
// ZIP file comment
- ByteBuffer data = this.zipEncoding.encode(comment);
- int dataLen = data.limit() - data.position();
+ final ByteBuffer data = this.zipEncoding.encode(comment);
+ final int dataLen = data.limit() - data.position();
writeCounted(ZipShort.getBytes(dataLen));
streamCompressor.writeCounted(data.array(), data.arrayOffset(), dataLen);
}
@@ -1346,7 +1346,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
return;
}
- long offset = streamCompressor.getTotalBytesWritten();
+ final long offset = streamCompressor.getTotalBytesWritten();
writeOut(ZIP64_EOCD_SIG);
// size, we don't have any variable length as we don't support
@@ -1371,7 +1371,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
writeOut(LZERO);
// number of entries
- byte[] num = ZipEightByteInteger.getBytes(entries.size());
+ final byte[] num = ZipEightByteInteger.getBytes(entries.size());
writeOut(num);
writeOut(num);
@@ -1416,7 +1416,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
private GeneralPurposeBit getGeneralPurposeBits(final int zipMethod, final boolean utfFallback) {
- GeneralPurposeBit b = new GeneralPurposeBit();
+ final GeneralPurposeBit b = new GeneralPurposeBit();
b.useUTF8ForNames(useUTF8Flag || utfFallback);
if (isDeflatedToOutputStream(zipMethod)) {
b.useDataDescriptor(true);
@@ -1522,7 +1522,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
}
private ZipEncoding getEntryEncoding(final ZipArchiveEntry ze) {
- boolean encodable = zipEncoding.canEncode(ze.getName());
+ final boolean encodable = zipEncoding.canEncode(ze.getName());
return !encodable && fallbackToUTF8
? ZipEncodingHelper.UTF8_ZIP_ENCODING : zipEncoding;
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java
index baf99ea..c564460 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java
@@ -139,8 +139,8 @@ public final class ZipEightByteInteger implements Serializable {
* @return value as eight bytes in big endian byte order
*/
public static byte[] getBytes(final BigInteger value) {
- byte[] result = new byte[8];
- long val = value.longValue();
+ final byte[] result = new byte[8];
+ final long val = value.longValue();
result[0] = (byte) ((val & BYTE_MASK));
result[BYTE_1] = (byte) ((val & BYTE_1_MASK) >> BYTE_1_SHIFT);
result[BYTE_2] = (byte) ((val & BYTE_2_MASK) >> BYTE_2_SHIFT);
@@ -182,7 +182,7 @@ public final class ZipEightByteInteger implements Serializable {
value += ((long) bytes[offset + BYTE_2] << BYTE_2_SHIFT) & BYTE_2_MASK;
value += ((long) bytes[offset + BYTE_1] << BYTE_1_SHIFT) & BYTE_1_MASK;
value += ((long) bytes[offset] & BYTE_MASK);
- BigInteger val = BigInteger.valueOf(value);
+ final BigInteger val = BigInteger.valueOf(value);
return (bytes[offset + BYTE_7] & LEFTMOST_BIT) == LEFTMOST_BIT
? val.setBit(LEFTMOST_BIT_SHIFT) : val;
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
index 63af448..bc3f9d2 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
@@ -68,10 +68,10 @@ public abstract class ZipEncodingHelper {
private static final Map<String, SimpleEncodingHolder> simpleEncodings;
static {
- Map<String, SimpleEncodingHolder> se =
+ final Map<String, SimpleEncodingHolder> se =
new HashMap<String, SimpleEncodingHolder>();
- char[] cp437_high_chars =
+ final char[] cp437_high_chars =
new char[] { 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0,
0x00e5, 0x00e7, 0x00ea, 0x00eb, 0x00e8, 0x00ef,
0x00ee, 0x00ec, 0x00c4, 0x00c5, 0x00c9, 0x00e6,
@@ -95,7 +95,7 @@ public abstract class ZipEncodingHelper {
0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2,
0x25a0, 0x00a0 };
- SimpleEncodingHolder cp437 = new SimpleEncodingHolder(cp437_high_chars);
+ final SimpleEncodingHolder cp437 = new SimpleEncodingHolder(cp437_high_chars);
se.put("CP437", cp437);
se.put("Cp437", cp437);
@@ -103,7 +103,7 @@ public abstract class ZipEncodingHelper {
se.put("IBM437", cp437);
se.put("ibm437", cp437);
- char[] cp850_high_chars =
+ final char[] cp850_high_chars =
new char[] { 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0,
0x00e5, 0x00e7, 0x00ea, 0x00eb, 0x00e8, 0x00ef,
0x00ee, 0x00ec, 0x00c4, 0x00c5, 0x00c9, 0x00e6,
@@ -127,7 +127,7 @@ public abstract class ZipEncodingHelper {
0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2,
0x25a0, 0x00a0 };
- SimpleEncodingHolder cp850 = new SimpleEncodingHolder(cp850_high_chars);
+ final SimpleEncodingHolder cp850 = new SimpleEncodingHolder(cp850_high_chars);
se.put("CP850", cp850);
se.put("Cp850", cp850);
@@ -153,8 +153,8 @@ public abstract class ZipEncodingHelper {
b.limit(b.position());
b.rewind();
- int c2 = b.capacity() * 2;
- ByteBuffer on = ByteBuffer.allocate(c2 < newCapacity ? newCapacity : c2);
+ final int c2 = b.capacity() * 2;
+ final ByteBuffer on = ByteBuffer.allocate(c2 < newCapacity ? newCapacity : c2);
on.put(b);
return on;
@@ -218,7 +218,7 @@ public abstract class ZipEncodingHelper {
return new FallbackZipEncoding();
}
- SimpleEncodingHolder h = simpleEncodings.get(name);
+ final SimpleEncodingHolder h = simpleEncodings.get(name);
if (h!=null) {
return h.getEncoding();
@@ -226,10 +226,10 @@ public abstract class ZipEncodingHelper {
try {
- Charset cs = Charset.forName(name);
+ final Charset cs = Charset.forName(name);
return new NioZipEncoding(cs);
- } catch (UnsupportedCharsetException e) {
+ } catch (final UnsupportedCharsetException e) {
return new FallbackZipEncoding(name);
}
}
@@ -248,7 +248,7 @@ public abstract class ZipEncodingHelper {
if (Charsets.UTF_8.name().equalsIgnoreCase(charsetName)) {
return true;
}
- for (String alias : Charsets.UTF_8.aliases()) {
+ for (final String alias : Charsets.UTF_8.aliases()) {
if (alias.equalsIgnoreCase(charsetName)) {
return true;
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
index 36fa63b..7647ead 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
@@ -214,7 +214,7 @@ public class ZipFile implements Closeable {
archive = new RandomAccessFile(f, "r");
boolean success = false;
try {
- Map<ZipArchiveEntry, NameAndComment> entriesWithoutUTF8Flag =
+ final Map<ZipArchiveEntry, NameAndComment> entriesWithoutUTF8Flag =
populateFromCentralDirectory();
resolveLocalFileHeaderData(entriesWithoutUTF8Flag);
success = true;
@@ -281,7 +281,7 @@ public class ZipFile implements Closeable {
* @since 1.1
*/
public Enumeration<ZipArchiveEntry> getEntriesInPhysicalOrder() {
- ZipArchiveEntry[] allEntries = entries.toArray(new ZipArchiveEntry[entries.size()]);
+ final ZipArchiveEntry[] allEntries = entries.toArray(new ZipArchiveEntry[entries.size()]);
Arrays.sort(allEntries, OFFSET_COMPARATOR);
return Collections.enumeration(Arrays.asList(allEntries));
}
@@ -299,7 +299,7 @@ public class ZipFile implements Closeable {
* {@code null} if not present.
*/
public ZipArchiveEntry getEntry(final String name) {
- LinkedList<ZipArchiveEntry> entriesOfThatName = nameMap.get(name);
+ final LinkedList<ZipArchiveEntry> entriesOfThatName = nameMap.get(name);
return entriesOfThatName != null ? entriesOfThatName.getFirst() : null;
}
@@ -313,7 +313,7 @@ public class ZipFile implements Closeable {
* @since 1.6
*/
public Iterable<ZipArchiveEntry> getEntries(final String name) {
- List<ZipArchiveEntry> entriesOfThatName = nameMap.get(name);
+ final List<ZipArchiveEntry> entriesOfThatName = nameMap.get(name);
return entriesOfThatName != null ? entriesOfThatName
: Collections.<ZipArchiveEntry>emptyList();
}
@@ -363,8 +363,8 @@ public class ZipFile implements Closeable {
if (!(ze instanceof Entry)) {
return null;
}
- OffsetEntry offsetEntry = ((Entry) ze).getOffsetEntry();
- long start = offsetEntry.dataOffset;
+ final OffsetEntry offsetEntry = ((Entry) ze).getOffsetEntry();
+ final long start = offsetEntry.dataOffset;
return new BoundedInputStream(start, ze.getCompressedSize());
}
@@ -380,9 +380,9 @@ public class ZipFile implements Closeable {
*/
public void copyRawEntries(final ZipArchiveOutputStream target, final ZipArchiveEntryPredicate predicate)
throws IOException {
- Enumeration<ZipArchiveEntry> src = getEntriesInPhysicalOrder();
+ final Enumeration<ZipArchiveEntry> src = getEntriesInPhysicalOrder();
while (src.hasMoreElements()) {
- ZipArchiveEntry entry = src.nextElement();
+ final ZipArchiveEntry entry = src.nextElement();
if (predicate.test( entry)) {
target.addRawArchiveEntry(entry, getRawInputStream(entry));
}
@@ -403,10 +403,10 @@ public class ZipFile implements Closeable {
return null;
}
// cast valididty is checked just above
- OffsetEntry offsetEntry = ((Entry) ze).getOffsetEntry();
+ final OffsetEntry offsetEntry = ((Entry) ze).getOffsetEntry();
ZipUtil.checkRequestedFeatures(ze);
- long start = offsetEntry.dataOffset;
- BoundedInputStream bis =
+ final long start = offsetEntry.dataOffset;
+ final BoundedInputStream bis =
new BoundedInputStream(start, ze.getCompressedSize());
switch (ZipMethod.getMethodByCode(ze.getMethod())) {
case STORED:
@@ -469,7 +469,7 @@ public class ZipFile implements Closeable {
InputStream in = null;
try {
in = getInputStream(entry);
- byte[] symlinkBytes = IOUtils.toByteArray(in);
+ final byte[] symlinkBytes = IOUtils.toByteArray(in);
return zipEncoding.decode(symlinkBytes);
} finally {
if (in != null) {
@@ -536,7 +536,7 @@ public class ZipFile implements Closeable {
*/
private Map<ZipArchiveEntry, NameAndComment> populateFromCentralDirectory()
throws IOException {
- HashMap<ZipArchiveEntry, NameAndComment> noUTF8Flag =
+ final HashMap<ZipArchiveEntry, NameAndComment> noUTF8Flag =
new HashMap<ZipArchiveEntry, NameAndComment>();
positionAtCentralDirectory();
@@ -571,10 +571,10 @@ public class ZipFile implements Closeable {
throws IOException {
archive.readFully(CFH_BUF);
int off = 0;
- OffsetEntry offset = new OffsetEntry();
- Entry ze = new Entry(offset);
+ final OffsetEntry offset = new OffsetEntry();
+ final Entry ze = new Entry(offset);
- int versionMadeBy = ZipShort.getValue(CFH_BUF, off);
+ final int versionMadeBy = ZipShort.getValue(CFH_BUF, off);
off += SHORT;
ze.setVersionMadeBy(versionMadeBy);
ze.setPlatform((versionMadeBy >> BYTE_SHIFT) & NIBLET_MASK);
@@ -595,7 +595,7 @@ public class ZipFile implements Closeable {
ze.setMethod(ZipShort.getValue(CFH_BUF, off));
off += SHORT;
- long time = ZipUtil.dosToJavaTime(ZipLong.getValue(CFH_BUF, off));
+ final long time = ZipUtil.dosToJavaTime(ZipLong.getValue(CFH_BUF, off));
ze.setTime(time);
off += WORD;
@@ -608,16 +608,16 @@ public class ZipFile implements Closeable {
ze.setSize(ZipLong.getValue(CFH_BUF, off));
off += WORD;
- int fileNameLen = ZipShort.getValue(CFH_BUF, off);
+ final int fileNameLen = ZipShort.getValue(CFH_BUF, off);
off += SHORT;
- int extraLen = ZipShort.getValue(CFH_BUF, off);
+ final int extraLen = ZipShort.getValue(CFH_BUF, off);
off += SHORT;
- int commentLen = ZipShort.getValue(CFH_BUF, off);
+ final int commentLen = ZipShort.getValue(CFH_BUF, off);
off += SHORT;
- int diskStart = ZipShort.getValue(CFH_BUF, off);
+ final int diskStart = ZipShort.getValue(CFH_BUF, off);
off += SHORT;
ze.setInternalAttributes(ZipShort.getValue(CFH_BUF, off));
@@ -626,7 +626,7 @@ public class ZipFile implements Closeable {
ze.setExternalAttributes(ZipLong.getValue(CFH_BUF, off));
off += WORD;
- byte[] fileName = new byte[fileNameLen];
+ final byte[] fileName = new byte[fileNameLen];
archive.readFully(fileName);
ze.setName(entryEncoding.decode(fileName), fileName);
@@ -635,13 +635,13 @@ public class ZipFile implements Closeable {
// data offset will be filled later
entries.add(ze);
- byte[] cdExtraData = new byte[extraLen];
+ final byte[] cdExtraData = new byte[extraLen];
archive.readFully(cdExtraData);
ze.setCentralDirectoryExtra(cdExtraData);
setSizesAndOffsetFromZip64Extra(ze, offset, diskStart);
- byte[] comment = new byte[commentLen];
+ final byte[] comment = new byte[commentLen];
archive.readFully(comment);
ze.setComment(entryEncoding.decode(comment));
@@ -666,13 +666,13 @@ public class ZipFile implements Closeable {
final OffsetEntry offset,
final int diskStart)
throws IOException {
- Zip64ExtendedInformationExtraField z64 =
+ final Zip64ExtendedInformationExtraField z64 =
(Zip64ExtendedInformationExtraField)
ze.getExtraField(Zip64ExtendedInformationExtraField.HEADER_ID);
if (z64 != null) {
- boolean hasUncompressedSize = ze.getSize() == ZIP64_MAGIC;
- boolean hasCompressedSize = ze.getCompressedSize() == ZIP64_MAGIC;
- boolean hasRelativeHeaderOffset =
+ final boolean hasUncompressedSize = ze.getSize() == ZIP64_MAGIC;
+ final boolean hasCompressedSize = ze.getCompressedSize() == ZIP64_MAGIC;
+ final boolean hasRelativeHeaderOffset =
offset.headerOffset == ZIP64_MAGIC;
z64.reparseCentralDirectoryData(hasUncompressedSize,
hasCompressedSize,
@@ -800,7 +800,7 @@ public class ZipFile implements Closeable {
throws IOException {
positionAtEndOfCentralDirectoryRecord();
boolean found = false;
- boolean searchedForZip64EOCD =
+ final boolean searchedForZip64EOCD =
archive.getFilePointer() > ZIP64_EOCDL_LENGTH;
if (searchedForZip64EOCD) {
archive.seek(archive.getFilePointer() - ZIP64_EOCDL_LENGTH);
@@ -865,7 +865,7 @@ public class ZipFile implements Closeable {
*/
private void positionAtEndOfCentralDirectoryRecord()
throws IOException {
- boolean found = tryToLocateSignature(MIN_EOCD_SIZE, MAX_EOCD_SIZE,
+ final boolean found = tryToLocateSignature(MIN_EOCD_SIZE, MAX_EOCD_SIZE,
ZipArchiveOutputStream.EOCD_SIG);
if (!found) {
throw new ZipException("archive is not a ZIP archive");
@@ -919,7 +919,7 @@ public class ZipFile implements Closeable {
private void skipBytes(final int count) throws IOException {
int totalSkipped = 0;
while (totalSkipped < count) {
- int skippedNow = archive.skipBytes(count - totalSkipped);
+ final int skippedNow = archive.skipBytes(count - totalSkipped);
if (skippedNow <= 0) {
throw new EOFException();
}
@@ -952,39 +952,39 @@ public class ZipFile implements Closeable {
private void resolveLocalFileHeaderData(final Map<ZipArchiveEntry, NameAndComment>
entriesWithoutUTF8Flag)
throws IOException {
- for (ZipArchiveEntry zipArchiveEntry : entries) {
+ for (final ZipArchiveEntry zipArchiveEntry : entries) {
// entries is filled in populateFromCentralDirectory and
// never modified
- Entry ze = (Entry) zipArchiveEntry;
- OffsetEntry offsetEntry = ze.getOffsetEntry();
- long offset = offsetEntry.headerOffset;
+ final Entry ze = (Entry) zipArchiveEntry;
+ final OffsetEntry offsetEntry = ze.getOffsetEntry();
+ final long offset = offsetEntry.headerOffset;
archive.seek(offset + LFH_OFFSET_FOR_FILENAME_LENGTH);
archive.readFully(SHORT_BUF);
- int fileNameLen = ZipShort.getValue(SHORT_BUF);
+ final int fileNameLen = ZipShort.getValue(SHORT_BUF);
archive.readFully(SHORT_BUF);
- int extraFieldLen = ZipShort.getValue(SHORT_BUF);
+ final int extraFieldLen = ZipShort.getValue(SHORT_BUF);
int lenToSkip = fileNameLen;
while (lenToSkip > 0) {
- int skipped = archive.skipBytes(lenToSkip);
+ final int skipped = archive.skipBytes(lenToSkip);
if (skipped <= 0) {
throw new IOException("failed to skip file name in"
+ " local file header");
}
lenToSkip -= skipped;
}
- byte[] localExtraData = new byte[extraFieldLen];
+ final byte[] localExtraData = new byte[extraFieldLen];
archive.readFully(localExtraData);
ze.setExtra(localExtraData);
offsetEntry.dataOffset = offset + LFH_OFFSET_FOR_FILENAME_LENGTH
+ SHORT + SHORT + fileNameLen + extraFieldLen;
if (entriesWithoutUTF8Flag.containsKey(ze)) {
- NameAndComment nc = entriesWithoutUTF8Flag.get(ze);
+ final NameAndComment nc = entriesWithoutUTF8Flag.get(ze);
ZipUtil.setNameAndCommentFromExtraFields(ze, nc.name,
nc.comment);
}
- String name = ze.getName();
+ final String name = ze.getName();
LinkedList<ZipArchiveEntry> entriesOfThatName = nameMap.get(name);
if (entriesOfThatName == null) {
entriesOfThatName = new LinkedList<ZipArchiveEntry>();
@@ -1098,15 +1098,15 @@ public class ZipFile implements Closeable {
return 0;
}
- Entry ent1 = e1 instanceof Entry ? (Entry) e1 : null;
- Entry ent2 = e2 instanceof Entry ? (Entry) e2 : null;
+ final Entry ent1 = e1 instanceof Entry ? (Entry) e1 : null;
+ final Entry ent2 = e2 instanceof Entry ? (Entry) e2 : null;
if (ent1 == null) {
return 1;
}
if (ent2 == null) {
return -1;
}
- long val = (ent1.getOffsetEntry().headerOffset
+ final long val = (ent1.getOffsetEntry().headerOffset
- ent2.getOffsetEntry().headerOffset);
return val == 0 ? 0 : val < 0 ? -1 : +1;
}
@@ -1137,7 +1137,7 @@ public class ZipFile implements Closeable {
public boolean equals(final Object other) {
if (super.equals(other)) {
// super.equals would return false if other were not an Entry
- Entry otherEntry = (Entry) other;
+ final Entry otherEntry = (Entry) other;
return offsetEntry.headerOffset
== otherEntry.offsetEntry.headerOffset
&& offsetEntry.dataOffset
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java
index 3b2e278..e3e3f86 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java
@@ -133,7 +133,7 @@ public final class ZipLong implements Cloneable, Serializable {
* @return value as four bytes in big endian byte order
*/
public static byte[] getBytes(final long value) {
- byte[] result = new byte[WORD];
+ final byte[] result = new byte[WORD];
putLong(value, result, 0);
return result;
}
@@ -207,7 +207,7 @@ public final class ZipLong implements Cloneable, Serializable {
public Object clone() {
try {
return super.clone();
- } catch (CloneNotSupportedException cnfe) {
+ } catch (final CloneNotSupportedException cnfe) {
// impossible
throw new RuntimeException(cnfe);
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/archivers/zip/ZipMethod.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipMethod.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipMethod.java
index 8848370..5f7bb41 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipMethod.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipMethod.java
@@ -173,8 +173,8 @@ public enum ZipMethod {
private static final Map<Integer, ZipMethod> codeToEnum;
static {
- Map<Integer, ZipMethod> cte = new HashMap<Integer, ZipMethod>();
- for (ZipMethod method : values()) {
+ final Map<Integer, ZipMethod> cte = new HashMap<Integer, ZipMethod>();
+ for (final ZipMethod method : values()) {
cte.put(method.getCode(), method);
}
codeToEnum = Collections.unmodifiableMap(cte);
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/archivers/zip/ZipShort.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipShort.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipShort.java
index 39f5274..f3c2e06 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipShort.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipShort.java
@@ -64,7 +64,7 @@ public final class ZipShort implements Cloneable, Serializable {
* @return the value as a a two byte array in big endian byte order
*/
public byte[] getBytes() {
- byte[] result = new byte[2];
+ final byte[] result = new byte[2];
result[0] = (byte) (value & BYTE_MASK);
result[1] = (byte) ((value & BYTE_1_MASK) >> BYTE_1_SHIFT);
return result;
@@ -84,7 +84,7 @@ public final class ZipShort implements Cloneable, Serializable {
* @return the converted int as a byte array in big endian byte order
*/
public static byte[] getBytes(final int value) {
- byte[] result = new byte[2];
+ final byte[] result = new byte[2];
putShort(value, result, 0);
return result;
}
@@ -149,7 +149,7 @@ public final class ZipShort implements Cloneable, Serializable {
public Object clone() {
try {
return super.clone();
- } catch (CloneNotSupportedException cnfe) {
+ } catch (final CloneNotSupportedException cnfe) {
// impossible
throw new RuntimeException(cnfe);
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
index 847678f..cc3660b 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
@@ -51,7 +51,7 @@ public abstract class ZipUtil {
* @return the date as a byte array
*/
public static byte[] toDosTime(final long t) {
- byte[] result = new byte[4];
+ final byte[] result = new byte[4];
toDosTime(t, result, 0);
return result;
}
@@ -73,13 +73,13 @@ public abstract class ZipUtil {
static void toDosTime(final Calendar c, final long t, final byte[] buf, final int offset) {
c.setTimeInMillis(t);
- int year = c.get(Calendar.YEAR);
+ final int year = c.get(Calendar.YEAR);
if (year < 1980) {
System.arraycopy(DOS_TIME_MIN, 0, buf, offset, DOS_TIME_MIN.length);// stop callers from changing the array
return;
}
- int month = c.get(Calendar.MONTH) + 1;
- long value = ((year - 1980) << 25)
+ final int month = c.get(Calendar.MONTH) + 1;
+ final long value = ((year - 1980) << 25)
| (month << 21)
| (c.get(Calendar.DAY_OF_MONTH) << 16)
| (c.get(Calendar.HOUR_OF_DAY) << 11)
@@ -117,7 +117,7 @@ public abstract class ZipUtil {
public static byte[] reverse(final byte[] array) {
final int z = array.length - 1; // position of last element
for (int i = 0; i < array.length / 2; i++) {
- byte x = array[i];
+ final byte x = array[i];
array[i] = array[z - i];
array[z - i] = x;
}
@@ -200,7 +200,7 @@ public abstract class ZipUtil {
* @return a Date instance corresponding to the given time.
*/
public static Date fromDosTime(final ZipLong zipDosTime) {
- long dosTime = zipDosTime.getValue();
+ final long dosTime = zipDosTime.getValue();
return new Date(dosToJavaTime(dosTime));
}
@@ -211,7 +211,7 @@ public abstract class ZipUtil {
* @return converted time
*/
public static long dosToJavaTime(final long dosTime) {
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
// CheckStyle:MagicNumberCheck OFF - no point
cal.set(Calendar.YEAR, (int) ((dosTime >> 25) & 0x7f) + 1980);
cal.set(Calendar.MONTH, (int) ((dosTime >> 21) & 0x0f) - 1);
@@ -232,19 +232,19 @@ public abstract class ZipUtil {
static void setNameAndCommentFromExtraFields(final ZipArchiveEntry ze,
final byte[] originalNameBytes,
final byte[] commentBytes) {
- UnicodePathExtraField name = (UnicodePathExtraField)
+ final UnicodePathExtraField name = (UnicodePathExtraField)
ze.getExtraField(UnicodePathExtraField.UPATH_ID);
- String originalName = ze.getName();
- String newName = getUnicodeStringIfOriginalMatches(name,
+ final String originalName = ze.getName();
+ final String newName = getUnicodeStringIfOriginalMatches(name,
originalNameBytes);
if (newName != null && !originalName.equals(newName)) {
ze.setName(newName);
}
if (commentBytes != null && commentBytes.length > 0) {
- UnicodeCommentExtraField cmt = (UnicodeCommentExtraField)
+ final UnicodeCommentExtraField cmt = (UnicodeCommentExtraField)
ze.getExtraField(UnicodeCommentExtraField.UCOM_ID);
- String newComment =
+ final String newComment =
getUnicodeStringIfOriginalMatches(cmt, commentBytes);
if (newComment != null) {
ze.setComment(newComment);
@@ -263,15 +263,15 @@ public abstract class ZipUtil {
String getUnicodeStringIfOriginalMatches(final AbstractUnicodeExtraField f,
final byte[] orig) {
if (f != null) {
- CRC32 crc32 = new CRC32();
+ final CRC32 crc32 = new CRC32();
crc32.update(orig);
- long origCRC32 = crc32.getValue();
+ final long origCRC32 = crc32.getValue();
if (origCRC32 == f.getNameCRC32()) {
try {
return ZipEncodingHelper
.UTF8_ZIP_ENCODING.decode(f.getUnicodeName());
- } catch (IOException ex) {
+ } catch (final IOException ex) {
// UTF-8 unsupported? should be impossible the
// Unicode*ExtraField must contain some bad bytes
@@ -289,7 +289,7 @@ public abstract class ZipUtil {
*/
static byte[] copy(final byte[] from) {
if (from != null) {
- byte[] to = new byte[from.length];
+ final byte[] to = new byte[from.length];
System.arraycopy(from, 0, to, 0, to.length);
return to;
}
@@ -345,7 +345,7 @@ public abstract class ZipUtil {
.Feature.ENCRYPTION, ze);
}
if (!supportsMethodOf(ze)) {
- ZipMethod m = ZipMethod.getMethodByCode(ze.getMethod());
+ final ZipMethod m = ZipMethod.getMethodByCode(ze.getMethod());
if (m == null) {
throw
new UnsupportedZipFeatureException(UnsupportedZipFeatureException
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/changes/ChangeSet.java b/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
index 7c899d0..c69c6de 100644
--- a/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
+++ b/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
@@ -97,11 +97,11 @@ public final class ChangeSet {
}
if (!changes.isEmpty()) {
- for (Iterator<Change> it = changes.iterator(); it.hasNext();) {
- Change change = it.next();
+ for (final Iterator<Change> it = changes.iterator(); it.hasNext();) {
+ final Change change = it.next();
if (change.type() == Change.TYPE_ADD
&& change.getEntry() != null) {
- ArchiveEntry entry = change.getEntry();
+ final ArchiveEntry entry = change.getEntry();
if(entry.equals(pChange.getEntry())) {
if(pChange.isReplaceMode()) {
@@ -130,14 +130,14 @@ public final class ChangeSet {
pChange.targetFile() == null) {
return;
}
- String source = pChange.targetFile();
+ final String source = pChange.targetFile();
if (source != null && !changes.isEmpty()) {
- for (Iterator<Change> it = changes.iterator(); it.hasNext();) {
- Change change = it.next();
+ for (final Iterator<Change> it = changes.iterator(); it.hasNext();) {
+ final Change change = it.next();
if (change.type() == Change.TYPE_ADD
&& change.getEntry() != null) {
- String target = change.getEntry().getName();
+ final String target = change.getEntry().getName();
if (target == null) {
continue;
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java b/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
index 46891d3..f3bac85 100644
--- a/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
+++ b/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
@@ -111,12 +111,12 @@ public class ChangeSetPerformer {
private ChangeSetResults perform(final ArchiveEntryIterator entryIterator,
final ArchiveOutputStream out)
throws IOException {
- ChangeSetResults results = new ChangeSetResults();
+ final ChangeSetResults results = new ChangeSetResults();
- Set<Change> workingSet = new LinkedHashSet<Change>(changes);
+ final Set<Change> workingSet = new LinkedHashSet<Change>(changes);
- for (Iterator<Change> it = workingSet.iterator(); it.hasNext();) {
- Change change = it.next();
+ for (final Iterator<Change> it = workingSet.iterator(); it.hasNext();) {
+ final Change change = it.next();
if (change.type() == Change.TYPE_ADD && change.isReplaceMode()) {
copyStream(change.getInput(), out, change.getEntry());
@@ -126,11 +126,11 @@ public class ChangeSetPerformer {
}
while (entryIterator.hasNext()) {
- ArchiveEntry entry = entryIterator.next();
+ final ArchiveEntry entry = entryIterator.next();
boolean copy = true;
- for (Iterator<Change> it = workingSet.iterator(); it.hasNext();) {
- Change change = it.next();
+ for (final Iterator<Change> it = workingSet.iterator(); it.hasNext();) {
+ final Change change = it.next();
final int type = change.type();
final String name = entry.getName();
@@ -160,8 +160,8 @@ public class ChangeSetPerformer {
}
// Adds files which hasn't been added from the original and do not have replace mode on
- for (Iterator<Change> it = workingSet.iterator(); it.hasNext();) {
- Change change = it.next();
+ for (final Iterator<Change> it = workingSet.iterator(); it.hasNext();) {
+ final Change change = it.next();
if (change.type() == Change.TYPE_ADD &&
!change.isReplaceMode() &&
@@ -185,12 +185,12 @@ public class ChangeSetPerformer {
* @return true, if this entry has an deletion change later, false otherwise
*/
private boolean isDeletedLater(final Set<Change> workingSet, final ArchiveEntry entry) {
- String source = entry.getName();
+ final String source = entry.getName();
if (!workingSet.isEmpty()) {
- for (Change change : workingSet) {
+ for (final Change change : workingSet) {
final int type = change.type();
- String target = change.targetFile();
+ final String target = change.targetFile();
if (type == Change.TYPE_DELETE && source.equals(target)) {
return true;
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java b/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
index 8f7e057..5a7160f 100644
--- a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
+++ b/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
@@ -214,7 +214,7 @@ public class CompressorStreamFactory {
final byte[] signature = new byte[12];
in.mark(signature.length);
try {
- int signatureLength = IOUtils.readFully(in, signature);
+ final int signatureLength = IOUtils.readFully(in, signature);
in.reset();
if (BZip2CompressorInputStream.matches(signature, signatureLength)) {
@@ -251,7 +251,7 @@ public class CompressorStreamFactory {
return new LZMACompressorInputStream(in);
}
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new CompressorException("Failed to detect Compressor from InputStream.", e);
}
@@ -315,7 +315,7 @@ public class CompressorStreamFactory {
return new DeflateCompressorInputStream(in);
}
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new CompressorException(
"Could not create CompressorInputStream.", e);
}
@@ -363,7 +363,7 @@ public class CompressorStreamFactory {
return new DeflateCompressorOutputStream(out);
}
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new CompressorException(
"Could not create CompressorOutputStream", e);
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java b/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
index 44735b5..22205d8 100644
--- a/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
+++ b/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
@@ -93,8 +93,8 @@ public class FileNameUtil {
this.uncompressSuffix = Collections.unmodifiableMap(uncompressSuffix);
int lc = Integer.MIN_VALUE, sc = Integer.MAX_VALUE;
int lu = Integer.MIN_VALUE, su = Integer.MAX_VALUE;
- for (Map.Entry<String, String> ent : uncompressSuffix.entrySet()) {
- int cl = ent.getKey().length();
+ for (final Map.Entry<String, String> ent : uncompressSuffix.entrySet()) {
+ final int cl = ent.getKey().length();
if (cl > lc) {
lc = cl;
}
@@ -102,8 +102,8 @@ public class FileNameUtil {
sc = cl;
}
- String u = ent.getValue();
- int ul = u.length();
+ final String u = ent.getValue();
+ final int ul = u.length();
if (ul > 0) {
if (!compressSuffix.containsKey(u)) {
compressSuffix.put(u, ent.getKey());
@@ -160,7 +160,7 @@ public class FileNameUtil {
final int n = lower.length();
for (int i = shortestCompressedSuffix;
i <= longestCompressedSuffix && i < n; i++) {
- String suffix = uncompressSuffix.get(lower.substring(n - i));
+ final String suffix = uncompressSuffix.get(lower.substring(n - i));
if (suffix != null) {
return filename.substring(0, n - i) + suffix;
}
@@ -184,7 +184,7 @@ public class FileNameUtil {
final int n = lower.length();
for (int i = shortestUncompressedSuffix;
i <= longestUncompressedSuffix && i < n; i++) {
- String suffix = compressSuffix.get(lower.substring(n - i));
+ final String suffix = compressSuffix.get(lower.substring(n - i));
if (suffix != null) {
return filename.substring(0, n - i) + suffix;
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
index 9c7938a..cb697ab 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
@@ -137,7 +137,7 @@ public class BZip2CompressorInputStream extends CompressorInputStream implements
@Override
public int read() throws IOException {
if (this.in != null) {
- int r = read0();
+ final int r = read0();
count(r < 0 ? -1 : 1);
return r;
}
@@ -177,7 +177,7 @@ public class BZip2CompressorInputStream extends CompressorInputStream implements
count(1);
}
- int c = (destOffs == offs) ? -1 : (destOffs - offs);
+ final int c = (destOffs == offs) ? -1 : (destOffs - offs);
return c;
}
@@ -232,12 +232,12 @@ public class BZip2CompressorInputStream extends CompressorInputStream implements
throw new IOException("No InputStream");
}
- int magic0 = this.in.read();
+ final int magic0 = this.in.read();
if (magic0 == -1 && !isFirstStream) {
return false;
}
- int magic1 = this.in.read();
- int magic2 = this.in.read();
+ final int magic1 = this.in.read();
+ final int magic2 = this.in.read();
if (magic0 != 'B' || magic1 != 'Z' || magic2 != 'h') {
throw new IOException(isFirstStream
@@ -245,7 +245,7 @@ public class BZip2CompressorInputStream extends CompressorInputStream implements
: "Garbage after a valid BZip2 stream");
}
- int blockSize = this.in.read();
+ final int blockSize = this.in.read();
if ((blockSize < '1') || (blockSize > '9')) {
throw new IOException("BZip2 block size is invalid");
}
@@ -352,7 +352,7 @@ public class BZip2CompressorInputStream extends CompressorInputStream implements
@Override
public void close() throws IOException {
- InputStream inShadow = this.in;
+ final InputStream inShadow = this.in;
if (inShadow != null) {
try {
if (inShadow != System.in) {
@@ -372,7 +372,7 @@ public class BZip2CompressorInputStream extends CompressorInputStream implements
if (bsLiveShadow < n) {
final InputStream inShadow = this.in;
do {
- int thech = inShadow.read();
+ final int thech = inShadow.read();
if (thech < 0) {
throw new IOException("unexpected end of stream");
@@ -835,7 +835,7 @@ public class BZip2CompressorInputStream extends CompressorInputStream implements
private int setupNoRandPartA() throws IOException {
if (this.su_i2 <= this.last) {
this.su_chPrev = this.su_ch2;
- int su_ch2Shadow = this.data.ll8[this.su_tPos] & 0xff;
+ final int su_ch2Shadow = this.data.ll8[this.su_tPos] & 0xff;
this.su_ch2 = su_ch2Shadow;
this.su_tPos = this.data.tt[this.su_tPos];
this.su_i2++;
@@ -905,7 +905,7 @@ public class BZip2CompressorInputStream extends CompressorInputStream implements
private int setupNoRandPartC() throws IOException {
if (this.su_j2 < this.su_z) {
- int su_ch2Shadow = this.su_ch2;
+ final int su_ch2Shadow = this.su_ch2;
this.crc.updateCRC(su_ch2Shadow);
this.su_j2++;
this.currentState = NO_RAND_PART_C_STATE;
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
index 315c6fe..9de51d4 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
@@ -168,7 +168,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
heap[nHeap] = i;
int zz = nHeap;
- int tmp = heap[zz];
+ final int tmp = heap[zz];
while (weight[tmp] < weight[heap[zz >> 1]]) {
heap[zz] = heap[zz >> 1];
zz >>= 1;
@@ -177,7 +177,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
}
while (nHeap > 1) {
- int n1 = heap[1];
+ final int n1 = heap[1];
heap[1] = heap[nHeap];
nHeap--;
@@ -207,7 +207,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
heap[zz] = tmp;
- int n2 = heap[1];
+ final int n2 = heap[1];
heap[1] = heap[nHeap];
nHeap--;
@@ -496,7 +496,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
@Override
public void close() throws IOException {
if (out != null) {
- OutputStream outShadow = this.out;
+ final OutputStream outShadow = this.out;
finish();
outShadow.close();
}
@@ -504,7 +504,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
@Override
public void flush() throws IOException {
- OutputStream outShadow = this.out;
+ final OutputStream outShadow = this.out;
if (outShadow != null) {
outShadow.flush();
}
@@ -537,7 +537,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
this.last = -1;
// ch = 0;
- boolean[] inUse = this.data.inUse;
+ final boolean[] inUse = this.data.inUse;
for (int i = 256; --i >= 0;) {
inUse[i] = false;
}
@@ -629,7 +629,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
throw new IOException("stream closed");
}
- for (int hi = offs + len; offs < hi;) {
+ for (final int hi = offs + len; offs < hi;) {
write0(buf[offs++]);
}
}
@@ -676,7 +676,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
private void bsFinishedWithStream() throws IOException {
while (this.bsLive > 0) {
- int ch = this.bsBuff >> 24;
+ final int ch = this.bsBuff >> 24;
this.out.write(ch); // write 8-bit
this.bsBuff <<= 8;
this.bsLive -= 8;
@@ -714,7 +714,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
final int alphaSize = this.nInUse + 2;
for (int t = N_GROUPS; --t >= 0;) {
- byte[] len_t = len[t];
+ final byte[] len_t = len[t];
for (int v = alphaSize; --v >= 0;) {
len_t[v] = GREATER_ICOST;
}
@@ -808,7 +808,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
for (int iter = 0; iter < N_ITERS; iter++) {
for (int t = nGroups; --t >= 0;) {
fave[t] = 0;
- int[] rfreqt = rfreq[t];
+ final int[] rfreqt = rfreq[t];
for (int i = alphaSize; --i >= 0;) {
rfreqt[i] = 0;
}
@@ -909,7 +909,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
// assert (nGroups < 8) : nGroups;
final Data dataShadow = this.data;
- byte[] pos = dataShadow.sendMTFValues2_pos;
+ final byte[] pos = dataShadow.sendMTFValues2_pos;
for (int i = nGroups; --i >= 0;) {
pos[i] = (byte) i;
@@ -922,7 +922,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
while (ll_i != tmp) {
j++;
- byte tmp2 = tmp;
+ final byte tmp2 = tmp;
tmp = pos[j];
pos[j] = tmp2;
}
@@ -933,8 +933,8 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
}
private void sendMTFValues3(final int nGroups, final int alphaSize) {
- int[][] code = this.data.sendMTFValues_code;
- byte[][] len = this.data.sendMTFValues_len;
+ final int[][] code = this.data.sendMTFValues_code;
+ final byte[][] len = this.data.sendMTFValues_len;
for (int t = 0; t < nGroups; t++) {
int minLen = 32;
@@ -1047,7 +1047,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
int bsBuffShadow = this.bsBuff;
for (int t = 0; t < nGroups; t++) {
- byte[] len_t = len[t];
+ final byte[] len_t = len[t];
int curr = len_t[0] & 0xff;
// inlined: bsW(5, curr);
@@ -1060,7 +1060,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
bsLiveShadow += 5;
for (int i = 0; i < alphaSize; i++) {
- int lti = len_t[i] & 0xff;
+ final int lti = len_t[i] & 0xff;
while (curr < lti) {
// inlined: bsW(2, 2);
while (bsLiveShadow >= 8) {
@@ -1207,7 +1207,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
while (ll_i != tmp) {
j++;
- byte tmp2 = tmp;
+ final byte tmp2 = tmp;
tmp = yy[j];
yy[j] = tmp2;
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java
index 2aed7e5..2a8c04f 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java
@@ -32,7 +32,7 @@ public abstract class BZip2Utils {
private static final FileNameUtil fileNameUtil;
static {
- Map<String, String> uncompressSuffix =
+ final Map<String, String> uncompressSuffix =
new LinkedHashMap<String, String>();
// backwards compatibilty: BZip2Utils never created the short
// tbz form, so .tar.bz2 has to be added explicitly
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java
index ffe77d4..63a3da3 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java
@@ -275,8 +275,8 @@ class BlockSort {
int j;
if (hi - lo > 3) {
for (int i = hi - 4; i >= lo; i--) {
- int tmp = fmap[i];
- int ec_tmp = eclass[tmp];
+ final int tmp = fmap[i];
+ final int ec_tmp = eclass[tmp];
for (j = i + 4; j <= hi && ec_tmp > eclass[fmap[j]];
j += 4) {
fmap[j - 4] = fmap[j];
@@ -286,8 +286,8 @@ class BlockSort {
}
for (int i = hi - 1; i >= lo; i--) {
- int tmp = fmap[i];
- int ec_tmp = eclass[tmp];
+ final int tmp = fmap[i];
+ final int ec_tmp = eclass[tmp];
for (j = i + 1; j <= hi && ec_tmp > eclass[fmap[j]]; j++) {
fmap[j - 1] = fmap[j];
}
@@ -301,7 +301,7 @@ class BlockSort {
* swaps two values in fmap
*/
private void fswap(final int[] fmap, final int zz1, final int zz2) {
- int zztmp = fmap[zz1];
+ final int zztmp = fmap[zz1];
fmap[zz1] = fmap[zz2];
fmap[zz2] = zztmp;
}
@@ -350,7 +350,7 @@ class BlockSort {
fpush(sp++, loSt, hiSt);
while (sp > 0) {
- int[] s = fpop(--sp);
+ final int[] s = fpop(--sp);
lo = s[0]; hi = s[1];
if (hi - lo < FALLBACK_QSORT_SMALL_THRESH) {
@@ -366,7 +366,8 @@ class BlockSort {
book, chapter 35.
*/
r = ((r * 7621) + 1) % 32768;
- long r3 = r % 3, med;
+ final long r3 = r % 3;
+ long med;
if (r3 == 0) {
med = eclass[fmap[lo]];
} else if (r3 == 1) {
@@ -496,7 +497,7 @@ class BlockSort {
}
nBhtab = 64 + nblock;
- BitSet bhtab = new BitSet(nBhtab);
+ final BitSet bhtab = new BitSet(nBhtab);
for (i = 0; i < 256; i++) {
bhtab.set(ftab[i]);
}
@@ -783,7 +784,7 @@ class BlockSort {
private static void vswap(final int[] fmap, int p1, int p2, int n) {
n += p1;
while (p1 < n) {
- int t = fmap[p1];
+ final int t = fmap[p1];
fmap[p1++] = fmap[p2];
fmap[p2++] = t;
}