Package org.apache.johnzon.core
Class Snippet.Buffer
- java.lang.Object
- 
- org.apache.johnzon.core.Snippet.Buffer
 
- 
- All Implemented Interfaces:
- Closeable,- AutoCloseable
 - Enclosing class:
- Snippet
 
 private class Snippet.Buffer extends Object implements Closeable 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 SummaryNested Classes Modifier and Type Class Description (package private) classSnippet.Buffer.SnippetWriterSpecialized Writer with three internal states: Writing, Completed, Truncated.
 - 
Field SummaryFields Modifier and Type Field Description private jakarta.json.stream.JsonGeneratorgeneratorprivate Snippet.Buffer.SnippetWritersnippet
 - 
Constructor SummaryConstructors Modifier Constructor Description privateBuffer()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()private Stringget()private booleanterminate()private voidwrite(jakarta.json.JsonArray array)private voidwrite(jakarta.json.JsonObject object)private voidwrite(jakarta.json.JsonValue value)private voidwrite(String name, jakarta.json.JsonValue value)
 
- 
- 
- 
Field Detail- 
generatorprivate final jakarta.json.stream.JsonGenerator generator 
 - 
snippetprivate final Snippet.Buffer.SnippetWriter snippet 
 
- 
 - 
Method Detail- 
writeprivate void write(jakarta.json.JsonValue value) 
 - 
writeprivate void write(jakarta.json.JsonArray array) 
 - 
writeprivate void write(jakarta.json.JsonObject object) 
 - 
writeprivate void write(String name, jakarta.json.JsonValue value) 
 - 
terminateprivate boolean terminate() 
 - 
getprivate String get() 
 - 
closepublic void close() - Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
 
 
- 
 
-