Class 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.
    • Constructor Detail

      • Buffer

        private Buffer()
    • Method Detail

      • 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

        private void write​(String name,
                           jakarta.json.JsonValue value)
      • terminate

        private boolean terminate()