Class Snippet.Buffer

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Enclosing class:
    Snippet

    private class Snippet.Buffer
    extends java.lang.Object
    implements java.io.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 Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) class  Snippet.Buffer.SnippetWriter
      Specialized Writer with three internal states: Writing, Completed, Truncated.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Buffer()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      private java.lang.String get()  
      private boolean terminate()  
      private void write​(jakarta.json.JsonArray array)  
      private void write​(jakarta.json.JsonObject object)  
      private void write​(jakarta.json.JsonValue value)  
      private void write​(java.lang.String name, jakarta.json.JsonValue value)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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​(java.lang.String name,
                           jakarta.json.JsonValue value)
      • terminate

        private boolean terminate()
      • get

        private java.lang.String get()
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable