Interface BytesReceiver

All Superinterfaces:
Availability, ByteDestination, ByteReceiver, BytesDestination, org.refcodes.component.Closable, org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.ClosedAccessor, org.refcodes.component.ConnectableComponent, org.refcodes.component.ConnectableComponent.ConnectableAutomaton, org.refcodes.component.ConnectionStatusAccessor, org.refcodes.mixin.InputStreamAccessor, org.refcodes.component.OpenedAccessor, Receivable, Skippable, TimeoutInputStreamAccessor
All Known Subinterfaces:
BidirectionalConnectionByteTransceiver<INPUT,OUTPUT>, BidirectionalStreamConnectionByteTransceiver, 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

public interface BytesReceiver extends BytesDestination, ByteReceiver, TimeoutInputStreamAccessor, Skippable
The Interface BytesReceiver.
  • Method Details

    • skip

      default long skip(long aLength) throws IOException
      Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, the skip method for class InputStream always returns 0, and no bytes are skipped. Subclasses may handle the negative value differently. The skip method implementation of this class creates a byte array and then repeatedly reads into it until n 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.
      Specified by:
      skip in interface Skippable
      Parameters:
      aLength - 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.
    • getInputStream

      default InputStream getInputStream()
      Retrieves the input stream from the underlying implementation as is (no TimeoutInputStream wrapping the original InputStream).
      Specified by:
      getInputStream in interface org.refcodes.mixin.InputStreamAccessor
      Returns:
      The according underlying InputStream.
    • getInputStream

      default TimeoutInputStream getInputStream(long aTimeoutMillis)
      Retrieves the InputStream as provided by getInputStream() wrapped in a TimeoutInputStream or an implementation depended implementation of a TimeoutInputStream.
      Specified by:
      getInputStream in interface TimeoutInputStreamAccessor
      Parameters:
      aTimeoutMillis - the a timeout in ms
      Returns:
      The according TimeoutInputStream from the underlying InputStream.
    • receiveAllBytes

      default byte[] receiveAllBytes() throws IOException
      Reads (receives) the all currently available data.
      Specified by:
      receiveAllBytes in interface BytesDestination
      Returns:
      The according data.
      Throws:
      IOException - Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
      EOFException - Signals that an end of file or end of stream has been reached unexpectedly during input.
    • receiveBytes

      default byte[] receiveBytes(int aLength) throws IOException
      Similar to BytesDestination.receiveAllBytes() though at maximum the amount of data as of the provided length returned.
      Specified by:
      receiveBytes in interface BytesDestination
      Parameters:
      aLength - The block-size which is not to exceeded by the returned data. A value of -1 specifies to retrieve all available datagrams (same behavior as method BytesDestination.receiveAllBytes().
      Returns:
      The according data.
      Throws:
      IOException - Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
      EOFException - Signals that an end of file or end of stream has been reached unexpectedly during input.
    • receiveByteWithin

      default byte receiveByteWithin(long aTimeoutMillis) throws IOException
      Receives a byte. This method blocks till a byte is available or the timeout has been reached.
      Parameters:
      aTimeoutMillis - The default timeout for read operations not explicitly called with a timeout argument. With a value of -1 timeout handling is disabled (blocking mode) or a technical timeout occurs (implementation depended).
      Returns:
      A accordingly received byte.
      Throws:
      IOException - thrown in case of I/O issues (e.g. a timeout) while receiving.
    • receiveBytesWithin

      default byte[] receiveBytesWithin(long aTimeoutMillis, int aLength) throws IOException
      Receives a byte array with the number of bytes specified. This method blocks till all bytes are read or the timeout has been reached.
      Parameters:
      aTimeoutMillis - The default timeout for read operations not explicitly called with a timeout argument. With a value of -1 timeout handling is disabled (blocking mode) or a technical timeout occurs (implementation depended).
      aLength - The number of bytes to receive.
      Returns:
      A byte array containing the accordingly received bytes.
      Throws:
      IOException - thrown in case of I/O issues (e.g. a timeout) while receiving.
    • receiveBytesWithin

      default void receiveBytesWithin(long aTimeoutMillis, byte[] aBuffer, int aOffset, int aLength) throws IOException
      Receives a byte array with the number of bytes specified inserted at the given offset. This method blocks till all bytes are read or the timeout has been reached.
      Parameters:
      aTimeoutMillis - The default timeout for read operations not explicitly called with a timeout argument. With a value of -1 timeout handling is disabled (blocking mode) or a technical timeout occurs (implementation depended).
      aBuffer - The byte array where to store the bytes at.
      aOffset - The offset where to start storing the received bytes.
      aLength - The number of bytes to receive.
      Throws:
      IOException - thrown in case of I/O issues (e.g. a timeout) while receiving.