Package io.deephaven.io.streams
Interface CurrentByteBufferSink
-
- All Superinterfaces:
ByteBufferSink
- All Known Implementing Classes:
CurrentByteBufferSink.Adapter,SimpleByteBufferSink
public interface CurrentByteBufferSink extends ByteBufferSink
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
Nested Classes Modifier and Type Interface Description static classCurrentByteBufferSink.Adapter
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidclose()Convenience close method.default java.nio.ByteBufferensureSpace(int need)Return the current buffer, guaranteed to have sufficient space remaining to append the requested number of bytes.default voidflush()Cause the current buffer to be accepted if it has any contents that aren't yet accepted into the sink.java.nio.ByteBuffergetBuffer()Access the current buffer for this sink.-
Methods inherited from interface io.deephaven.io.streams.ByteBufferSink
acceptBuffer, close
-
-
-
-
Method Detail
-
getBuffer
java.nio.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
default java.nio.ByteBuffer ensureSpace(int need) throws java.io.IOExceptionReturn 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:
java.io.IOException
-
flush
default void flush() throws java.io.IOExceptionCause the current buffer to be accepted if it has any contents that aren't yet accepted into the sink.- Throws:
java.io.IOException
-
close
default void close() throws java.io.IOExceptionConvenience close method. Effectively the same as invokingByteBufferSink.close(ByteBuffer)with the result ofgetBuffer().- Throws:
java.io.IOException
-
-