StreamCharBuffer (Grails 6.0.0)

Package: org.grails.buffer

## [Java] Class StreamCharBuffer

- org.grails.buffer.StreamCharBuffer

- All Implemented Interfaces and Traits:
    groovy.lang.Writable, java.lang.CharSequence, Encodeable, EncodedAppenderWriterFactory, java.io.Externalizable, StreamEncodeable, StreamingEncoderWritable, java.lang.Cloneable

      public class StreamCharBuffer
      extends groovy.lang.GroovyObjectSupport
      implements groovy.lang.Writable, java.lang.CharSequence, Encodeable, EncodedAppenderWriterFactory, java.io.Externalizable, StreamEncodeable, StreamingEncoderWritable, java.lang.Cloneable

  StreamCharBuffer is a multipurpose in-memory buffer that can replace JDK in-memory buffers (StringBuffer, StringBuilder, StringWriter).

  Grails GSP rendering uses this class as a buffer that is optimized for performance.

  StreamCharBuffer keeps the buffer in a linked list of "chunks". The main difference compared to JDK in-memory buffers (StringBuffer, StringBuilder & StringWriter) is that the buffer can be held in several smaller buffers ("chunks" here). In JDK in-memory buffers, the buffer has to be expanded whenever it gets filled up. The old buffer's data is copied to the new one and the old one is discarded. In StreamCharBuffer, there are several ways to prevent unnecessary allocation & copy operations. The StreamCharBuffer contains a linked list of different type of chunks: char arrays, java.lang.String chunks and other StreamCharBuffers as sub chunks. A StringChunk is appended to the linked list whenever a java.lang.String of a length that exceeds the "stringChunkMinSize" value is written to the buffer.

  Grails tag libraries also use a StreamCharBuffer to "capture" the output of the taglib and return it to the caller. The buffer can be appended to it's parent buffer directly without extra object generation (like converting to java.lang.String in between). for example this line of code in a taglib would just append the buffer returned from the body closure evaluation to the buffer of the taglib:
  `out << body()`
  other example:
  `out << g.render(template: '/some/template', model:[somebean: somebean])`
  There's no extra java.lang.String generation overhead.

  There's a java.io.Writer interface for appending character data to the buffer and a java.io.Reader interface for reading data.

  Each getReader() call will create a new reader instance that keeps it own state.
  There is a alternative method getReader(boolean) for creating the reader. When reader is created by calling getReader(true), the reader will remove already read characters from the buffer. In this mode only a single reader instance is supported.

  There's also several other options for reading data:
  readAsCharArray() reads the buffer to a char[] array
  readAsString() reads the buffer and wraps the char[] data as a String
  writeTo(Writer) writes the buffer to a java.io.Writer
  toCharArray() returns the buffer as a char[] array, caches the return value internally so that this method can be called several times.
  toString() returns the buffer as a String, caches the return value internally

  By using the "connectTo" method, one can connect the buffer directly to a target java.io.Writer. The internal buffer gets flushed automaticly to the target whenever the buffer gets filled up. See connectTo(Writer).

  This class is not thread-safe. Object instances of this class are intended to be used by a single Thread. The Reader and Writer interfaces can be open simultaneous and the same Thread can write and read several times.

  Main operation principle:

  StreamCharBuffer keeps the buffer in a linked link of "chunks".
  The main difference compared to JDK in-memory buffers (StringBuffer, StringBuilder & StringWriter) is that the buffer can be held in several smaller buffers ("chunks" here).
  In JDK in-memory buffers, the buffer has to be expanded whenever it gets filled up. The old buffer's data is copied to the new one and the old one is discarded.
  In StreamCharBuffer, there are several ways to prevent unnecessary allocation & copy operations.

  There can be several different type of chunks: char arrays ( `CharBufferChunk`), String chunks (`StringChunk`) and other StreamCharBuffers as sub chunks (`StreamCharBufferSubChunk`).

  Child StreamCharBuffers can be changed after adding to parent buffer. The flush() method must be called on the child buffer's Writer to notify the parent that the child buffer's content has been changed (used for calculating total size).

  A StringChunk is appended to the linked list whenever a java.lang.String of a length that exceeds the "stringChunkMinSize" value is written to the buffer.

  If the buffer is in "connectTo" mode, any String or char[] that's length is over writeDirectlyToConnectedMinSize gets written directly to the target. The buffer content will get fully flushed to the target before writing the String or char[].

  There can be several targets "listening" the buffer in "connectTo" mode. The same content will be written to all targets.

  Growable chunksize: By default, a newly allocated chunk's size will grow based on the total size of all written chunks.
  The default growProcent value is 100. If the total size is currently 1024, the newly created chunk will have a internal buffer that's size is 1024.
  Growable chunksize can be turned off by setting the growProcent to 0.
  There's a default maximum chunksize of 1MB by default. The minimum size is the initial chunksize size.

  System properties to change default configuration parameters:

  System Property name | Description | Default value
  --- | --- | ---
  streamcharbuffer.chunksize | default chunk size - the size the first allocated buffer | 512
  streamcharbuffer.maxchunksize | maximum chunk size - the maximum size of the allocated buffer | 1048576
  streamcharbuffer.growprocent | growing buffer percentage - the newly allocated buffer is defined by total_size * (growpercent/100) | 100
  streamcharbuffer.subbufferchunkminsize | minimum size of child StreamCharBuffer chunk - if the size is smaller, the content is copied to the parent buffer | 512
  streamcharbuffer.substringchunkminsize | minimum size of String chunks - if the size is smaller, the content is copied to the buffer | 512
  streamcharbuffer.chunkminsize | minimum size of chunk that gets written directly to the target in connected mode. | 256

  Configuration values can also be changed for each instance of StreamCharBuffer individually. Default values are defined with System Properties.
  Authors:
    Lari Hotari, Sagire Software Oy

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `class` | `StreamCharBuffer.AbstractChunk` |
    `class` | `StreamCharBuffer.AbstractChunkReader` |
    `class` | `StreamCharBuffer.AllocatedBuffer` |
    `class` | `StreamCharBuffer.AllocatedBufferReader` |
    `class` | `StreamCharBuffer.CharBufferChunk` | The data in the buffer is stored in a linked list of StreamCharBufferChunks.
    `class` | `StreamCharBuffer.CharBufferChunkReader` |
    `static class` | `StreamCharBuffer.ChunkReader` |
    `class` | `StreamCharBuffer.ConnectToWriter` |
    `static class` | `StreamCharBuffer.ConnectedWriter` | Simple holder class for the connected writer
    `static class` | `StreamCharBuffer.ConnectedWritersWriter` |
    `static class` | `StreamCharBuffer.EncodedPart` |
    `static class` | `StreamCharBuffer.EncodingStatePart` |
    `private class` | `StreamCharBuffer.FixedCharArrayEncodedAppender` |
    `static interface` | `StreamCharBuffer.LazyInitializingMultipleWriter` |
    `static interface` | `StreamCharBuffer.LazyInitializingWriter` | Interface for a Writer that gets initialized if it is used Can be used for passing in to "connectTo" method of StreamCharBuffer
    `static class` | `StreamCharBuffer.MultiOutputWriter` | delegates to several writers, used in "connectTo" mode.
    `class` | `StreamCharBuffer.MultipartCharBufferChunk` |
    `class` | `StreamCharBuffer.MultipartStringChunk` |
    `private static class` | `StreamCharBuffer.SavedEncoder` |
    `static class` | `StreamCharBuffer.SingleOutputWriter` |
    `private static class` | `StreamCharBuffer.StreamCharBufferEncodedAppender` |
    `private class` | `StreamCharBuffer.StreamCharBufferKey` |
    `class` | `StreamCharBuffer.StreamCharBufferReader` |
    `class` | `StreamCharBuffer.StreamCharBufferSubChunk` |
    `class` | `StreamCharBuffer.StreamCharBufferSubChunkReader` |
    `class` | `StreamCharBuffer.StreamCharBufferWriter` | This is the java.io.Writer implementation for StreamCharBuffer
    `class` | `StreamCharBuffer.StringChunk` | StringChunk is a wrapper for java.lang.String.
    `class` | `StreamCharBuffer.StringChunkReader` |

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private static int` | `CHUNK_MIN_SIZE` |
    `private static int` | `DEFAULT_CHUNK_SIZE` |
    `private static int` | `DEFAULT_CHUNK_SIZE_GROW_PROCENT` |
    `private static int` | `DEFAULT_MAX_CHUNK_SIZE` |
    `private static int` | `EXTERNALIZABLE_VERSION` |
    `private static int` | `SUB_BUFFERCHUNK_MIN_SIZE` |
    `private static int` | `SUB_STRINGCHUNK_MIN_SIZE` |
    `private static int` | `WRITE_DIRECT_MIN_SIZE` |
    `private StreamCharBuffer.AllocatedBuffer` | `allocBuffer` |
    `int` | `allocatedBufferIdSequence` |
    `int` | `bufferChangesCounter` |
    `private StreamCharBuffer.StreamCharBufferKey` | `bufferKey` |
    `private int` | `chunkMinSize` |
    `private int` | `chunkSize` |
    `private java.util.List<ConnectToWriter>` | `connectToWriters` |
    `private ConnectedWritersWriter` | `connectedWritersWriter` |
    `private java.util.Map<StreamCharBufferKey, StreamCharBufferSubChunk>` | `dynamicChunkMap` |
    `private AbstractChunk` | `firstChunk` |
    `private int` | `firstChunkSize` |
    `private int` | `growProcent` |
    `boolean` | `hasReaders` |
    `private AbstractChunk` | `lastChunk` |
    `java.io.Writer` | `lazyWriter` |
    `private static org.apache.commons.logging.Log` | `log` |
    `private int` | `maxChunkSize` |
    `private java.lang.Boolean` | `notConnectedToEncodeAwareWriters` |
    `boolean` | `notifyParentBuffersEnabled` |
    `private java.util.Set<java.lang.ref.SoftReference<StreamCharBufferKey>>` | `parentBuffers` |
    `boolean` | `preferSubChunkWhenWritingToOtherBuffer` |
    `int` | `readerCount` |
    `static long` | `serialVersionUID` |
    `private int` | `sizeAtLeast` |
    `private int` | `subBufferChunkMinSize` |
    `boolean` | `subBuffersEnabled` |
    `private int` | `subStringChunkMinSize` |
    `private int` | `totalCharsInDynamicChunks` |
    `private int` | `totalCharsInList` |
    `private int` | `totalChunkSize` |
    `private int` | `writeDirectlyToConnectedMinSize` |
    `private StreamCharBufferWriter` | `writer` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `StreamCharBuffer ()`
    `StreamCharBuffer (int chunkSize)`
    `StreamCharBuffer (int chunkSize, int growProcent)`
    `StreamCharBuffer (int chunkSize, int growProcent, int maxChunkSize)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `AbstractChunk` | `addChunk(AbstractChunk newChunk)`
    `` | `void` | `addParentBuffer(StreamCharBuffer parent)`
    `` | `int` | `allocateSpace(EncodingState encodingState)`
    `` | `private int` | `appendCharBufferChunk(EncodingState encodingState, boolean flushInConnected, boolean allocate)`
    `` | `public void` | `appendStreamCharBufferChunk(StreamCharBuffer subBuffer)`
    `` | `public void` | `appendStreamCharBufferChunk(StreamCharBuffer subBuffer, java.util.List<Encoder> encoders)`
    `` | `void` | `appendStringChunk(EncodingState encodingState, java.lang.String str, int off, int len)`
    `` | `protected static final void` | `arrayCopy(char[] src, int srcPos, char[] dest, int destPos, int length)`
    `` | `public boolean` | `asBoolean()`
    `` | `public java.lang.Object` | `asType(java.lang.Class clazz)`
    `` | `protected boolean` | `bufferChanged(StreamCharBuffer buffer)`
    `` | `private boolean` | `calculateIsSizeLarger(int minSize)`
    `` | `public char` | `charAt(int index)`
    `` | `public final void` | `clear()` Clears the buffer and notifies the parents of this buffer of the change.
    `` | `public StreamCharBuffer` | `clone()`
    `` | `public final void` | `connectTo(java.io.Writer w)` Connect this buffer to a target Writer.
    `` | `public final void` | `connectTo(java.io.Writer w, boolean autoFlush)`
    `` | `public final void` | `connectTo(LazyInitializingWriter w)`
    `` | `public final void` | `connectTo(LazyInitializingWriter w, boolean autoFlush)`
    `` | `public LazyInitializingWriter` | `createEncodingInitializer(EncoderAware encoderLookup, EncodingStateRegistryLookup encodingStateRegistryLookup, LazyInitializingWriter writers)`
    `` | `public java.util.List<EncodedPart>` | `dumpEncodedParts()`
    `` | `protected void` | `emptyAfterReading()`
    `` | `public java.lang.CharSequence` | `encode(Encoder encoder)`
    `` | `public final void` | `encodeInStreamingModeTo(EncoderAware encoderLookup, EncodingStateRegistryLookup encodingStateRegistryLookup, boolean autoFlush, java.io.Writer w)`
    `` | `public final void` | `encodeInStreamingModeTo(EncoderAware encoderLookup, EncodingStateRegistryLookup encodingStateRegistryLookup, boolean autoFlush, LazyInitializingWriter writers)`
    `` | `public void` | `encodeTo(EncodedAppender appender, Encoder encoder)`
    `` | `public void` | `encodeTo(java.io.Writer writer, EncodesToWriter encoder)`
    `` | `public StreamCharBuffer` | `encodeToBuffer(Encoder encoder)`
    `` | `public StreamCharBuffer` | `encodeToBuffer(Encoder encoder, boolean allowSubBuffers, boolean notifyParentBuffersEnabled)`
    `` | `public StreamCharBuffer` | `encodeToBuffer(java.util.List<Encoder> encoders)`
    `` | `public StreamCharBuffer` | `encodeToBuffer(java.util.List<Encoder> encoders, boolean allowSubBuffers, boolean notifyParentBuffersEnabled)`
    `` | `public boolean` | `equals(java.lang.Object o)` equals uses String.equals to check for equality to support compatibility with String instances in maps, sets, etc.
    `` | `private void` | `flushToConnected(boolean forceFlush)`
    `` | `public int` | `getBufferChangesCounter()`
    `` | `public int` | `getChunkMinSize()`
    `` | `protected java.util.List<StreamCharBuffer>` | `getCurrentParentBuffers()`
    `` | `public java.io.Reader` | `getReader()` Creates a new Reader instance for reading/consuming data from the buffer.
    `` | `public java.io.Reader` | `getReader(boolean removeAfterReading)` Like getReader(), but when removeAfterReading is true, the read data will be removed from the buffer.
    `` | `public int` | `getSubBufferChunkMinSize()`
    `` | `public int` | `getSubStringChunkMinSize()`
    `` | `public int` | `getWriteDirectlyToConnectedMinSize()`
    `` | `public java.io.Writer` | `getWriter()`
    `` | `public java.io.Writer` | `getWriter()`
    `` | `public java.io.Writer` | `getWriter()` Writer interface for adding/writing data to the buffer.
    `` | `public java.io.Writer` | `getWriterForEncoder()`
    `` | `public java.io.Writer` | `getWriterForEncoder(Encoder encoder)`
    `` | `public java.io.Writer` | `getWriterForEncoder(Encoder encoder, EncodingStateRegistry encodingStateRegistry)`
    `` | `public java.io.Writer` | `getWriterForEncoder(Encoder encoder, EncodingStateRegistry encodingStateRegistry, boolean ignoreEncodingState)`
    `` | `boolean` | `hasQuicklyCalcutableSize()`
    `` | `public int` | `hashCode()` {@inheritDoc}
    `` | `private void` | `initConnected()`
    `` | `private void` | `initConnectedWritersWriter()`
    `` | `public LazyInitializingWriter[]` | `initializeMultiple(StreamCharBuffer buffer, boolean autoFlushMode)`
    `` | `public boolean` | `isAllowSubBuffers()`
    `` | `protected boolean` | `isChunkSizeResizeable()`
    `` | `public boolean` | `isConnectedMode()`
    `` | `public boolean` | `isEmpty()`
    `` | `private boolean` | `isNotConnectedToEncoderAwareWriters()`
    `` | `boolean` | `isNotEmpty()`
    `` | `public boolean` | `isNotifyParentBuffersEnabled()`
    `` | `public boolean` | `isPreferSubChunkWhenWritingToOtherBuffer()`
    `` | `boolean` | `isSizeLarger(int minSize)`
    `` | `public int` | `length()`
    `` | `protected EncodingStateRegistry` | `lookupDefaultEncodingStateRegistry()`
    `` | `protected int` | `markBufferChanged()`
    `` | `public void` | `markEncoded(StringChunk strChunk)`
    `` | `public java.lang.Object` | `methodMissing(java.lang.String name, java.lang.Object args)` Delegates methodMissing to String object
    `` | `protected void` | `notifyBufferChange()`
    `` | `protected void` | `notifyPreferSubChunkEnabled()`
    `` | `public java.lang.String` | `plus(java.lang.String value)`
    `` | `public java.lang.String` | `plus(java.lang.Object value)`
    `` | `public void` | `readExternal(java.io.ObjectInput in)`
    `` | `private MultipartCharBufferChunk` | `readToSingleChunk()`
    `` | `public StringChunk` | `readToSingleStringChunk(boolean registerEncodingState)`
    `` | `public final void` | `removeConnections()`
    `` | `public final void` | `reset()`
    `` | `public final void` | `reset(boolean resetChunkSize)` resets the state of this buffer (empties it)
    `` | `protected void` | `resizeChunkSizeAsProcentageOfTotalSize()`
    `` | `public void` | `setAllowSubBuffers(boolean allowSubBuffers)`
    `` | `public void` | `setChunkMinSize(int size)`
    `` | `public void` | `setNotifyParentBuffersEnabled(boolean notifyParentBuffersEnabled)` By default the parent buffers (a buffer where this buffer has been appended to) get notified of changed to this buffer.
    `` | `public void` | `setPreferSubChunkWhenWritingToOtherBuffer(boolean prefer)`
    `` | `public void` | `setSubBufferChunkMinSize(int size)`
    `` | `public void` | `setSubStringChunkMinSize(int size)` Minimum size for a String to be added as a StringChunk instead of copying content to the char[] buffer of the current StreamCharBufferChunk
    `` | `public void` | `setWriteDirectlyToConnectedMinSize(int size)` Minimum size for a String or char[] to get written directly to connected writer (in "connectTo" mode).
    `` | `public int` | `size()`
    `` | `private void` | `startUsingConnectedWritersWriter()`
    `` | `public java.lang.CharSequence` | `subSequence(int start, int end)`
    `` | `public char[]` | `toCharArray()` Reads the buffer to a char[].
    `` | `public java.lang.String` | `toString()` {@inheritDoc}
    `` | `public void` | `writeExternal(java.io.ObjectOutput out)`
    `` | `public java.io.Writer` | `writeTo(java.io.Writer target)` Writes the buffer content to a target java.io.Writer
    `` | `public void` | `writeTo(java.io.Writer target, boolean flushTarget, boolean emptyAfter)` Writes the buffer content to a target java.io.Writer
    `` | `private static boolean` | `writeToEncodedAppender(StreamCharBuffer source, java.io.Writer target, EncodedAppender notAllowedAppender, boolean flush)`
    `` | `private void` | `writeToImpl(java.io.Writer target, boolean flushTarget, boolean emptyAfter)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class groovy.lang.GroovyObjectSupport` | `groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll(), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object)`

