commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject commons-compress git commit: make all CompressorOutputStreams count written bytes
Date Sun, 10 Apr 2016 04:22:42 GMT
Repository: commons-compress
Updated Branches:
  refs/heads/COMPRESS-207 ffc026d06 -> e848f8053


make all CompressorOutputStreams count written bytes


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/e848f805
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/e848f805
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/e848f805

Branch: refs/heads/COMPRESS-207
Commit: e848f805373f8cda5e7e3ba6df7a9fb8b685653b
Parents: ffc026d
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Sun Apr 10 06:19:05 2016 +0200
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Sun Apr 10 06:22:25 2016 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                                       | 4 ++++
 .../commons/compress/compressors/CompressorInputStream.java   | 3 +++
 .../commons/compress/compressors/CompressorOutputStream.java  | 7 ++++++-
 .../compressors/bzip2/BZip2CompressorOutputStream.java        | 2 ++
 .../compressors/deflate/DeflateCompressorOutputStream.java    | 2 ++
 .../compress/compressors/gzip/GzipCompressorOutputStream.java | 1 +
 .../compressors/pack200/Pack200CompressorOutputStream.java    | 3 +++
 .../compress/compressors/xz/XZCompressorOutputStream.java     | 2 ++
 8 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e848f805/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2e0dfc2..12538fd 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -44,6 +44,10 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
     <release version="1.12" date="not released, yet"
              description="Release 1.12 - API compatible to 1.11 but requires Java6 at runtime">
+      <action type="add" date="2016-04-10">
+        The CompressorOutputStreams now provide a count of the
+        uncompressed bytes written to the stream.
+      </action>
       <action issue="COMPRESS-349" type="update" date="2016-04-09" dev="ggregory">
         Update requirement from Java 5 to 6.
       </action>

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e848f805/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java
b/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java
index 64c4dfa..06e9c45 100644
--- a/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java
@@ -88,6 +88,7 @@ public abstract class CompressorInputStream extends InputStream {
      * <p>Not all streams support progress notifications.</p>
      *
      * @param l the listener to add
+     * @since 1.12
      */
     public void addCompressionProgressListener(CompressionProgressListener l) {
         listeners.add(l);
@@ -97,6 +98,7 @@ public abstract class CompressorInputStream extends InputStream {
      * Removes a listener that is notified of decompression progress.
      *
      * @param l the listener to remove
+     * @since 1.12
      */
     public void removeCompressionProgressListener(CompressionProgressListener l) {
         listeners.remove(l);
@@ -109,6 +111,7 @@ public abstract class CompressorInputStream extends InputStream {
      * @param streamNumer number of the stream that is getting
      *        processed now
      * @param compressedBytesRead number of compressed bytes read
+     * @since 1.12
      */
     protected void fireProgress(int blockNumber, int streamNumber, long compressedBytesRead)
{
         CompressionProgressEvent e = new CompressionProgressEvent(this, blockNumber, streamNumber,

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e848f805/src/main/java/org/apache/commons/compress/compressors/CompressorOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/CompressorOutputStream.java
b/src/main/java/org/apache/commons/compress/compressors/CompressorOutputStream.java
index 28440e0..8b6ad74 100644
--- a/src/main/java/org/apache/commons/compress/compressors/CompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/CompressorOutputStream.java
@@ -34,6 +34,7 @@ public abstract class CompressorOutputStream extends OutputStream {
      * <p>Not all streams support progress notifications.</p>
      *
      * @param l the listener to add
+     * @since 1.12
      */
     public void addCompressionProgressListener(CompressionProgressListener l) {
         listeners.add(l);
@@ -43,6 +44,7 @@ public abstract class CompressorOutputStream extends OutputStream {
      * Removes a listener that is notified of compression progress.
      *
      * @param l the listener to remove
+     * @since 1.12
      */
     public void removeCompressionProgressListener(CompressionProgressListener l) {
         listeners.remove(l);
@@ -55,6 +57,7 @@ public abstract class CompressorOutputStream extends OutputStream {
      * @param streamNumer number of the stream that is getting
      *        processed now
      * @param compressedBytesWritten number of compressed bytes written
+     * @since 1.12
      */
     protected void fireProgress(int blockNumber, int streamNumber, long compressedBytesWritten)
{
         CompressionProgressEvent e = new CompressionProgressEvent(this, blockNumber, streamNumber,
@@ -72,14 +75,16 @@ public abstract class CompressorOutputStream extends OutputStream {
      * Increments the counter of already written bytes.
      *
      * @param written the number of bytes written
+     * @since 1.12
      */
     protected void count(long written) {
         bytesWritten += written;
     }
 
     /**
-     * Returns the current number of bytes written from this stream.
+     * Returns the current number of bytes written to this stream.
      * @return the number of written bytes
+     * @since 1.12
      */
     public long getBytesWritten() {
         return bytesWritten;

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e848f805/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 9de51d4..22b38f9 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
@@ -394,6 +394,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
     public void write(final int b) throws IOException {
         if (this.out != null) {
             write0(b);
+            count(1);
         } else {
             throw new IOException("closed");
         }
@@ -632,6 +633,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
         for (final int hi = offs + len; offs < hi;) {
             write0(buf[offs++]);
         }
+        count(len);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e848f805/src/main/java/org/apache/commons/compress/compressors/deflate/DeflateCompressorOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/deflate/DeflateCompressorOutputStream.java
b/src/main/java/org/apache/commons/compress/compressors/deflate/DeflateCompressorOutputStream.java
index a315605..e417e5e 100644
--- a/src/main/java/org/apache/commons/compress/compressors/deflate/DeflateCompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/deflate/DeflateCompressorOutputStream.java
@@ -57,11 +57,13 @@ public class DeflateCompressorOutputStream extends CompressorOutputStream
{
     @Override
     public void write(final int b) throws IOException {
         out.write(b);
+        count(1);
     }
 
     @Override
     public void write(final byte[] buf, final int off, final int len) throws IOException
{
         out.write(buf, off, len);
+        count(len);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e848f805/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
index af79210..2f5e69e 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
@@ -163,6 +163,7 @@ public class GzipCompressorOutputStream extends CompressorOutputStream
{
             }
             
             crc.update(buffer, offset, length);
+            count(length);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e848f805/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorOutputStream.java
b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorOutputStream.java
index ca27100..48ff132 100644
--- a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorOutputStream.java
@@ -101,16 +101,19 @@ public class Pack200CompressorOutputStream extends CompressorOutputStream
{
     @Override
     public void write(final int b) throws IOException {
         streamBridge.write(b);
+        count(1);
     }
 
     @Override
     public void write(final byte[] b) throws IOException {
         streamBridge.write(b);
+        count(b.length);
     }
 
     @Override
     public void write(final byte[] b, final int from, final int length) throws IOException
{
         streamBridge.write(b, from, length);
+        count(length);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e848f805/src/main/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStream.java
b/src/main/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStream.java
index 6e9b70e..0aa9322 100644
--- a/src/main/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStream.java
@@ -67,11 +67,13 @@ public class XZCompressorOutputStream extends CompressorOutputStream {
     @Override
     public void write(final int b) throws IOException {
         out.write(b);
+        count(1);
     }
 
     @Override
     public void write(final byte[] buf, final int off, final int len) throws IOException
{
         out.write(buf, off, len);
+        count(len);
     }
 
     /**


Mime
View raw message