Package com.amazonaws.event
Class ProgressInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- com.amazonaws.internal.SdkFilterInputStream
-
- com.amazonaws.event.ProgressInputStream
-
- All Implemented Interfaces:
com.amazonaws.internal.MetricAware
,com.amazonaws.internal.Releasable
,Closeable
,AutoCloseable
public abstract class ProgressInputStream extends com.amazonaws.internal.SdkFilterInputStream
Used for input stream progress tracking purposes.
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description ProgressInputStream(InputStream is, ProgressListener listener)
ProgressInputStream(InputStream is, ProgressListener listener, int notifyThresHold)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
ProgressListener
getListener()
protected long
getNotifiedByteCount()
protected int
getUnnotifiedByteCount()
InputStream
getWrappedInputStream()
static InputStream
inputStreamForRequest(InputStream is, AmazonWebServiceRequest req)
Returns an input stream for request progress tracking purposes.static InputStream
inputStreamForResponse(InputStream is, AmazonWebServiceRequest req)
Returns an input stream for response progress tracking purposes.protected void
onClose()
Defaults to behave the same asonEOF()
.protected void
onEOF()
An end-of-file event is to be notified.protected void
onFirstRead()
The read method is called for the very first time.protected void
onNotifyBytesRead()
Upon notification of the number of bytes transferred since last notification.protected void
onReset()
A reset event is to be notified.int
read()
int
read(byte[] b, int off, int len)
void
reset()
-
Methods inherited from class com.amazonaws.internal.SdkFilterInputStream
abort, abortIfNeeded, available, isMetricActivated, mark, markSupported, release, skip
-
Methods inherited from class java.io.FilterInputStream
read
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
ProgressInputStream
public ProgressInputStream(InputStream is, ProgressListener listener)
-
ProgressInputStream
public ProgressInputStream(InputStream is, ProgressListener listener, int notifyThresHold)
-
-
Method Detail
-
inputStreamForRequest
public static InputStream inputStreamForRequest(InputStream is, AmazonWebServiceRequest req)
Returns an input stream for request progress tracking purposes. If request/response progress tracking is not enabled, this method simply return the given input stream as is.- Parameters:
is
- the request content input stream
-
inputStreamForResponse
public static InputStream inputStreamForResponse(InputStream is, AmazonWebServiceRequest req)
Returns an input stream for response progress tracking purposes. If request/response progress tracking is not enabled, this method simply return the given input stream as is.- Parameters:
is
- the response content input stream
-
onFirstRead
protected void onFirstRead()
The read method is called for the very first time. Defaults to do nothing.
-
onEOF
protected void onEOF()
An end-of-file event is to be notified. Defaults to do nothing.
-
onClose
protected void onClose()
Defaults to behave the same asonEOF()
.
-
onReset
protected void onReset()
A reset event is to be notified. Default to do nothing.
-
onNotifyBytesRead
protected void onNotifyBytesRead()
Upon notification of the number of bytes transferred since last notification. Default to do nothing.
-
read
public int read() throws IOException
- Overrides:
read
in classcom.amazonaws.internal.SdkFilterInputStream
- Throws:
IOException
-
reset
public void reset() throws IOException
- Overrides:
reset
in classcom.amazonaws.internal.SdkFilterInputStream
- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException
- Overrides:
read
in classcom.amazonaws.internal.SdkFilterInputStream
- Throws:
IOException
-
getWrappedInputStream
public final InputStream getWrappedInputStream()
-
getUnnotifiedByteCount
protected final int getUnnotifiedByteCount()
-
getNotifiedByteCount
protected final long getNotifiedByteCount()
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classcom.amazonaws.internal.SdkFilterInputStream
- Throws:
IOException
-
getListener
public final ProgressListener getListener()
-
-