Interface MessageSink
public sealed interface MessageSink
A destination of bytes that a
MessageWriter writes to.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface -
Method Summary
Modifier and TypeMethodDescriptionReturns the buffer allocator used by this message sink.buffer()Returns the write buffer of this messge sink.voidensureRemaining(int length) voidflush()Flushes this message sink.voidFlushes the buffer of this message sink.longtransferFrom(ReadableByteChannel channel, long length) Transfers up tolengthbytes from the given channel to this message sink.voidwrite(byte value) Writes abyte.voidwrite(byte value1, byte value2) Writes abytefollowed by abyte.voidwrite(byte value1, double value2) Writes abytefollowed by adouble.voidwrite(byte value1, float value2) Writes abytefollowed by afloat.voidwrite(byte value1, int value2) Writes abytefollowed by anint.voidwrite(byte value1, long value2) Writes abytefollowed by along.voidwrite(byte value1, short value2) Writes abytefollowed by ashort.voidwrite(double value) Writes adouble.voidwrite(float value) Writes afloat.voidwrite(int value) Writes anint.voidwrite(long value) Writes along.voidwrite(short value) Writes ashort.voidwrite(ByteBuffer buffer) Writes the remaining bytes of the given buffer.voidwrite(ByteBuffer... buffers) Writes the remaining bytes of the given buffers.
-
Method Details
-
buffer
ByteBuffer buffer()Returns the write buffer of this messge sink.- Returns:
- the write buffer of this message sink
-
allocator
BufferAllocator allocator()Returns the buffer allocator used by this message sink.- Returns:
- the byte allocator used by this message sink
-
write
Writes the remaining bytes of the given buffer.
This method blocks until the given buffer has been written.
- Parameters:
buffer- the buffer to write- Throws:
IOException- if an I/O error occurs
-
write
Writes the remaining bytes of the given buffers.
This method blocks until the given buffers have been written. Calling this method may be more efficient than repeatedly calling
write(ByteBuffer).- Parameters:
buffers- the buffers to write- Throws:
IOException- if an I/O error occurs
-
transferFrom
Transfers up to
lengthbytes from the given channel to this message sink.Fewer than
lengthbytes may be transferred if the channel's end of input is reached.- Parameters:
channel- the channel to read fromlength- the number of bytes to transfer- Returns:
- the actual number of bytes transferred (between 0 and
length) - Throws:
IOException- if an I/O error occurs
-
ensureRemaining
Ensures that the buffer of this message sink has at least
lengthbytes remaining.If the buffer has fewer than
lengthbytes remaining, this method blocks until enough bytes have been written.- Parameters:
length- the minimum number of bytes that the buffer needs to have remaining- Throws:
IOException- if an I/O error occurs
-
write
Writes abyte.- Parameters:
value- the value to write- Throws:
IOException- if an I/O error occurs
-
write
Writes ashort.- Parameters:
value- the value to write- Throws:
IOException- if an I/O error occurs
-
write
Writes anint.- Parameters:
value- the value to write- Throws:
IOException- if an I/O error occurs
-
write
Writes along.- Parameters:
value- the value to write- Throws:
IOException- if an I/O error occurs
-
write
Writes afloat.- Parameters:
value- the value to write- Throws:
IOException- if an I/O error occurs
-
write
Writes adouble.- Parameters:
value- the value to write- Throws:
IOException- if an I/O error occurs
-
write
Writes abytefollowed by abyte.- Parameters:
value1- the first value to writevalue2- the second value to write- Throws:
IOException- if an I/O error occurs
-
write
Writes abytefollowed by ashort.- Parameters:
value1- the first value to writevalue2- the second value to write- Throws:
IOException- if an I/O error occurs
-
write
Writes abytefollowed by anint.- Parameters:
value1- the first value to writevalue2- the second value to write- Throws:
IOException- if an I/O error occurs
-
write
Writes abytefollowed by along.- Parameters:
value1- the first value to writevalue2- the second value to write- Throws:
IOException- if an I/O error occurs
-
write
Writes abytefollowed by afloat.- Parameters:
value1- the first value to writevalue2- the second value to write- Throws:
IOException- if an I/O error occurs
-
write
Writes abytefollowed by adouble.- Parameters:
value1- the first value to writevalue2- the second value to write- Throws:
IOException- if an I/O error occurs
-
flushBuffer
Flushes the buffer of this message sink.- Throws:
IOException- if an I/O error occurs
-
flush
Flushes this message sink.
This method calls
flushBuffer()andMessageSink.Provider.flush().- Throws:
IOException- if an I/O error occurs
-