Interface MessageSource.Provider

Enclosing interface:
MessageSource

public static interface MessageSource.Provider
Adapts a MessageSource to an underlying I/O abstraction such as ReadableByteChannel or InputStream.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the underlying I/O abstraction.
    int
    read(ByteBuffer buffer, int minLengthHint)
    Reads from the underlying I/O abstraction into the given buffer.
    default void
    skip(int length, ByteBuffer buffer)
    Skips the next length bytes in the underlying I/O abstraction.
    default long
    transferTo(WritableByteChannel channel, long length, ByteBuffer buffer)
    Transfers up to length bytes from the underlying I/O abstraction to the given channel.
  • Method Details

    • read

      int read(ByteBuffer buffer, int minLengthHint) throws IOException
      Reads from the underlying I/O abstraction into the given buffer.
      Parameters:
      buffer - the buffer to read into
      minLengthHint - A hint as to how many bytes the caller will try to read immediately. If the underlying I/O abstraction has at least minLengthHint bytes readily available, it should return them without making a blocking I/O call.
      Returns:
      the actual number of bytes read, or -1 if the end of input has been reached
      Throws:
      IOException - if an I/O error occurs
    • close

      void close() throws IOException

      Closes the underlying I/O abstraction.

      This method is called at most once. No other method is called after this method.

      Throws:
      IOException - if an I/O error occurs
    • transferTo

      default long transferTo(WritableByteChannel channel, long length, ByteBuffer buffer) throws IOException

      Transfers up to length bytes from the underlying I/O abstraction to the given channel.

      Fewer than length bytes may be transferred if this message source reaches the end of input.

      Parameters:
      channel - the channel to transfer bytes to
      length - the number of bytes to transfer
      buffer - A buffer whose n remaining bytes must be transferred before transferring up to length - n bytes from the underlying I/O abstraction. The buffer can also be used for transferring bytes from the underlying I/O abstraction.
      Returns:
      the actual number of bytes transferred (between 0 and length)
      Throws:
      IOException - if an I/O error occurs
    • skip

      default void skip(int length, ByteBuffer buffer) throws IOException
      Skips the next length bytes in the underlying I/O abstraction.
      Parameters:
      length - the number of bytes to skip
      buffer - a buffer whose n remaining bytes must be skipped before skipping length - n bytes in the underlying I/O abstraction. The buffer can also be used for skipping bytes in the underlying I/O abstraction.
      Throws:
      EOFException - if this message source reaches the end of input before length bytes have been skipped
      IOException - if an I/O error occurs