This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 46a251d235733fa088037ab3fd411dc11b97ffda Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Wed Apr 9 11:00:24 2025 -0400 Javadoc --- .../compress/archivers/zip/StreamCompressor.java | 36 ++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/StreamCompressor.java b/src/main/java/org/apache/commons/compress/archivers/zip/StreamCompressor.java index 0f4196d92..dc4bf1c1d 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/StreamCompressor.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/StreamCompressor.java @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.commons.compress.archivers.zip; import java.io.Closeable; @@ -40,6 +41,7 @@ public abstract class StreamCompressor implements Closeable { private static final class DataOutputCompressor extends StreamCompressor { + private final DataOutput raf; DataOutputCompressor(final Deflater deflater, final DataOutput raf) { @@ -54,6 +56,7 @@ protected void writeOut(final byte[] data, final int offset, final int length) t } private static final class OutputStreamCompressor extends StreamCompressor { + private final OutputStream os; OutputStreamCompressor(final Deflater deflater, final OutputStream os) { @@ -68,6 +71,7 @@ protected void writeOut(final byte[] data, final int offset, final int length) t } private static final class ScatterGatherBackingStoreCompressor extends StreamCompressor { + private final ScatterGatherBackingStore bs; ScatterGatherBackingStoreCompressor(final Deflater deflater, final ScatterGatherBackingStore bs) { @@ -82,6 +86,7 @@ protected void writeOut(final byte[] data, final int offset, final int length) t } private static final class SeekableByteChannelCompressor extends StreamCompressor { + private final SeekableByteChannel channel; SeekableByteChannelCompressor(final Deflater deflater, final SeekableByteChannel channel) { @@ -171,17 +176,11 @@ static StreamCompressor create(final SeekableByteChannel os, final Deflater defl } private final Deflater deflater; - private final CRC32 crc = new CRC32(); - private long writtenToOutputStreamForLastEntry; - private long sourcePayloadLength; - private long totalWrittenToOutputStream; - private final byte[] outputBuffer = new byte[BUFFER_SIZE]; - private final byte[] readerBuf = new byte[BUFFER_SIZE]; StreamCompressor(final Deflater deflater) { @@ -207,11 +206,9 @@ void deflate() throws IOException { * @param method The #ZipArchiveEntry compression method * @throws IOException When failures happen */ - public void deflate(final InputStream source, final int method) throws IOException { reset(); int length; - while ((length = source.read(readerBuf, 0, readerBuf.length)) >= 0) { write(readerBuf, 0, length, method); } @@ -256,7 +253,6 @@ public long getBytesWrittenForLastEntry() { * * @return the CRC-32 */ - public long getCrc32() { return crc.getValue(); } @@ -299,10 +295,24 @@ long write(final byte[] b, final int offset, final int length, final int method) return writtenToOutputStreamForLastEntry - current; } + /** + * Writes the specified byte array to the output stream. + * + * @param data the data. + * @exception IOException if an I/O error occurs. + */ public void writeCounted(final byte[] data) throws IOException { writeCounted(data, 0, data.length); } + /** + * Writes {@code len} bytes from the specified byte array starting at offset {@code off} to the output stream. + * + * @param data the data. + * @param offset the start offset in the data. + * @param length the number of bytes to write. + * @exception IOException if an I/O error occurs. + */ public void writeCounted(final byte[] data, final int offset, final int length) throws IOException { writeOut(data, offset, length); writtenToOutputStreamForLastEntry += length; @@ -329,5 +339,13 @@ private void writeDeflated(final byte[] b, final int offset, final int length) t } } + /** + * Writes {@code len} bytes from the specified byte array starting at offset {@code off} to the output stream. + * + * @param data the data. + * @param offset the start offset in the data. + * @param length the number of bytes to write. + * @exception IOException if an I/O error occurs. + */ protected abstract void writeOut(byte[] data, int offset, int length) throws IOException; }