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
Basic
AsyncDataProducer
implementation that
generates data stream from content of a string.- Since:
- 5.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hc.core5.http.nio.entity.AbstractCharAsyncEntityProducer
AbstractCharAsyncEntityProducer.State
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CharBuffer
private final AtomicReference
<Exception> -
Constructor Summary
ConstructorsConstructorDescriptionStringAsyncEntityProducer
(CharSequence content) StringAsyncEntityProducer
(CharSequence content, int bufferSize, int fragmentSizeHint, ContentType contentType) StringAsyncEntityProducer
(CharSequence content, int bufferSize, ContentType contentType) StringAsyncEntityProducer
(CharSequence content, ContentType contentType) -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Returns the number of bytes immediately available for output.void
Triggered to signal a failure in data generation.boolean
Determines whether the producer can consistently produce the same content after invocation ofResourceHolder.releaseResources()
.protected void
produceData
(StreamChannel<CharBuffer> channel) Triggered to signal the ability of the underlying char channel to accept more data.void
Methods inherited from class org.apache.hc.core5.http.nio.entity.AbstractCharAsyncEntityProducer
available, getContentEncoding, getContentLength, getContentType, getTrailerNames, isChunked, produce, streamEnd, writeData
-
Field Details
-
-
exception
-
-
Constructor Details
-
StringAsyncEntityProducer
public StringAsyncEntityProducer(CharSequence content, int bufferSize, int fragmentSizeHint, ContentType contentType) -
StringAsyncEntityProducer
-
StringAsyncEntityProducer
-
StringAsyncEntityProducer
-
-
Method Details
-
isRepeatable
public boolean isRepeatable()Description copied from interface:AsyncEntityProducer
Determines whether the producer can consistently produce the same content after invocation ofResourceHolder.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 classAbstractCharAsyncEntityProducer
- Returns:
- the number of bytes immediately available for output
-
produceData
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 classAbstractCharAsyncEntityProducer
- Parameters:
channel
- the data channel capable to accepting more data.- Throws:
IOException
-
failed
Description copied from interface:AsyncEntityProducer
Triggered to signal a failure in data generation.- Parameters:
cause
- the cause of the failure.
-
getException
-
releaseResources
public void releaseResources()- Specified by:
releaseResources
in interfaceResourceHolder
- Overrides:
releaseResources
in classAbstractCharAsyncEntityProducer
-