- All Superinterfaces:
AutoCloseable
,BufferedEncodedOutput
,Output<RuntimeException>
,Output.CloseableEncodedOutput<RuntimeException>
,Output.EncodedOutput<RuntimeException>
- All Known Implementing Classes:
ByteBufferedOutputStream
An encoded output optimized for producing a single
ByteBuffer
. The
BufferedEncodedOutput.bufferSizeHint()
is usually the size of the entire output and usually
implementations of this type are reusable with care.- Author:
- agentgt
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jstach.jstachio.Output
Output.CloseableEncodedOutput<E extends Exception>, Output.EncodedOutput<E extends Exception>, Output.StringOutput
-
Method Summary
Modifier and TypeMethodDescriptionGets a byte buffer view of the data.default ReadableByteChannel
Represents the encoded output as readable channel.static ByteBufferEncodedOutput
ofByteArray
(Charset charset) CallsofByteArray(Charset, int)
with initial size of 4096.static ByteBufferEncodedOutput
ofByteArray
(Charset charset, int initialSize) Create a buffered encoded output backed by an array that will grow as needed analagous to StringBuilder and/orByteArrayOutputStream
.Methods inherited from interface io.jstach.jstachio.output.BufferedEncodedOutput
accept, append, append, bufferSizeHint, close, isReusable, limit, size, toByteArray, transferTo
-
Method Details
-
asByteBuffer
Gets a byte buffer view of the data.- Returns:
- byte buffer
-
ofByteArray
Create a buffered encoded output backed by an array that will grow as needed analagous to StringBuilder and/orByteArrayOutputStream
. This output is more optimized for getting byte array or a ByteBuffer as well a reuse.- Parameters:
charset
- the expected encodinginitialSize
- the initial size of the backing array.- Returns:
- buffered output
-
ofByteArray
CallsofByteArray(Charset, int)
with initial size of 4096.- Parameters:
charset
- the expected encoding- Returns:
- buffered output
-
asReadableByteChannel
Description copied from interface:BufferedEncodedOutput
Represents the encoded output as readable channel. The channel should be closed when finished to signal reuse or destruction of the buffered output!. To possibly help determine the buffer to use forReadableByteChannel.read(java.nio.ByteBuffer)
one can useBufferedEncodedOutput.bufferSizeHint()
orBufferedEncodedOutput.size()
.- Specified by:
asReadableByteChannel
in interfaceBufferedEncodedOutput
- Returns:
- channel open and ready to read from at the start of the output.
- See Also:
-