Interface MessageSource.Provider
- Enclosing interface:
MessageSource
public static interface MessageSource.Provider
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the underlying I/O abstraction.intread(ByteBuffer buffer, int minLengthHint) Reads from the underlying I/O abstraction into the given buffer.default voidskip(int length, ByteBuffer buffer) Skips the nextlengthbytes in the underlying I/O abstraction.default longtransferTo(WritableByteChannel channel, long length, ByteBuffer buffer) Transfers up tolengthbytes from the underlying I/O abstraction to the given channel.
-
Method Details
-
read
Reads from the underlying I/O abstraction into the given buffer.- Parameters:
buffer- the buffer to read intominLengthHint- A hint as to how many bytes the caller will try to read immediately. If the underlying I/O abstraction has at leastminLengthHintbytes readily available, it should return them without making a blocking I/O call.- Returns:
- the actual number of bytes read, or
-1if the end of input has been reached - Throws:
IOException- if an I/O error occurs
-
close
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
lengthbytes from the underlying I/O abstraction to the given channel.Fewer than
lengthbytes may be transferred if this message source reaches the end of input.- Parameters:
channel- the channel to transfer bytes tolength- the number of bytes to transferbuffer- A buffer whosenremaining bytes must be transferred before transferring up tolength - nbytes 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
Skips the nextlengthbytes in the underlying I/O abstraction.- Parameters:
length- the number of bytes to skipbuffer- a buffer whosenremaining bytes must be skipped before skippinglength - nbytes 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 beforelengthbytes have been skippedIOException- if an I/O error occurs
-