Package io.deephaven.io.streams
Interface CurrentByteBufferSink
- All Superinterfaces:
ByteBufferSink
- All Known Implementing Classes:
CurrentByteBufferSink.Adapter
,SimpleByteBufferSink
A ByteBufferSink that knows and provides a getter for the last buffer it gave out, to avoid unnecessary state in code
that uses the buffer.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
close()
Convenience close method.default ByteBuffer
ensureSpace
(int need) Return the current buffer, guaranteed to have sufficient space remaining to append the requested number of bytes.default void
flush()
Cause the current buffer to be accepted if it has any contents that aren't yet accepted into the sink.Access the current buffer for this sink.Methods inherited from interface io.deephaven.io.streams.ByteBufferSink
acceptBuffer, close
-
Method Details
-
getBuffer
ByteBuffer getBuffer()Access the current buffer for this sink. This is either the initial buffer, or the last one provided byByteBufferSink.acceptBuffer(ByteBuffer, int)
) orensureSpace(int)
.- Returns:
- The current buffer for this sink
-
ensureSpace
Return the current buffer, guaranteed to have sufficient space remaining to append the requested number of bytes. The existing current buffer may be accepted (seeByteBufferSink.acceptBuffer(ByteBuffer, int)
) as a side effect of this operation.- Parameters:
need
- The number of bytes required to proceed- Returns:
- The current buffer for further output
- Throws:
IOException
-
flush
Cause the current buffer to be accepted if it has any contents that aren't yet accepted into the sink.- Throws:
IOException
-
close
Convenience close method. Effectively the same as invokingByteBufferSink.close(ByteBuffer)
with the result ofgetBuffer()
.- Throws:
IOException
-