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 2009/03/20 16:42:38 UTC
svn commit: r756536 - in /commons/proper/compress/trunk/src:
main/java/org/apache/commons/compress/archivers/cpio/
main/java/org/apache/commons/compress/archivers/tar/
main/java/org/apache/commons/compress/archivers/zip/
main/java/org/apache/commons/co...
Author: bodewig
Date: Fri Mar 20 15:42:37 2009
New Revision: 756536
URL: http://svn.apache.org/viewvc?rev=756536&view=rev
Log:
clean up protected/public API - SANDBOX-294 - a combination of patches by Sebb, Christian Grobmeier and discussion on the dev list http://mail-archives.apache.org/mod_mbox/commons-dev/200903.mbox/%3Cy1ufxhbifdo.fsf@v30161.1blu.de%3E
Added:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java (with props)
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java (with props)
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java (contents, props changed)
- copied, changed from r756455, commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStreamTest.java
Removed:
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStreamTest.java
Modified:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java?rev=756536&r1=756535&r2=756536&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java Fri Mar 20 15:42:37 2009
@@ -64,10 +64,12 @@
* pathname c_chksum 8 0 for "new" portable format; for CRC format the sum of
* all the bytes in the file
*
- * based on code from the jRPM project (jrpm.sourceforge.net)
+ * This class uses mutable fields and is not considered to be threadsafe.
+ *
+ * based on code from the jRPM project (jrpm.sourceforge.net)
*/
public class CpioArchiveEntry implements CpioConstants, ArchiveEntry {
-
+
private long chksum = 0;
private short fileFormat = -1;
@@ -99,13 +101,6 @@
private long uid = 0;
/**
- * Ceates a CPIOArchiveEntry without a cpio format.
- */
- public CpioArchiveEntry() {
- // do nothing
- }
-
- /**
* Ceates a CPIOArchiveEntry with a specified format.
*
* @param format
@@ -116,8 +111,8 @@
}
/**
- * Ceates a CPIOArchiveEntry with a specified name. The format of this entry will
- * be the new format.
+ * Ceates a CPIOArchiveEntry with a specified name. The format of this entry
+ * will be the new format.
*
* @param name
* The name of this entry.
@@ -128,20 +123,20 @@
}
/**
- * Ceates a CPIOArchiveEntry with a specified name. The format of this entry will
- * be the new format.
+ * Ceates a CPIOArchiveEntry with a specified name. The format of this entry
+ * will be the new format.
*
* @param name
* The name of this entry.
* @param size
- * The size of this entry
+ * The size of this entry
*/
public CpioArchiveEntry(final String name, final long size) {
this(FORMAT_NEW);
this.name = name;
this.setSize(size);
}
-
+
/**
* Check if the method is allowed for the defined format.
*/
@@ -175,7 +170,8 @@
*
* @return Returns the device id.
* @throws UnsupportedOperationException
- * if this method is called for a CPIOArchiveEntry with a new format.
+ * if this method is called for a CPIOArchiveEntry with a new
+ * format.
*/
public long getDevice() {
checkOldFormat();
@@ -187,7 +183,8 @@
*
* @return Returns the major device id.
* @throws UnsupportedOperationException
- * if this method is called for a CPIOArchiveEntry with an old format.
+ * if this method is called for a CPIOArchiveEntry with an old
+ * format.
*/
public long getDeviceMaj() {
checkNewFormat();
@@ -209,7 +206,9 @@
*
* @return Returns the filesize.
*/
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.commons.compress.archivers.ArchiveEntry#getSize()
*/
public long getSize() {
@@ -284,7 +283,8 @@
*
* @return Returns the remote device id.
* @throws UnsupportedOperationException
- * if this method is called for a CPIOArchiveEntry with a new format.
+ * if this method is called for a CPIOArchiveEntry with a new
+ * format.
*/
public long getRemoteDevice() {
checkOldFormat();
@@ -296,7 +296,8 @@
*
* @return Returns the remote major device id.
* @throws UnsupportedOperationException
- * if this method is called for a CPIOArchiveEntry with an old format.
+ * if this method is called for a CPIOArchiveEntry with an old
+ * format.
*/
public long getRemoteDeviceMaj() {
checkNewFormat();
@@ -308,7 +309,8 @@
*
* @return Returns the remote minor device id.
* @throws UnsupportedOperationException
- * if this method is called for a CPIOArchiveEntry with an old format.
+ * if this method is called for a CPIOArchiveEntry with an old
+ * format.
*/
public long getRemoteDeviceMin() {
checkNewFormat();
@@ -423,7 +425,8 @@
* @param device
* The device id to set.
* @throws UnsupportedOperationException
- * if this method is called for a CPIOArchiveEntry with a new format.
+ * if this method is called for a CPIOArchiveEntry with a new
+ * format.
*/
public void setDevice(final long device) {
checkOldFormat();
@@ -474,7 +477,7 @@
* @param format
* The format to set.
*/
- void setFormat(final short format) {
+ final void setFormat(final short format) {
switch (format) {
case FORMAT_NEW:
this.fileFormat = FORMAT_NEW;
@@ -536,10 +539,9 @@
break;
default:
// FIXME: testCpioUnarchive fails if I change the line to
- // actually throw the excpetion
- new IllegalArgumentException("Unknown mode (full mode: "
- + mode + ", masked mode: "
- + (mode & S_IFMT));
+ // actually throw the excpetion
+ new IllegalArgumentException("Unknown mode (full mode: " + mode
+ + ", masked mode: " + (mode & S_IFMT));
}
this.mode = mode;
@@ -571,7 +573,8 @@
* @param device
* The remote device id to set.
* @throws UnsupportedOperationException
- * if this method is called for a CPIOArchiveEntry with a new format.
+ * if this method is called for a CPIOArchiveEntry with a new
+ * format.
*/
public void setRemoteDevice(final long device) {
checkOldFormat();
@@ -584,7 +587,8 @@
* @param rmaj
* The remote major device id to set.
* @throws UnsupportedOperationException
- * if this method is called for a CPIOArchiveEntry with an old format.
+ * if this method is called for a CPIOArchiveEntry with an old
+ * format.
*/
public void setRemoteDeviceMaj(final long rmaj) {
checkNewFormat();
@@ -597,7 +601,8 @@
* @param rmin
* The remote minor device id to set.
* @throws UnsupportedOperationException
- * if this method is called for a CPIOArchiveEntry with an old format.
+ * if this method is called for a CPIOArchiveEntry with an old
+ * format.
*/
public void setRemoteDeviceMin(final long rmin) {
checkNewFormat();
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java?rev=756536&r1=756535&r2=756536&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java Fri Mar 20 15:42:37 2009
@@ -26,9 +26,9 @@
import org.apache.commons.compress.archivers.ArchiveInputStream;
/**
- * CPIOArchiveInputStream is a stream for reading cpio streams. All formats of cpio are
- * supported (old ascii, old binary, new portable format and the new portable
- * format with crc).
+ * CPIOArchiveInputStream is a stream for reading cpio streams. All formats of
+ * cpio are supported (old ascii, old binary, new portable format and the new
+ * portable format with crc).
* <p/>
* <p/>
* The stream can be read by extracting a cpio entry (containing all
@@ -54,10 +54,13 @@
* <p/>
* Note: This implementation should be compatible to cpio 2.5
*
- * based on code from the jRPM project (jrpm.sourceforge.net)
+ * This class uses mutable fields and is not considered to be threadsafe.
+ *
+ * based on code from the jRPM project (jrpm.sourceforge.net)
*/
-public class CpioArchiveInputStream extends ArchiveInputStream implements CpioConstants {
+public class CpioArchiveInputStream extends ArchiveInputStream implements
+ CpioConstants {
private boolean closed = false;
@@ -67,9 +70,9 @@
private boolean entryEOF = false;
- private byte[] singleByteBuf = new byte[1];
+ private final byte[] singleByteBuf = new byte[1];
- private byte tmpbuf[] = new byte[4096];
+ private final byte tmpbuf[] = new byte[4096];
private long crc = 0;
@@ -77,8 +80,9 @@
/**
* Construct the cpio input stream
- *
- * @param in The cpio stream
+ *
+ * @param in
+ * The cpio stream
*/
public CpioArchiveInputStream(final InputStream in) {
this.in = in;
@@ -90,10 +94,11 @@
* <p/>
* Programs should not count on this method to return the actual number of
* bytes that could be read without blocking.
- *
+ *
* @return 1 before EOF and 0 after EOF has reached for current entry.
- * @throws IOException if an I/O error has occurred or if a CPIO file error has
- * occurred
+ * @throws IOException
+ * if an I/O error has occurred or if a CPIO file error has
+ * occurred
*/
public int available() throws IOException {
ensureOpen();
@@ -104,44 +109,10 @@
}
/**
- * Converts a byte array to a long. Halfwords can be swaped with setting
- * swapHalfWord=true.
- *
- * @param number An array of bytes containing a number
- * @param swapHalfWord Swap halfwords ([0][1][2][3]->[1][0][3][2])
- * @return The long value
- */
- private long byteArray2long(final byte[] number, final boolean swapHalfWord) {
- long ret = 0;
- int pos = 0;
- byte tmp_number[] = new byte[number.length];
- System.arraycopy(number, 0, tmp_number, 0, number.length);
-
- if (tmp_number.length % 2 != 0) {
- throw new UnsupportedOperationException();
- }
-
- if (!swapHalfWord) {
- byte tmp = 0;
- for (pos = 0; pos < tmp_number.length; pos++) {
- tmp = tmp_number[pos];
- tmp_number[pos++] = tmp_number[pos];
- tmp_number[pos] = tmp;
- }
- }
-
- ret = tmp_number[0] & 0xFF;
- for (pos = 1; pos < tmp_number.length; pos++) {
- ret <<= 8;
- ret |= tmp_number[pos] & 0xFF;
- }
- return ret;
- }
-
- /**
* Closes the CPIO input stream.
- *
- * @throws IOException if an I/O error has occurred
+ *
+ * @throws IOException
+ * if an I/O error has occurred
*/
public void close() throws IOException {
if (!this.closed) {
@@ -153,9 +124,10 @@
/**
* Closes the current CPIO entry and positions the stream for reading the
* next entry.
- *
- * @throws IOException if an I/O error has occurred or if a CPIO file error has
- * occurred
+ *
+ * @throws IOException
+ * if an I/O error has occurred or if a CPIO file error has
+ * occurred
*/
public void closeEntry() throws IOException {
ensureOpen();
@@ -168,8 +140,9 @@
/**
* Check to make sure that this stream has not been closed
- *
- * @throws IOException if the stream is already closed
+ *
+ * @throws IOException
+ * if the stream is already closed
*/
private void ensureOpen() throws IOException {
if (this.closed) {
@@ -180,10 +153,11 @@
/**
* Reads the next CPIO file entry and positions stream at the beginning of
* the entry data.
- *
+ *
* @return the CPIOArchiveEntry just read
- * @throws IOException if an I/O error has occurred or if a CPIO file error has
- * occurred
+ * @throws IOException
+ * if an I/O error has occurred or if a CPIO file error has
+ * occurred
*/
public CpioArchiveEntry getNextCPIOEntry() throws IOException {
ensureOpen();
@@ -192,9 +166,9 @@
}
byte magic[] = new byte[2];
readFully(magic, 0, magic.length);
- if (byteArray2long(magic, false) == MAGIC_OLD_BINARY) {
+ if (CpioUtil.byteArray2long(magic, false) == MAGIC_OLD_BINARY) {
this.entry = readOldBinaryEntry(false);
- } else if (byteArray2long(magic, true) == MAGIC_OLD_BINARY) {
+ } else if (CpioUtil.byteArray2long(magic, true) == MAGIC_OLD_BINARY) {
this.entry = readOldBinaryEntry(true);
} else {
byte more_magic[] = new byte[4];
@@ -202,7 +176,7 @@
byte tmp[] = new byte[6];
System.arraycopy(magic, 0, tmp, 0, magic.length);
System.arraycopy(more_magic, 0, tmp, magic.length,
- more_magic.length);
+ more_magic.length);
String magicString = new String(tmp);
if (magicString.equals(MAGIC_NEW)) {
this.entry = readNewEntry(false);
@@ -237,30 +211,35 @@
/**
* Reads a byte of data. This method will block until enough input is
* available.
- *
+ *
* @return the byte read, or -1 if end of input is reached
- * @throws IOException if an I/O error has occurred or if a CPIO file error has
- * occurred
+ * @throws IOException
+ * if an I/O error has occurred or if a CPIO file error has
+ * occurred
*/
public int read() throws IOException {
return read(this.singleByteBuf, 0, 1) == -1 ? -1
- : this.singleByteBuf[0] & 0xff;
+ : this.singleByteBuf[0] & 0xff;
}
/**
* Reads from the current CPIO entry into an array of bytes. Blocks until
* some input is available.
- *
- * @param b the buffer into which the data is read
- * @param off the start offset of the data
- * @param len the maximum number of bytes read
+ *
+ * @param b
+ * the buffer into which the data is read
+ * @param off
+ * the start offset of the data
+ * @param len
+ * the maximum number of bytes read
* @return the actual number of bytes read, or -1 if the end of the entry is
* reached
- * @throws IOException if an I/O error has occurred or if a CPIO file error has
- * occurred
+ * @throws IOException
+ * if an I/O error has occurred or if a CPIO file error has
+ * occurred
*/
public int read(final byte[] b, final int off, final int len)
- throws IOException {
+ throws IOException {
ensureOpen();
if (off < 0 || len < 0 || off > b.length - len) {
throw new IndexOutOfBoundsException();
@@ -286,7 +265,7 @@
return -1;
}
int tmplength = (int) Math.min(len, this.entry.getSize()
- - this.entryBytesRead);
+ - this.entryBytesRead);
if (tmplength < 0) {
return -1;
}
@@ -303,7 +282,7 @@
}
private final int readFully(final byte[] b, final int off, final int len)
- throws IOException {
+ throws IOException {
if (len < 0) {
throw new IndexOutOfBoundsException();
}
@@ -319,20 +298,21 @@
}
private long readBinaryLong(final int length, final boolean swapHalfWord)
- throws IOException {
+ throws IOException {
byte tmp[] = new byte[length];
readFully(tmp, 0, tmp.length);
- return byteArray2long(tmp, swapHalfWord);
+ return CpioUtil.byteArray2long(tmp, swapHalfWord);
}
private long readAsciiLong(final int length, final int radix)
- throws IOException {
+ throws IOException {
byte tmpBuffer[] = new byte[length];
readFully(tmpBuffer, 0, tmpBuffer.length);
return Long.parseLong(new String(tmpBuffer), radix);
}
- private CpioArchiveEntry readNewEntry(final boolean hasCrc) throws IOException {
+ private CpioArchiveEntry readNewEntry(final boolean hasCrc)
+ throws IOException {
CpioArchiveEntry ret;
if (hasCrc) {
ret = new CpioArchiveEntry(FORMAT_NEW_CRC);
@@ -378,7 +358,7 @@
}
private CpioArchiveEntry readOldBinaryEntry(final boolean swapHalfWord)
- throws IOException {
+ throws IOException {
CpioArchiveEntry ret = new CpioArchiveEntry(FORMAT_OLD_BINARY);
ret.setDevice(readBinaryLong(2, swapHalfWord));
@@ -405,11 +385,14 @@
/**
* Skips specified number of bytes in the current CPIO entry.
- *
- * @param n the number of bytes to skip
+ *
+ * @param n
+ * the number of bytes to skip
* @return the actual number of bytes skipped
- * @throws IOException if an I/O error has occurred
- * @throws IllegalArgumentException if n < 0
+ * @throws IOException
+ * if an I/O error has occurred
+ * @throws IllegalArgumentException
+ * if n < 0
*/
public long skip(final long n) throws IOException {
if (n < 0) {
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java?rev=756536&r1=756535&r2=756536&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java Fri Mar 20 15:42:37 2009
@@ -27,15 +27,15 @@
import org.apache.commons.compress.archivers.ArchiveOutputStream;
/**
- * CPIOArchiveOutputStream is a stream for writting cpio streams. All formats of cpio
- * are supported (old ascii, old binary, new portable format and the new
+ * CPIOArchiveOutputStream is a stream for writting cpio streams. All formats of
+ * cpio are supported (old ascii, old binary, new portable format and the new
* portable format with crc).
* <p/>
* <p/>
- * An entry can be written by creating an instance of CPIOArchiveEntry and fill it with
- * the necessary values and put it into the cpio stream. Afterwards write the
- * contents of the file into the cpio stream. Either close the stream by calling
- * finish() or put a next entry into the cpio stream.
+ * An entry can be written by creating an instance of CPIOArchiveEntry and fill
+ * it with the necessary values and put it into the cpio stream. Afterwards
+ * write the contents of the file into the cpio stream. Either close the stream
+ * by calling finish() or put a next entry into the cpio stream.
* <p/>
* <code><pre>
* CPIOArchiveOutputStream cpioOut = new CPIOArchiveOutputStream(new BufferedOutputStream(
@@ -51,10 +51,13 @@
* </pre></code>
* <p/>
* Note: This implementation should be compatible to cpio 2.5
- *
- * based on code from the jRPM project (jrpm.sourceforge.net)
+ *
+ * This class uses mutable fields and is not considered threadsafe.
+ *
+ * based on code from the jRPM project (jrpm.sourceforge.net)
*/
-public class CpioArchiveOutputStream extends ArchiveOutputStream implements CpioConstants {
+public class CpioArchiveOutputStream extends ArchiveOutputStream implements
+ CpioConstants {
private CpioArchiveEntry cpioEntry;
@@ -64,7 +67,7 @@
private short entryFormat = FORMAT_NEW;
- private HashMap names = new HashMap();
+ private final HashMap names = new HashMap();
private long crc = 0;
@@ -73,21 +76,12 @@
private final OutputStream out;
/**
- * Check to make sure that this stream has not been closed
- *
- * @throws IOException if the stream is already closed
- */
- private void ensureOpen() throws IOException {
- if (this.closed) {
- throw new IOException("Stream closed");
- }
- }
-
- /**
* Construct the cpio output stream with a specified format
- *
- * @param out The cpio stream
- * @param format The format of the stream
+ *
+ * @param out
+ * The cpio stream
+ * @param format
+ * The format of the stream
*/
public CpioArchiveOutputStream(final OutputStream out, final short format) {
this.out = new FilterOutputStream(out);
@@ -97,20 +91,34 @@
/**
* Construct the cpio output stream. The format for this CPIO stream is the
* "new" format
- *
- * @param out The cpio stream
+ *
+ * @param out
+ * The cpio stream
*/
public CpioArchiveOutputStream(final OutputStream out) {
this(out, FORMAT_NEW);
}
/**
+ * Check to make sure that this stream has not been closed
+ *
+ * @throws IOException
+ * if the stream is already closed
+ */
+ private void ensureOpen() throws IOException {
+ if (this.closed) {
+ throw new IOException("Stream closed");
+ }
+ }
+
+ /**
* Set a default header format. This will be used if no format is defined in
* the cpioEntry given to putNextEntry().
- *
- * @param format A CPIO format
+ *
+ * @param format
+ * A CPIO format
*/
- public void setFormat(final short format) {
+ private void setFormat(final short format) {
switch (format) {
case FORMAT_NEW:
case FORMAT_NEW_CRC:
@@ -132,12 +140,14 @@
* current time will be used if the entry has no set modification time and
* the default header format will be used if no other format is specified in
* the entry.
- *
- * @param e the CPIO cpioEntry to be written
- * @throws IOException if an I/O error has occurred or if a CPIO file error has
- * occurred
+ *
+ * @param e
+ * the CPIO cpioEntry to be written
+ * @throws IOException
+ * if an I/O error has occurred or if a CPIO file error has
+ * occurred
*/
- public synchronized void putNextEntry(final CpioArchiveEntry e) throws IOException {
+ public void putNextEntry(final CpioArchiveEntry e) throws IOException {
ensureOpen();
if (this.cpioEntry != null) {
closeEntry(); // close previous entry
@@ -145,6 +155,9 @@
if (e.getTime() == -1) {
e.setTime(System.currentTimeMillis());
}
+
+ // TODO what happens if an entry has an other format than the
+ // outputstream?
if (e.getFormat() == -1) {
e.setFormat(this.entryFormat);
}
@@ -198,7 +211,8 @@
pad(entry.getHeaderSize() + entry.getName().length() + 1, 4);
}
- private void writeOldAsciiEntry(final CpioArchiveEntry entry) throws IOException {
+ private void writeOldAsciiEntry(final CpioArchiveEntry entry)
+ throws IOException {
writeAsciiLong(entry.getDevice(), 6, 8);
writeAsciiLong(entry.getInode(), 6, 8);
writeAsciiLong(entry.getMode(), 6, 8);
@@ -213,7 +227,7 @@
}
private void writeOldBinaryEntry(final CpioArchiveEntry entry,
- final boolean swapHalfWord) throws IOException {
+ final boolean swapHalfWord) throws IOException {
writeBinaryLong(entry.getDevice(), 2, swapHalfWord);
writeBinaryLong(entry.getInode(), 2, swapHalfWord);
writeBinaryLong(entry.getMode(), 2, swapHalfWord);
@@ -231,17 +245,18 @@
/**
* Closes the current CPIO entry and positions the stream for writing the
* next entry.
- *
- * @throws IOException if an I/O error has occurred or if a CPIO file error has
- * occurred
+ *
+ * @throws IOException
+ * if an I/O error has occurred or if a CPIO file error has
+ * occurred
*/
- public synchronized void closeEntry() throws IOException {
+ public void closeEntry() throws IOException {
ensureOpen();
if (this.cpioEntry.getSize() != this.written) {
throw new IOException("invalid entry size (expected "
- + this.cpioEntry.getSize() + " but got " + this.written
- + " bytes)");
+ + this.cpioEntry.getSize() + " but got " + this.written
+ + " bytes)");
}
if ((this.cpioEntry.getFormat() | FORMAT_NEW_MASK) == FORMAT_NEW_MASK) {
pad(this.cpioEntry.getSize(), 4);
@@ -261,15 +276,19 @@
/**
* Writes an array of bytes to the current CPIO entry data. This method will
* block until all the bytes are written.
- *
- * @param b the data to be written
- * @param off the start offset in the data
- * @param len the number of bytes that are written
- * @throws IOException if an I/O error has occurred or if a CPIO file error has
- * occurred
+ *
+ * @param b
+ * the data to be written
+ * @param off
+ * the start offset in the data
+ * @param len
+ * the number of bytes that are written
+ * @throws IOException
+ * if an I/O error has occurred or if a CPIO file error has
+ * occurred
*/
public synchronized void write(final byte[] b, final int off, final int len)
- throws IOException {
+ throws IOException {
ensureOpen();
if (off < 0 || len < 0 || off > b.length - len) {
throw new IndexOutOfBoundsException();
@@ -296,13 +315,14 @@
* Finishes writing the contents of the CPIO output stream without closing
* the underlying stream. Use this method when applying multiple filters in
* succession to the same output stream.
- *
- * @throws IOException if an I/O exception has occurred or if a CPIO file error
- * has occurred
+ *
+ * @throws IOException
+ * if an I/O exception has occurred or if a CPIO file error has
+ * occurred
*/
- public synchronized void finish() throws IOException {
+ public void finish() throws IOException {
ensureOpen();
- // TODO: synchronize and finish
+
if (this.finished) {
return;
}
@@ -319,9 +339,10 @@
/**
* Closes the CPIO output stream as well as the stream being filtered.
- *
- * @throws IOException if an I/O error has occurred or if a CPIO file error has
- * occurred
+ *
+ * @throws IOException
+ * if an I/O error has occurred or if a CPIO file error has
+ * occurred
*/
public void close() throws IOException {
if (!this.closed) {
@@ -339,13 +360,13 @@
}
private void writeBinaryLong(final long number, final int length,
- final boolean swapHalfWord) throws IOException {
- byte tmp[] = long2byteArray(number, length, swapHalfWord);
+ final boolean swapHalfWord) throws IOException {
+ byte tmp[] = CpioUtil.long2byteArray(number, length, swapHalfWord);
out.write(tmp);
}
private void writeAsciiLong(final long number, final int length,
- final int radix) throws IOException {
+ final int radix) throws IOException {
StringBuffer tmp = new StringBuffer();
String tmpStr;
if (radix == 16) {
@@ -373,58 +394,31 @@
out.write('\0');
}
- /**
- * Converts a byte array to a long. Halfwords can be swaped with setting
- * swapHalfWord=true.
- *
- * @param number An array of bytes containing a number
- * @param length The length of the returned array
- * @param swapHalfWord Swap halfwords ([0][1][2][3]->[1][0][3][2])
- * @return The long value
- */
- private static byte[] long2byteArray(final long number, final int length,
- final boolean swapHalfWord) {
- byte[] ret = new byte[length];
- int pos = 0;
- long tmp_number = 0;
-
- if (length % 2 != 0 || length < 2) {
- throw new UnsupportedOperationException();
- }
-
- tmp_number = number;
- for (pos = length - 1; pos >= 0; pos--) {
- ret[pos] = (byte) (tmp_number & 0xFF);
- tmp_number >>= 8;
- }
-
- if (!swapHalfWord) {
- byte tmp = 0;
- for (pos = 0; pos < length; pos++) {
- tmp = ret[pos];
- ret[pos++] = ret[pos];
- ret[pos] = tmp;
- }
- }
-
- return ret;
- }
-
- /* (non-Javadoc)
- * @see org.apache.commons.compress.archivers.ArchiveOutputStream#closeArchiveEntry()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.commons.compress.archivers.ArchiveOutputStream#closeArchiveEntry
+ * ()
*/
public void closeArchiveEntry() throws IOException {
this.closeEntry();
}
- /* (non-Javadoc)
- * @see org.apache.commons.compress.archivers.ArchiveOutputStream#putArchiveEntry(org.apache.commons.compress.archivers.ArchiveEntry)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.commons.compress.archivers.ArchiveOutputStream#putArchiveEntry
+ * (org.apache.commons.compress.archivers.ArchiveEntry)
*/
public void putArchiveEntry(ArchiveEntry entry) throws IOException {
- this.putNextEntry((CpioArchiveEntry)entry);
+ this.putNextEntry((CpioArchiveEntry) entry);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see java.io.OutputStream#write(int)
*/
public void write(int b) throws IOException {
Added: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java?rev=756536&view=auto
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java (added)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java Fri Mar 20 15:42:37 2009
@@ -0,0 +1,80 @@
+package org.apache.commons.compress.archivers.cpio;
+
+class CpioUtil {
+ /**
+ * Converts a byte array to a long. Halfwords can be swaped with setting
+ * swapHalfWord=true.
+ *
+ * @param number
+ * An array of bytes containing a number
+ * @param swapHalfWord
+ * Swap halfwords ([0][1][2][3]->[1][0][3][2])
+ * @return The long value
+ */
+ static long byteArray2long(final byte[] number, final boolean swapHalfWord) {
+ long ret = 0;
+ int pos = 0;
+ byte tmp_number[] = new byte[number.length];
+ System.arraycopy(number, 0, tmp_number, 0, number.length);
+
+ if (tmp_number.length % 2 != 0) {
+ throw new UnsupportedOperationException();
+ }
+
+ if (!swapHalfWord) {
+ byte tmp = 0;
+ for (pos = 0; pos < tmp_number.length; pos++) {
+ tmp = tmp_number[pos];
+ tmp_number[pos++] = tmp_number[pos];
+ tmp_number[pos] = tmp;
+ }
+ }
+
+ ret = tmp_number[0] & 0xFF;
+ for (pos = 1; pos < tmp_number.length; pos++) {
+ ret <<= 8;
+ ret |= tmp_number[pos] & 0xFF;
+ }
+ return ret;
+ }
+
+ /**
+ * Converts a byte array to a long. Halfwords can be swaped with setting
+ * swapHalfWord=true.
+ *
+ * @param number
+ * An array of bytes containing a number
+ * @param length
+ * The length of the returned array
+ * @param swapHalfWord
+ * Swap halfwords ([0][1][2][3]->[1][0][3][2])
+ * @return The long value
+ */
+ static byte[] long2byteArray(final long number, final int length,
+ final boolean swapHalfWord) {
+ byte[] ret = new byte[length];
+ int pos = 0;
+ long tmp_number = 0;
+
+ if (length % 2 != 0 || length < 2) {
+ throw new UnsupportedOperationException();
+ }
+
+ tmp_number = number;
+ for (pos = length - 1; pos >= 0; pos--) {
+ ret[pos] = (byte) (tmp_number & 0xFF);
+ tmp_number >>= 8;
+ }
+
+ if (!swapHalfWord) {
+ byte tmp = 0;
+ for (pos = 0; pos < length; pos++) {
+ tmp = ret[pos];
+ ret[pos++] = ret[pos];
+ ret[pos] = tmp;
+ }
+ }
+
+ return ret;
+ }
+}
Propchange: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=756536&r1=756535&r2=756536&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java Fri Mar 20 15:42:37 2009
@@ -42,25 +42,20 @@
private static final int LARGE_BUFFER_SIZE = 32 * 1024;
private static final int BYTE_MASK = 0xFF;
- // CheckStyle:VisibilityModifier OFF - bc
- protected boolean debug;
- protected boolean hasHitEOF;
- protected long entrySize;
- protected long entryOffset;
- protected byte[] readBuf;
- protected TarBuffer buffer;
- protected TarArchiveEntry currEntry;
+ private boolean debug;
+ private boolean hasHitEOF;
+ private long entrySize;
+ private long entryOffset;
+ private byte[] readBuf;
+ protected final TarBuffer buffer;
+ private TarArchiveEntry currEntry;
/**
* This contents of this array is not used at all in this class,
- * it is only here to avoid repreated object creation during calls
+ * it is only here to avoid repeated object creation during calls
* to the no-arg read method.
*/
- protected byte[] oneBuf;
-
- // CheckStyle:VisibilityModifier ON
-
- private final InputStream in;
+ private final byte[] oneBuf;
/**
* Constructor for TarInputStream.
@@ -86,8 +81,6 @@
* @param recordSize the record size to use
*/
public TarArchiveInputStream(InputStream is, int blockSize, int recordSize) {
- this.in = is;
-
this.buffer = new TarBuffer(is, blockSize, recordSize);
this.readBuf = null;
this.oneBuf = new byte[1];
@@ -390,6 +383,23 @@
}
}
+ protected final TarArchiveEntry getCurrentEntry() {
+ return currEntry;
+ }
+
+ protected final void setCurrentEntry(TarArchiveEntry e) {
+ currEntry = e;
+ }
+
+ protected final boolean isAtEOF() {
+ return hasHitEOF;
+ }
+
+ protected final void setAtEOF(boolean b) {
+ hasHitEOF = b;
+ }
+
+
// used to be implemented via FilterInputStream
public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java?rev=756536&r1=756535&r2=756536&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java Fri Mar 20 15:42:37 2009
@@ -39,18 +39,16 @@
/** GNU tar extensions are used to store long file names in the archive. */
public static final int LONGFILE_GNU = 2;
- // CheckStyle:VisibilityModifier OFF - bc
- protected boolean debug;
- protected long currSize;
- protected String currName;
- protected long currBytes;
- protected byte[] oneBuf;
- protected byte[] recordBuf;
- protected int assemLen;
- protected byte[] assemBuf;
- protected TarBuffer buffer;
- protected int longFileMode = LONGFILE_ERROR;
- // CheckStyle:VisibilityModifier ON
+ private boolean debug;// NOT READ
+ private long currSize;
+ private String currName;
+ private long currBytes;
+ private final byte[] oneBuf;
+ private final byte[] recordBuf;
+ private int assemLen;
+ private final byte[] assemBuf;
+ protected final TarBuffer buffer;
+ private int longFileMode = LONGFILE_ERROR;
private boolean closed = false;
@@ -368,11 +366,6 @@
return "tar";
}
- public byte[] getHeader() {
- // TODO Auto-generated method stub
- return null;
- }
-
public String getName() {
return "tar";
}
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=756536&r1=756535&r2=756536&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Fri Mar 20 15:42:37 2009
@@ -192,29 +192,17 @@
private ZipEncoding zipEncoding =
ZipEncodingHelper.getZipEncoding(DEFAULT_ENCODING);
- // CheckStyle:VisibilityModifier OFF - bc
-
/**
* This Deflater object is used for output.
*
- * <p>This attribute is only protected to provide a level of API
- * backwards compatibility. This class used to extend {@link
- * java.util.zip.DeflaterOutputStream DeflaterOutputStream} up to
- * Revision 1.13.</p>
*/
- protected Deflater def = new Deflater(level, true);
+ protected final Deflater def = new Deflater(level, true);
/**
* This buffer servers as a Deflater.
*
- * <p>This attribute is only protected to provide a level of API
- * backwards compatibility. This class used to extend {@link
- * java.util.zip.DeflaterOutputStream DeflaterOutputStream} up to
- * Revision 1.13.</p>
*/
- protected byte[] buf = new byte[BUFFER_SIZE];
-
- // CheckStyle:VisibilityModifier ON
+ private final byte[] buf = new byte[BUFFER_SIZE];
/**
* Optional random access output.
@@ -376,8 +364,8 @@
deflate();
}
- entry.setSize(adjustToLong(def.getTotalIn()));
- entry.setCompressedSize(adjustToLong(def.getTotalOut()));
+ entry.setSize(ZipUtil.adjustToLong(def.getTotalIn()));
+ entry.setCompressedSize(ZipUtil.adjustToLong(def.getTotalOut()));
entry.setCrc(realCrc);
def.reset();
@@ -688,7 +676,7 @@
written += SHORT;
// last mod. time and date
- writeOut(toDosTime(ze.getTime()));
+ writeOut(ZipUtil.toDosTime(ze.getTime()));
written += WORD;
// CRC
@@ -772,7 +760,7 @@
written += SHORT;
// last mod. time and date
- writeOut(toDosTime(ze.getTime()));
+ writeOut(ZipUtil.toDosTime(ze.getTime()));
written += WORD;
// CRC
@@ -871,46 +859,6 @@
}
/**
- * Smallest date/time ZIP can handle.
- */
- private static final byte[] DOS_TIME_MIN = ZipLong.getBytes(0x00002100L);
-
- /**
- * Convert a Date object to a DOS date/time field.
- * @param time the <code>Date</code> to convert
- * @return the date as a <code>ZipLong</code>
- */
- protected static ZipLong toDosTime(Date time) {
- return new ZipLong(toDosTime(time.getTime()));
- }
-
- /**
- * Convert a Date object to a DOS date/time field.
- *
- * <p>Stolen from InfoZip's <code>fileio.c</code></p>
- * @param t number of milliseconds since the epoch
- * @return the date as a byte array
- */
- protected static byte[] toDosTime(long t) {
- Date time = new Date(t);
- // CheckStyle:MagicNumberCheck OFF - I do not think that using constants
- // here will improve the readablity
- int year = time.getYear() + 1900;
- if (year < 1980) {
- return DOS_TIME_MIN;
- }
- int month = time.getMonth() + 1;
- long value = ((year - 1980) << 25)
- | (month << 21)
- | (time.getDate() << 16)
- | (time.getHours() << 11)
- | (time.getMinutes() << 5)
- | (time.getSeconds() >> 1);
- return ZipLong.getBytes(value);
- // CheckStyle:MagicNumberCheck ON
- }
-
- /**
* Write bytes to output or random access file.
* @param data the byte array to write
* @throws IOException on error
@@ -935,20 +883,6 @@
}
}
- /**
- * Assumes a negative integer really is a positive integer that
- * has wrapped around and re-creates the original value.
- * @param i the value to treat as unsigned int.
- * @return the unsigned int as a long.
- */
- protected static long adjustToLong(int i) {
- if (i < 0) {
- return 2 * ((long) Integer.MAX_VALUE) + 2 + i;
- } else {
- return i;
- }
- }
-
private void deflateUntilInputIsNeeded() throws IOException {
while (!def.needsInput()) {
deflate();
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=756536&r1=756535&r2=756536&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java Fri Mar 20 15:42:37 2009
@@ -346,7 +346,7 @@
// FIXME this is actually not very cpu cycles friendly as we are converting from
// dos to java while the underlying Sun implementation will convert
// from java to dos time for internal storage...
- long time = dosToJavaTime(ZipLong.getValue(cfh, off));
+ long time = ZipUtil.dosToJavaTime(ZipLong.getValue(cfh, off));
ze.setTime(time);
off += WORD;
@@ -539,34 +539,6 @@
}
/**
- * Convert a DOS date/time field to a Date object.
- *
- * @param zipDosTime contains the stored DOS time.
- * @return a Date instance corresponding to the given time.
- */
- protected static Date fromDosTime(ZipLong zipDosTime) {
- long dosTime = zipDosTime.getValue();
- return new Date(dosToJavaTime(dosTime));
- }
-
- /*
- * Converts DOS time to Java time (number of milliseconds since epoch).
- */
- private static long dosToJavaTime(long dosTime) {
- 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);
- cal.set(Calendar.DATE, (int) (dosTime >> 16) & 0x1f);
- cal.set(Calendar.HOUR_OF_DAY, (int) (dosTime >> 11) & 0x1f);
- cal.set(Calendar.MINUTE, (int) (dosTime >> 5) & 0x3f);
- cal.set(Calendar.SECOND, (int) (dosTime << 1) & 0x3e);
- // CheckStyle:MagicNumberCheck ON
- return cal.getTime().getTime();
- }
-
-
- /**
* Checks whether the archive starts with a LFH. If it doesn't,
* it may be an empty archive.
*/
Added: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java?rev=756536&view=auto
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java (added)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java Fri Mar 20 15:42:37 2009
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.
+ *
+ */
+package org.apache.commons.compress.archivers.zip;
+
+import java.util.Calendar;
+import java.util.Date;
+
+public abstract class ZipUtil {
+ /**
+ * Smallest date/time ZIP can handle.
+ */
+ private static final byte[] DOS_TIME_MIN = ZipLong.getBytes(0x00002100L);
+
+ /**
+ * Convert a Date object to a DOS date/time field.
+ * @param time the <code>Date</code> to convert
+ * @return the date as a <code>ZipLong</code>
+ */
+ public static ZipLong toDosTime(Date time) {
+ return new ZipLong(toDosTime(time.getTime()));
+ }
+
+ /**
+ * Convert a Date object to a DOS date/time field.
+ *
+ * <p>Stolen from InfoZip's <code>fileio.c</code></p>
+ * @param t number of milliseconds since the epoch
+ * @return the date as a byte array
+ */
+ public static byte[] toDosTime(long t) {
+ Date time = new Date(t);
+ // CheckStyle:MagicNumberCheck OFF - I do not think that using constants
+ // here will improve the readablity
+ int year = time.getYear() + 1900;
+ if (year < 1980) {
+ return DOS_TIME_MIN;
+ }
+ int month = time.getMonth() + 1;
+ long value = ((year - 1980) << 25)
+ | (month << 21)
+ | (time.getDate() << 16)
+ | (time.getHours() << 11)
+ | (time.getMinutes() << 5)
+ | (time.getSeconds() >> 1);
+ return ZipLong.getBytes(value);
+ // CheckStyle:MagicNumberCheck ON
+ }
+
+ /**
+ * Assumes a negative integer really is a positive integer that
+ * has wrapped around and re-creates the original value.
+ * @param i the value to treat as unsigned int.
+ * @return the unsigned int as a long.
+ */
+ public static long adjustToLong(int i) {
+ if (i < 0) {
+ return 2 * ((long) Integer.MAX_VALUE) + 2 + i;
+ } else {
+ return i;
+ }
+ }
+
+ /**
+ * Convert a DOS date/time field to a Date object.
+ *
+ * @param zipDosTime contains the stored DOS time.
+ * @return a Date instance corresponding to the given time.
+ */
+ public static Date fromDosTime(ZipLong zipDosTime) {
+ long dosTime = zipDosTime.getValue();
+ return new Date(dosToJavaTime(dosTime));
+ }
+
+ /**
+ * Converts DOS time to Java time (number of milliseconds since
+ * epoch).
+ */
+ public static long dosToJavaTime(long dosTime) {
+ 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);
+ cal.set(Calendar.DATE, (int) (dosTime >> 16) & 0x1f);
+ cal.set(Calendar.HOUR_OF_DAY, (int) (dosTime >> 11) & 0x1f);
+ cal.set(Calendar.MINUTE, (int) (dosTime >> 5) & 0x3f);
+ cal.set(Calendar.SECOND, (int) (dosTime << 1) & 0x3e);
+ // CheckStyle:MagicNumberCheck ON
+ return cal.getTime().getTime();
+ }
+
+
+}
\ No newline at end of file
Propchange: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java?rev=756536&r1=756535&r2=756536&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java Fri Mar 20 15:42:37 2009
@@ -213,25 +213,25 @@
index of the last char in the block, so
the block size == last + 1.
*/
- int last;
+ private int last;
/*
index in zptr[] of original string after sorting.
*/
- int origPtr;
+ private int origPtr;
/*
always: in the range 0 .. 9.
The current block size is 100000 * this number.
*/
- int blockSize100k;
+ private int blockSize100k;
- boolean blockRandomised;
+ private boolean blockRandomised;
- int bytesOut;
- int bsBuff;
- int bsLive;
- CRC mCrc = new CRC();
+ private int bytesOut;
+ private int bsBuff;
+ private int bsLive;
+ private final CRC mCrc = new CRC();
private boolean[] inUse = new boolean[256];
private int nInUse;
@@ -364,7 +364,7 @@
}
}
- boolean closed = false;
+ private boolean closed = false;
protected void finalize() throws Throwable {
close();
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java?rev=756536&r1=756535&r2=756536&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java Fri Mar 20 15:42:37 2009
@@ -23,7 +23,7 @@
* data.
*/
class CRC {
- static final int crc32Table[] = {
+ private static final int crc32Table[] = {
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9,
0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
@@ -129,5 +129,5 @@
this.globalCrc = globalCrcShadow;
}
- int globalCrc;
+ private int globalCrc;
}
\ No newline at end of file
Copied: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java (from r756455, commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStreamTest.java)
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java?p2=commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java&p1=commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStreamTest.java&r1=756455&r2=756536&rev=756536&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStreamTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java Fri Mar 20 15:42:37 2009
@@ -23,7 +23,7 @@
import junit.framework.TestCase;
-public class ZipArchiveOutputStreamTest extends TestCase {
+public class ZipUtilTest extends TestCase {
private Date time;
private ZipLong zl;
@@ -31,7 +31,7 @@
/**
* Constructor
*/
- public ZipArchiveOutputStreamTest(String name) {
+ public ZipUtilTest(String name) {
super(name);
}
@@ -61,17 +61,17 @@
}
public void testZipLong() throws Exception {
- ZipLong test = ZipArchiveOutputStream.toDosTime(time);
+ ZipLong test = ZipUtil.toDosTime(time);
assertEquals(test.getValue(), zl.getValue());
}
public void testAdjustToLong() {
assertEquals(Integer.MAX_VALUE,
- ZipArchiveOutputStream.adjustToLong(Integer.MAX_VALUE));
+ ZipUtil.adjustToLong(Integer.MAX_VALUE));
assertEquals(((long) Integer.MAX_VALUE) + 1,
- ZipArchiveOutputStream.adjustToLong(Integer.MAX_VALUE + 1));
+ ZipUtil.adjustToLong(Integer.MAX_VALUE + 1));
assertEquals(2 * ((long) Integer.MAX_VALUE),
- ZipArchiveOutputStream.adjustToLong(2 * Integer.MAX_VALUE));
+ ZipUtil.adjustToLong(2 * Integer.MAX_VALUE));
}
}
Propchange: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java
------------------------------------------------------------------------------
svn:mergeinfo =