- - ### Field Detail

    - #### private static final int CHUNK_MIN_SIZE

    - #### private static final int DEFAULT_CHUNK_SIZE

    - #### private static final int DEFAULT_CHUNK_SIZE_GROW_PROCENT

    - #### private static final int DEFAULT_MAX_CHUNK_SIZE

    - #### private static final int EXTERNALIZABLE_VERSION

    - #### private static final int SUB_BUFFERCHUNK_MIN_SIZE

    - #### private static final int SUB_STRINGCHUNK_MIN_SIZE

    - #### private static final int WRITE_DIRECT_MIN_SIZE

    - #### private StreamCharBuffer.AllocatedBuffer allocBuffer

    - #### int allocatedBufferIdSequence

    - #### int bufferChangesCounter

    - #### private StreamCharBuffer.StreamCharBufferKey bufferKey

    - #### private int chunkMinSize

    - #### private int chunkSize

    - #### private java.util.List<ConnectToWriter> connectToWriters

    - #### private ConnectedWritersWriter connectedWritersWriter

    - #### private java.util.Map<StreamCharBufferKey, StreamCharBufferSubChunk> dynamicChunkMap

    - #### private AbstractChunk firstChunk

    - #### private final int firstChunkSize

    - #### private final int growProcent

    - #### boolean hasReaders

    - #### private AbstractChunk lastChunk

    - #### java.io.Writer lazyWriter

    - #### private static final org.apache.commons.logging.Log log

    - #### private final int maxChunkSize

    - #### private java.lang.Boolean notConnectedToEncodeAwareWriters

    - #### boolean notifyParentBuffersEnabled

    - #### private java.util.Set<java.lang.ref.SoftReference<StreamCharBufferKey>> parentBuffers

    - #### boolean preferSubChunkWhenWritingToOtherBuffer

    - #### int readerCount

    - #### static final long serialVersionUID

    - #### private int sizeAtLeast

    - #### private int subBufferChunkMinSize

    - #### boolean subBuffersEnabled

    - #### private int subStringChunkMinSize

    - #### private int totalCharsInDynamicChunks

    - #### private int totalCharsInList

    - #### private int totalChunkSize

    - #### private int writeDirectlyToConnectedMinSize

    - #### private final StreamCharBufferWriter writer

  - ### Constructor Detail

    - #### public StreamCharBuffer()

    - #### public StreamCharBuffer(int chunkSize)

    - #### public StreamCharBuffer(int chunkSize, int growProcent)

    - #### public StreamCharBuffer(int chunkSize, int growProcent, int maxChunkSize)

  - ### Method Detail

    - #### AbstractChunk addChunk(AbstractChunk newChunk)

    - #### void addParentBuffer(StreamCharBuffer parent)

    - #### int allocateSpace(EncodingState encodingState)

    - #### private int appendCharBufferChunk(EncodingState encodingState, boolean flushInConnected, boolean allocate)

    - #### public void appendStreamCharBufferChunk(StreamCharBuffer subBuffer)

    - #### public void appendStreamCharBufferChunk(StreamCharBuffer subBuffer, java.util.List<Encoder> encoders)

    - #### void appendStringChunk(EncodingState encodingState, java.lang.String str, int off, int len)

    - #### protected static final void arrayCopy(char[] src, int srcPos, char[] dest, int destPos, int length)

    - #### public boolean asBoolean()

    - #### public java.lang.Object asType(java.lang.Class clazz)

    - #### protected boolean bufferChanged(StreamCharBuffer buffer)

    - #### private boolean calculateIsSizeLarger(int minSize)

    - #### public char charAt(int index)

    - #### public final void clear()

      Clears the buffer and notifies the parents of this buffer of the change.

    - #### @java.lang.Override public StreamCharBuffer clone()

    - #### public final void connectTo(java.io.Writer w)

      Connect this buffer to a target Writer. When the buffer (a chunk) get filled up, it will automaticly write it's content to the Writer

      Parameters:
        w

    - #### public final void connectTo(java.io.Writer w, boolean autoFlush)

    - #### public final void connectTo(LazyInitializingWriter w)

    - #### public final void connectTo(LazyInitializingWriter w, boolean autoFlush)

    - #### public LazyInitializingWriter createEncodingInitializer(EncoderAware encoderLookup, EncodingStateRegistryLookup encodingStateRegistryLookup, LazyInitializingWriter writers)

    - #### public java.util.List<EncodedPart> dumpEncodedParts()

    - #### protected void emptyAfterReading()

    - #### public java.lang.CharSequence encode(Encoder encoder)

    - #### public final void encodeInStreamingModeTo(EncoderAware encoderLookup, EncodingStateRegistryLookup encodingStateRegistryLookup, boolean autoFlush, java.io.Writer w)

    - #### public final void encodeInStreamingModeTo(EncoderAware encoderLookup, EncodingStateRegistryLookup encodingStateRegistryLookup, boolean autoFlush, LazyInitializingWriter writers)

    - #### public void encodeTo(EncodedAppender appender, Encoder encoder)

    - #### @java.lang.Override public void encodeTo(java.io.Writer writer, EncodesToWriter encoder)

    - #### public StreamCharBuffer encodeToBuffer(Encoder encoder)

    - #### public StreamCharBuffer encodeToBuffer(Encoder encoder, boolean allowSubBuffers, boolean notifyParentBuffersEnabled)

    - #### public StreamCharBuffer encodeToBuffer(java.util.List<Encoder> encoders)

    - #### public StreamCharBuffer encodeToBuffer(java.util.List<Encoder> encoders, boolean allowSubBuffers, boolean notifyParentBuffersEnabled)

    - #### @java.lang.Override public boolean equals(java.lang.Object o)

      equals uses String.equals to check for equality to support compatibility with String instances in maps, sets, etc.

      See Also:
        java.lang.Object#equals(java.lang.Object)

    - #### private void flushToConnected(boolean forceFlush)

    - #### public int getBufferChangesCounter()

    - #### public int getChunkMinSize()

    - #### protected java.util.List<StreamCharBuffer> getCurrentParentBuffers()

    - #### public java.io.Reader getReader()

      Creates a new Reader instance for reading/consuming data from the buffer. Each call creates a new instance that will keep it's reading state. There can be several readers on the buffer. (single thread only supported)

      Returns:
        the Reader

    - #### public java.io.Reader getReader(boolean removeAfterReading)

      Like getReader(), but when removeAfterReading is true, the read data will be removed from the buffer.

      Parameters:
        removeAfterReading
      Returns:
        the Reader

    - #### public int getSubBufferChunkMinSize()

    - #### public int getSubStringChunkMinSize()

    - #### public int getWriteDirectlyToConnectedMinSize()

    - #### public java.io.Writer getWriter()

    - Writer interface for adding/writing data to the buffer.

      Returns:
        the Writer

    - #### public java.io.Writer getWriterForEncoder()

    - #### public java.io.Writer getWriterForEncoder(Encoder encoder)

    - #### public java.io.Writer getWriterForEncoder(Encoder encoder, EncodingStateRegistry encodingStateRegistry)

    - #### public java.io.Writer getWriterForEncoder(Encoder encoder, EncodingStateRegistry encodingStateRegistry, boolean ignoreEncodingState)

    - #### boolean hasQuicklyCalcutableSize()

    - #### @java.lang.Override public int hashCode()

      {@inheritDoc} Uses String's hashCode to support compatibility with String instances in maps, sets, etc.

      See Also:
        java.lang.Object#hashCode()

    - #### private void initConnected()

    - #### private void initConnectedWritersWriter()

    - #### public LazyInitializingWriter[] initializeMultiple(StreamCharBuffer buffer, boolean autoFlushMode)

    - #### public boolean isAllowSubBuffers()

    - #### protected boolean isChunkSizeResizeable()

    - #### public boolean isConnectedMode()

    - #### public boolean isEmpty()

    - #### private boolean isNotConnectedToEncoderAwareWriters()

    - #### boolean isNotEmpty()

    - #### public boolean isNotifyParentBuffersEnabled()

    - #### public boolean isPreferSubChunkWhenWritingToOtherBuffer()

    - #### boolean isSizeLarger(int minSize)

    - #### public int length()

    - #### protected EncodingStateRegistry lookupDefaultEncodingStateRegistry()

    - #### protected int markBufferChanged()

    - #### public void markEncoded(StringChunk strChunk)

    - #### public java.lang.Object methodMissing(java.lang.String name, java.lang.Object args)

      Delegates methodMissing to String object

      Parameters:
        `name` - The name of the method
        `args` - The arguments
      Returns:
        The return value

    - #### protected void notifyBufferChange()

    - #### protected void notifyPreferSubChunkEnabled()

    - #### public java.lang.String plus(java.lang.String value)

    - #### public java.lang.String plus(java.lang.Object value)

    - #### public void readExternal(java.io.ObjectInput in)

    - #### private MultipartCharBufferChunk readToSingleChunk()

    - #### public StringChunk readToSingleStringChunk(boolean registerEncodingState)

    - #### public final void removeConnections()

    - #### public final void reset()

    - #### public final void reset(boolean resetChunkSize)

      resets the state of this buffer (empties it)

      Parameters:
        resetChunkSize

    - #### protected void resizeChunkSizeAsProcentageOfTotalSize()

    - #### public void setAllowSubBuffers(boolean allowSubBuffers)

    - #### public void setChunkMinSize(int size)

    - #### public void setNotifyParentBuffersEnabled(boolean notifyParentBuffersEnabled)

      By default the parent buffers (a buffer where this buffer has been appended to) get notified of changed to this buffer. You can control the notification behavior with this property. Setting this property to false will also clear the references to parent buffers if there are any.

      Parameters:
        notifyParentBuffersEnabled

    - #### public void setPreferSubChunkWhenWritingToOtherBuffer(boolean prefer)

    - #### public void setSubBufferChunkMinSize(int size)

    - #### public void setSubStringChunkMinSize(int size)

      Minimum size for a String to be added as a StringChunk instead of copying content to the char[] buffer of the current StreamCharBufferChunk

      Parameters:
        size

    - #### public void setWriteDirectlyToConnectedMinSize(int size)

      Minimum size for a String or char[] to get written directly to connected writer (in "connectTo" mode).

      Parameters:
        size

    - #### public int size()

    - #### private void startUsingConnectedWritersWriter()

    - #### public java.lang.CharSequence subSequence(int start, int end)

    - #### public char[] toCharArray()

      Reads the buffer to a char[]. Caches the result if there aren't any readers.

      Returns:
        the chars

    - #### @java.lang.Override public java.lang.String toString()

      {@inheritDoc} Reads (and empties) the buffer to a String, but caches the return value for subsequent calls. If more content has been added between 2 calls, the returned value will be joined from the previously cached value and the data read from the buffer.

      See Also:
        java.lang.Object#toString()

    - #### public void writeExternal(java.io.ObjectOutput out)

    - #### public java.io.Writer writeTo(java.io.Writer target)

      Writes the buffer content to a target java.io.Writer

      throws:
        IOException
      Parameters:
        target

    - #### public void writeTo(java.io.Writer target, boolean flushTarget, boolean emptyAfter)

      Writes the buffer content to a target java.io.Writer

      throws:
        IOException
      Parameters:
        `target` - Writer
        `flushTarget` - calls target.flush() before finishing
        `emptyAfter` - empties the buffer if true

    - #### private static boolean writeToEncodedAppender(StreamCharBuffer source, java.io.Writer target, EncodedAppender notAllowedAppender, boolean flush)

    - #### private void writeToImpl(java.io.Writer target, boolean flushTarget, boolean emptyAfter)