|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream java.io.FilterInputStream org.eclipse.ecf.provider.filetransfer.util.PollingInputStream
public class PollingInputStream
Polls a progress monitor periodically and handles timeouts over extended durations. For this class to be effective, a high numAttempts should be specified, and the underlying stream should time out frequently on reads (every second or so). Supports resuming partially completed operations after an InterruptedIOException if the underlying stream does. Check the bytesTransferred field to determine how much of the operation completed; conversely, at what point to resume.
Field Summary |
---|
Fields inherited from class java.io.FilterInputStream |
---|
in |
Constructor Summary | |
---|---|
PollingInputStream(java.io.InputStream in,
int numAttempts,
org.eclipse.core.runtime.IProgressMonitor monitor)
Creates a new polling input stream. |
|
PollingInputStream(java.io.InputStream in,
int numAttempts,
org.eclipse.core.runtime.IProgressMonitor monitor,
java.lang.String readTimeoutMessage,
java.lang.String closeTimeoutMessage)
Creates a new polling input stream. |
Method Summary | |
---|---|
void |
close()
Wraps the underlying stream's method. |
int |
read()
Wraps the underlying stream's method. |
int |
read(byte[] buffer,
int off,
int len)
Wraps the underlying stream's method. |
protected void |
readPendingInput()
Reads any pending input from the input stream so that the stream can savely be closed. |
void |
setIsCancellable(boolean cancellable)
Called to set whether cancellation will be checked by this stream. |
long |
skip(long count)
Wraps the underlying stream's method. |
Methods inherited from class java.io.FilterInputStream |
---|
available, mark, markSupported, read, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PollingInputStream(java.io.InputStream in, int numAttempts, org.eclipse.core.runtime.IProgressMonitor monitor)
in
- the underlying input streamnumAttempts
- the number of attempts before issuing an
InterruptedIOException, if 0, retries indefinitely until
canceledmonitor
- the progress monitor to be polled for cancellationpublic PollingInputStream(java.io.InputStream in, int numAttempts, org.eclipse.core.runtime.IProgressMonitor monitor, java.lang.String readTimeoutMessage, java.lang.String closeTimeoutMessage)
in
- the underlying input streamnumAttempts
- the number of attempts before issuing an
InterruptedIOException, if 0, retries indefinitely until
canceledmonitor
- the progress monitor to be polled for cancellationreadTimeoutMessage
- message to go with InteruptedIOException if read timeoutcloseTimeoutMessage
- message to go with InteruptedIOException if close timeoutMethod Detail |
---|
public void close() throws java.io.InterruptedIOException
close
in interface java.io.Closeable
close
in class java.io.FilterInputStream
org.eclipse.core.runtime.OperationCanceledException
- if the progress monitor is canceled
java.io.InterruptedIOException
- if the underlying operation times out numAttempts timespublic int read() throws java.io.IOException
read
in class java.io.FilterInputStream
org.eclipse.core.runtime.OperationCanceledException
- if the progress monitor is canceled
java.io.InterruptedIOException
- if the underlying operation times out numAttempts times and
no data was received, bytesTransferred will be zero
java.io.IOException
- if an i/o error occurspublic int read(byte[] buffer, int off, int len) throws java.io.IOException
read
in class java.io.FilterInputStream
buffer
- - the buffer into which the data is read.off
- - the start offset of the data.len
- - the maximum number of bytes read.
org.eclipse.core.runtime.OperationCanceledException
- if the progress monitor is canceled
java.io.InterruptedIOException
- if the underlying operation times out numAttempts times and
no data was received, bytesTransferred will be zero
java.io.IOException
- if an i/o error occurspublic long skip(long count) throws java.io.IOException
skip
in class java.io.FilterInputStream
count
- - the number of bytes to be skipped.
org.eclipse.core.runtime.OperationCanceledException
- if the progress monitor is canceled
java.io.InterruptedIOException
- if the underlying operation times out numAttempts times and
no data was received, bytesTransferred will be zero
java.io.IOException
- if an i/o error occursprotected void readPendingInput() throws java.io.IOException
java.io.IOException
public void setIsCancellable(boolean cancellable)
cancellable
- a flag controlling whether this stream will check for
cancellation.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |