org.apache.hc.core5.http.nio.entity

## Class StringAsyncEntityProducer

- java.lang.Object
- - org.apache.hc.core5.http.nio.entity.AbstractCharAsyncEntityProducer
  - - org.apache.hc.core5.http.nio.entity.StringAsyncEntityProducer

- All Implemented Interfaces:
    EntityDetails, AsyncDataProducer, AsyncEntityProducer, ResourceHolder

      public class StringAsyncEntityProducer
      extends AbstractCharAsyncEntityProducer

  Basic `AsyncDataProducer` implementation that generates data stream from content of a string.
  Since:
    5.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StringAsyncEntityProducer(CharSequence content)`
    `StringAsyncEntityProducer(CharSequence content, ContentType contentType)`
    `StringAsyncEntityProducer(CharSequence content, int bufferSize, ContentType contentType)`
    `StringAsyncEntityProducer(CharSequence content, int bufferSize, int fragmentSizeHint, ContentType contentType)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected int` | `availableData()` Returns the number of bytes immediately available for output.
    `void` | `failed(Exception cause)` Triggered to signal a failure in data generation.
    `Exception` | `getException()`
    `boolean` | `isRepeatable()` Determines whether the producer can consistently produce the same content after invocation of `ResourceHolder.releaseResources()`.
    `protected void` | `produceData(StreamChannel<CharBuffer> channel)` Triggered to signal the ability of the underlying char channel to accept more data.
    `void` | `releaseResources()`

    - ### Methods inherited from class org.apache.hc.core5.http.nio.entity.AbstractCharAsyncEntityProducer

      `available, getContentEncoding, getContentLength, getContentType, getTrailerNames, isChunked, produce`

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

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

- - ### Constructor Detail

    - #### StringAsyncEntityProducer

          public StringAsyncEntityProducer(CharSequence content,
                                   int bufferSize,
                                   int fragmentSizeHint,
                                   ContentType contentType)

    - #### StringAsyncEntityProducer

          public StringAsyncEntityProducer(CharSequence content,
                                   int bufferSize,
                                   ContentType contentType)

    - #### StringAsyncEntityProducer

          public StringAsyncEntityProducer(CharSequence content,
                                   ContentType contentType)

    - #### StringAsyncEntityProducer

          public StringAsyncEntityProducer(CharSequence content)

  - ### Method Detail

    - #### isRepeatable

          public boolean isRepeatable()

      Description copied from interface: `AsyncEntityProducer`
      Determines whether the producer can consistently produce the same content after invocation of `ResourceHolder.releaseResources()`.

    - #### availableData

          protected int availableData()

      Description copied from class: `AbstractCharAsyncEntityProducer`
      Returns the number of bytes immediately available for output. This method can be used as a hint to control output events of the underlying I/O session.
      Specified by:
        `availableData` in class `AbstractCharAsyncEntityProducer`
      Returns:
        the number of bytes immediately available for output

    - #### produceData

          protected void produceData(StreamChannel<CharBuffer> channel)
                              throws IOException

      Description copied from class: `AbstractCharAsyncEntityProducer`
      Triggered to signal the ability of the underlying char channel to accept more data. The data producer can choose to write data immediately inside the call or asynchronously at some later point.

      `StreamChannel` passed to this method is threading-safe.

      Specified by:
        `produceData` in class `AbstractCharAsyncEntityProducer`
      Parameters:
        `channel` - the data channel capable to accepting more data.
      Throws:
        `IOException`

    - #### failed

          public void failed(Exception cause)

      Description copied from interface: `AsyncEntityProducer`
      Triggered to signal a failure in data generation.
      Parameters:
        `cause` - the cause of the failure.

    - #### getException

          public Exception getException()

    - #### releaseResources

          public void releaseResources()

      Specified by:
        `releaseResources` in interface `ResourceHolder`
      Overrides:
        `releaseResources` in class `AbstractCharAsyncEntityProducer`

Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.