- All Known Subinterfaces:
BidirectionalConnectionByteTransceiver<INPUT,
,OUTPUT> BidirectionalStreamConnectionByteTransceiver
,BytesReceiver
,BytesTransceiver
,ConnectionBytesReceiver<CON>
,ConnectionBytesTransceiver<CON>
,InputStreamConnectionByteReceiver
- All Known Implementing Classes:
AbstractBytesReceiver
,AbstractInputStreamByteReceiver
,AbstractPrefetchInputStreamByteReceiver
,BidirectionalStreamByteTransceiver
,BidirectionalStreamConnectionByteTransceiverImpl
,ByteArrayReceiver
,BytesReceiverDecorator
,InputStreamByteReceiver
,InputStreamConnectionByteReceiverImpl
,LoopbackBytesReceiver
,LoopbackBytesTransceiver
,PrefetchBidirectionalStreamByteTransceiver
,PrefetchBidirectionalStreamConnectionByteTransceiver
,PrefetchInputStreamByteReceiver
,PrefetchInputStreamConnectionByteReceiver
,SkipAvailableInputStream
public interface Skippable
The
Skippable
interface defines methods useful for omitting bytes
known to be unusable for the according operation.-
Method Summary
Modifier and TypeMethodDescriptionint
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected.long
skip
(long n) Skips over and discardsn
bytes of data from this input stream.default void
Clears the read buffer from all available bytes as ofavailable()
at the time of this call.default void
skipAvailableExcept
(int aLength) Skips all currently available bytes except the number of bytes specified.default void
skipAvailableTill
(long aSkipTimeSpanInMs) Skips all available bytes till the given time span elapsed.default void
skipAvailableTillSilenceFor
(long aSilenceTimeSpanInMs) Skips all available bytes till a given time span of silence is detected: The number of bytes available must be 0 for the given time span for this operation to conclude.default void
skipAvailableTillSilenceFor
(long aSilenceTimeSpanInMs, long aTimeoutMillis) Skips all available bytes till a given time span of silence is detected: The number of bytes available must be 0 for the given time span for this operation to conclude.default void
skipAvailableWithin
(int aSkipLoops, int aSkipLoopTimeoutInMs) Skips all available bytes till after the given time no more bytes are available, else skipping is repeated till no more bytes are available within the given time span.default void
skipAvailableWithin
(long aSkipTimeSpanInMs) Skips all available bytes till after the given time no more bytes are available, else skipping is repeated till no more bytes are available within the given time span.This method blocks until the according available bytes have been skipped.default void
skipAvailableWithin
(long aSkipTimeSpanInMs, long aTimeoutMillis) Skips all available bytes till after the given time no more bytes are available, else skipping is repeated till no more bytes are available within the given time span.
-
Method Details
-
skipAvailable
Clears the read buffer from all available bytes as ofavailable()
at the time of this call. The bytes available are determined at the beginning of the skip process to prevent ongoing skipping of bytes on very slow machines and whilst receiving at very fast transfer rates (hypothetical).- Throws:
IOException
- thrown in case of I/O issues.
-
skipAvailableWithin
Skips all available bytes till after the given time no more bytes are available, else skipping is repeated till no more bytes are available within the given time span.This method blocks until the according available bytes have been skipped. ATTENTION: To apply a custom timeout, please useskipAvailableWithin(long, long)
.- Parameters:
aSkipTimeSpanInMs
- the skip time span in ms- Throws:
IOException
- thrown in case of I/O issues.
-
skipAvailableWithin
Skips all available bytes till after the given time no more bytes are available, else skipping is repeated till no more bytes are available within the given time span.- Parameters:
aSkipTimeSpanInMs
- the skip time span in msaTimeoutMillis
- the timeout in ms- Throws:
IOException
- thrown in case of I/O issues.
-
skipAvailableWithin
Skips all available bytes till after the given time no more bytes are available, else skipping is repeated till no more bytes are available within the given time span.- Parameters:
aSkipLoops
- the number of loops to skip available bytes.aSkipLoopTimeoutInMs
- the timeout in ms for each loop to wait.- Throws:
IOException
- thrown in case of I/O issues.
-
skipAvailableTill
Skips all available bytes till the given time span elapsed.- Parameters:
aSkipTimeSpanInMs
- the skip time span in ms- Throws:
IOException
- thrown in case of I/O issues.
-
skipAvailableTillSilenceFor
Skips all available bytes till a given time span of silence is detected: The number of bytes available must be 0 for the given time span for this operation to conclude. This method blocks until the time span of silence has been reached. ATTENTION: To apply a custom timeout, please useskipAvailableTillSilenceFor(long, long)
.- Parameters:
aSilenceTimeSpanInMs
- The time span in milliseconds of silence (0 bytes available) till skipping is terminated.- Throws:
IOException
- thrown in case of I/O issues.
-
skipAvailableTillSilenceFor
default void skipAvailableTillSilenceFor(long aSilenceTimeSpanInMs, long aTimeoutMillis) throws IOException Skips all available bytes till a given time span of silence is detected: The number of bytes available must be 0 for the given time span for this operation to conclude. In case the read timeout is not -1 and the overall time while skipping bytes exceeds the read timeout aTimeoutIOException
is thrown.- Parameters:
aSilenceTimeSpanInMs
- The time span in milliseconds of silence (0 bytes available) till skipping is terminated.aTimeoutMillis
- The time in milliseconds before this operation is terminated in case no period of silence as been detected before. With a value of -1 timeout handling is disabled (blocking mode).- Throws:
IOException
- thrown in case of I/O issues.org.refcodes.exception.TimeoutIOException
- in case the the read timeout is not -1 and the overall time while skipping bytes exceeds the read timeout .
-
skipAvailableExcept
Skips all currently available bytes except the number of bytes specified.- Parameters:
aLength
- The number of bytes to leave in theInputStream
.- Throws:
IOException
- thrown in case of problems while skipping.
-
skip
Skips over and discardsn
bytes of data from this input stream. Theskip
method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly0
. This may result from any of a number of conditions; reaching end of file beforen
bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. Ifn
is negative, theskip
method for classInputStream
always returns 0, and no bytes are skipped. Subclasses may handle the negative value differently. Theskip
method implementation of this class creates a byte array and then repeatedly reads into it untiln
bytes have been read or the end of the stream has been reached. Subclasses are encouraged to provide a more efficient implementation of this method. For instance, the implementation may depend on the ability to seek.- Parameters:
n
- the number of bytes to be skipped.- Returns:
- the actual number of bytes skipped which might be zero.
- Throws:
IOException
- if an I/O error occurs.
-
available
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. Note that while some implementations as of theInputStream
will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream. A subclass's implementation of this method may choose to throw anIOException
if this input stream has been closed. Theavailable
method ofInputStream
always returns0
.- Returns:
- an estimate of the number of bytes that can be read (or skipped
over) from this input stream without blocking or
0
when it reaches the end of the input stream. - Throws:
IOException
- if an I/O error occurs.
-