com.amazonaws.event
Class ProgressReportingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.amazonaws.internal.SdkFilterInputStream
              extended by com.amazonaws.event.ProgressReportingInputStream
All Implemented Interfaces:
com.amazonaws.internal.MetricAware, java.io.Closeable

public class ProgressReportingInputStream
extends com.amazonaws.internal.SdkFilterInputStream

Simple InputStream wrapper that occasionally notifies a progress listener about the number of bytes transferred.

This class could be used for both Amazon S3 and Amazon Glacier clients. The legacy Amazon Amazon S3 com.amazonaws.services.s3.internal.ProgressReportingInputStream has been deprecated in favor of this new class.


Constructor Summary
ProgressReportingInputStream(java.io.InputStream in, ProgressListenerCallbackExecutor listenerCallbackExecutor)
          Creates a new progress reporting input stream that simply wraps the specified input stream and uses the specified listener callback executor to asynchronously notify the listener about the number of bytes transferred.
 
Method Summary
 void close()
           
 boolean getFireCompletedEvent()
          Returns whether this input stream should fire an event with code ProgressEvent.COMPLETED_EVENT_CODE when this stream runs out of data.
 int read()
           
 int read(byte[] b, int off, int len)
           
 void reset()
           
 void setFireCompletedEvent(boolean fireCompletedEvent)
          Sets whether this input stream should fire an event with code ProgressEvent.COMPLETED_EVENT_CODE when this stream runs out of data.
 
Methods inherited from class com.amazonaws.internal.SdkFilterInputStream
available, isMetricActivated, mark, markSupported, skip
 
Methods inherited from class java.io.FilterInputStream
read
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressReportingInputStream

public ProgressReportingInputStream(java.io.InputStream in,
                                    ProgressListenerCallbackExecutor listenerCallbackExecutor)
Creates a new progress reporting input stream that simply wraps the specified input stream and uses the specified listener callback executor to asynchronously notify the listener about the number of bytes transferred.

Parameters:
in - The input stream to wrap.
listenerCallbackExecutor - The listener callback executor that wraps the listener to notify about progress.
Method Detail

setFireCompletedEvent

public void setFireCompletedEvent(boolean fireCompletedEvent)
Sets whether this input stream should fire an event with code ProgressEvent.COMPLETED_EVENT_CODE when this stream runs out of data. By default, completed events are not fired by this stream.

Parameters:
fireCompletedEvent - Whether this input stream should fire an event to indicate that the stream has been fully read.

getFireCompletedEvent

public boolean getFireCompletedEvent()
Returns whether this input stream should fire an event with code ProgressEvent.COMPLETED_EVENT_CODE when this stream runs out of data. By default, completed events are not fired by this stream.

Returns:
Whether this input stream should fire an event to indicate that the stream has been fully read.

read

public int read()
         throws java.io.IOException
Overrides:
read in class com.amazonaws.internal.SdkFilterInputStream
Throws:
java.io.IOException

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class com.amazonaws.internal.SdkFilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class com.amazonaws.internal.SdkFilterInputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class com.amazonaws.internal.SdkFilterInputStream
Throws:
java.io.IOException


Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.