Package io.avaje.json.stream
Interface JsonOutput
- All Superinterfaces:
AutoCloseable
,Closeable
Output that can be aware of server content chunking.
We can use an implementation of JsonOutput such that it can make use of
the underlying buffer used by avaje-jsonb, using writeLast(byte[], int, int)
to know if the content is complete (and typically can be written directly as fixed
content) or if the content is still being written (and potentially written by an
http server as chunked content).
Typically, for HTTP servers that can send output using fixed length or chunked.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
flush()
Flush the underlying OutputStream.static JsonOutput
of
(OutputStream outputStream) Deprecated.static JsonOutput
ofStream
(OutputStream outputStream) Create as a simple wrapper for OutputStream.Return the underlying OutputStream.void
write
(byte[] content, int offset, int length) Write the content to the underlying output stream.default void
writeLast
(byte[] content, int offset, int length) Write the last content to the underlying output stream.
-
Method Details
-
ofStream
Create as a simple wrapper for OutputStream. -
of
Deprecated.migrate toofStream(OutputStream)
. -
write
Write the content to the underlying output stream.- Throws:
IOException
-
writeLast
Write the last content to the underlying output stream.Given that this is known to be the last content written an implementation can make use of this to optimise for sending as fixed length content.
- Throws:
IOException
-
flush
Flush the underlying OutputStream.- Throws:
IOException
-
unwrapOutputStream
Return the underlying OutputStream.This is used for Jsonb adapters (Jackson) that can't support writeLast() semantics.
-
ofStream(OutputStream)
.