Package: org.grails.buffer

## [Java] Class StreamByteBuffer

- org.grails.buffer.StreamByteBuffer

-     public class StreamByteBuffer
      extends java.lang.Object

  An in-memory buffer that provides OutputStream and InputStream interfaces. This is more efficient than using ByteArrayOutputStream/ByteArrayInputStream This is not thread-safe, it is intended to be used by a single Thread.

  Authors:
    Lari Hotari, Sagire Software Oy

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `enum` | `StreamByteBuffer.ReadMode` |
    `class` | `StreamByteBuffer.StreamByteBufferChunk` |
    `class` | `StreamByteBuffer.StreamByteBufferInputStream` |
    `class` | `StreamByteBuffer.StreamByteBufferOutputStream` |

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private static int` | `DEFAULT_CHUNK_SIZE` |
    `private int` | `chunkSize` |
    `private java.util.LinkedList<StreamByteBufferChunk>` | `chunks` |
    `private StreamByteBuffer.StreamByteBufferChunk` | `currentReadChunk` |
    `private StreamByteBuffer.StreamByteBufferChunk` | `currentWriteChunk` |
    `private StreamByteBuffer.StreamByteBufferInputStream` | `input` |
    `private StreamByteBuffer.StreamByteBufferOutputStream` | `output` |
    `private java.util.Iterator<StreamByteBufferChunk>` | `readIterator` |
    `private StreamByteBuffer.ReadMode` | `readMode` |
    `private int` | `totalBytesUnreadInIterator` |
    `private int` | `totalBytesUnreadInList` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `StreamByteBuffer ()`
    `StreamByteBuffer (int chunkSize)`
    `StreamByteBuffer (int chunkSize, StreamByteBuffer.ReadMode readMode)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected int` | `allocateSpace()`
    `` | `public void` | `clear()`
    `` | `public java.io.InputStream` | `getInputStream()`
    `` | `public java.io.OutputStream` | `getOutputStream()`
    `` | `public StreamByteBuffer.ReadMode` | `getReadMode()`
    `` | `protected int` | `prepareRead()`
    `` | `private void` | `prepareRetainAfterReading()`
    `` | `public byte[]` | `readAsByteArray()`
    `` | `public java.lang.String` | `readAsString(java.lang.String encoding)`
    `` | `public java.lang.String` | `readAsString(java.nio.charset.Charset charset)`
    `` | `public void` | `reset()`
    `` | `public void` | `retainAfterReadingMode()`
    `` | `public void` | `setReadMode(StreamByteBuffer.ReadMode readMode)`
    `` | `public int` | `totalBytesUnread()`
    `` | `public void` | `writeTo(java.io.OutputStream target)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### private static final int DEFAULT_CHUNK_SIZE

    - #### private int chunkSize

    - #### private java.util.LinkedList<StreamByteBufferChunk> chunks

    - #### private StreamByteBuffer.StreamByteBufferChunk currentReadChunk

    - #### private StreamByteBuffer.StreamByteBufferChunk currentWriteChunk

    - #### private StreamByteBuffer.StreamByteBufferInputStream input

    - #### private StreamByteBuffer.StreamByteBufferOutputStream output

    - #### private java.util.Iterator<StreamByteBufferChunk> readIterator

    - #### private StreamByteBuffer.ReadMode readMode

    - #### private int totalBytesUnreadInIterator

    - #### private int totalBytesUnreadInList

  - ### Constructor Detail

    - #### public StreamByteBuffer()

    - #### public StreamByteBuffer(int chunkSize)

    - #### public StreamByteBuffer(int chunkSize, StreamByteBuffer.ReadMode readMode)

  - ### Method Detail

    - #### protected int allocateSpace()

    - #### public void clear()

    - #### public java.io.InputStream getInputStream()

    - #### public java.io.OutputStream getOutputStream()

    - #### public StreamByteBuffer.ReadMode getReadMode()

    - #### protected int prepareRead()

    - #### private void prepareRetainAfterReading()

    - #### public byte[] readAsByteArray()

    - #### public java.lang.String readAsString(java.lang.String encoding)

    - #### public java.lang.String readAsString(java.nio.charset.Charset charset)

    - #### public void reset()

    - #### public void retainAfterReadingMode()

    - #### public void setReadMode(StreamByteBuffer.ReadMode readMode)

    - #### public int totalBytesUnread()

    - #### public void writeTo(java.io.OutputStream target)