org.hibernate.search.elasticsearch.util.impl

## Class ProgressiveCharBufferWriter

- java.lang.Object
- - java.io.Writer
  - - org.hibernate.search.elasticsearch.util.impl.ProgressiveCharBufferWriter

- All Implemented Interfaces:
    Closeable, Flushable, Appendable, AutoCloseable

      public class ProgressiveCharBufferWriter
      extends Writer

  A writer to a ContentEncoder, using an automatically growing, paged buffer to store input when flow control pushes back.

  To be used when your input source is not reactive (uses `Writer`), but you have multiple elements to write and thus could take advantage of reactive output to some extent.

  Author:
    Sanne Grinovero, Yoann Rodiere

- - ### Field Summary

    - ### Fields inherited from class java.io.Writer

      `lock`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ProgressiveCharBufferWriter(Charset charset, int charBufferSize, int pageSize)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `byteBufferContentSize()`
    `void` | `close()`
    `void` | `flush()`
    `void` | `flushToOutput()` Send all buffer pages to the `output`, Even those that are not full yet
    `boolean` | `isFlowControlPushingBack()`
    `void` | `resumePendingWrites()` Send all full buffer pages to the `output`.
    `void` | `setOutput(org.apache.http.nio.ContentEncoder output)` Set the encoder to write to when buffers are full.
    `void` | `write(char[] cbuf, int off, int len)`

    - ### Methods inherited from class java.io.Writer

      `append, append, append, write, write, write, write`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ProgressiveCharBufferWriter

          public ProgressiveCharBufferWriter(Charset charset,
                                             int charBufferSize,
                                             int pageSize)

  - ### Method Detail

    - #### setOutput

          public void setOutput(org.apache.http.nio.ContentEncoder output)

      Set the encoder to write to when buffers are full.

    - #### write

          public void write(char[] cbuf,
                            int off,
                            int len)
                     throws IOException

      Specified by:
        `write` in class `Writer`
      Throws:
        `IOException`

    - #### flush

          public void flush()
                     throws IOException

      Specified by:
        `flush` in interface `Flushable`
      Specified by:
        `flush` in class `Writer`
      Throws:
        `IOException`

    - #### close

          public void close()
                     throws IOException

      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in class `Writer`
      Throws:
        `IOException`

    - #### resumePendingWrites

          public void resumePendingWrites()
                                   throws IOException

      Send all full buffer pages to the `output`.

      Flow control may push back, in which case this method or `flushToOutput()` should be called again later.

      Throws:
        `IOException` - when `ContentEncoder.write(ByteBuffer)` fails.

    - #### isFlowControlPushingBack

          public boolean isFlowControlPushingBack()

      Returns:
        `true` if the `output` pushed back the last time a write was attempted, `false` otherwise.

    - #### flushToOutput

          public void flushToOutput()
                             throws IOException

      Send all buffer pages to the `output`, Even those that are not full yet

      Flow control may push back, in which case this method should be called again later.

      Throws:
        `IOException` - when `ContentEncoder.write(ByteBuffer)` fails.

    - #### byteBufferContentSize

          public int byteBufferContentSize()

      Returns:
        The current size of content stored in the byte buffer, in bytes. This does not include the content that has already been written to the `output`, nor the content of the char buffer (which can be flushed using `flush()`).

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved