java.lang.Object
org.apache.johnzon.core.Snippet.Buffer
- All Implemented Interfaces:
Closeable,AutoCloseable
- Enclosing class:
- Snippet
There are several buffers involved in the creation of a json string.
This class carefully manages them all.
JsonGeneratorImpl with a 64k buffer (by default)
ObjectStreamWriter with an 8k buffer
SnippetOutputStream with a buffer of maxSnippetLength
As we create json via calling the JsonGenerator it is critical we
flush the work in progress all the way through these buffers and into
the final SnippetOutputStream buffer.
If we do not, we risk creating up to 64k of json when we may only
need 50 bytes. We could potentially optimize this code so the
buffer held by JsonGeneratorImpl is also the maxSnippetLength.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classSpecialized Writer with three internal states: Writing, Completed, Truncated. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final jakarta.json.stream.JsonGeneratorprivate final Snippet.Buffer.SnippetWriter -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
generator
private final jakarta.json.stream.JsonGenerator generator -
snippet
-
-
Constructor Details
-
Buffer
private Buffer()
-
-
Method Details
-
write
private void write(jakarta.json.JsonValue value) -
write
private void write(jakarta.json.JsonArray array) -
write
private void write(jakarta.json.JsonObject object) -
write
-
terminate
private boolean terminate() -
get
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-