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
BasicAsyncDataProducer
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
-
-
Constructor Summary
Constructors Constructor Description StringAsyncEntityProducer(java.lang.CharSequence content)
StringAsyncEntityProducer(java.lang.CharSequence content, int bufferSize, int fragmentSizeHint, ContentType contentType)
StringAsyncEntityProducer(java.lang.CharSequence content, int bufferSize, ContentType contentType)
StringAsyncEntityProducer(java.lang.CharSequence content, ContentType contentType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
availableData()
Returns the number of bytes immediately available for output.void
failed(java.lang.Exception cause)
Triggered to signal a failure in data generation.java.lang.Exception
getException()
boolean
isRepeatable()
Determines whether the producer can consistently produce the same content after invocation ofResourceHolder.releaseResources()
.protected void
produceData(StreamChannel<java.nio.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, streamEnd, writeData
-
-
-
-
Constructor Detail
-
StringAsyncEntityProducer
public StringAsyncEntityProducer(java.lang.CharSequence content, int bufferSize, int fragmentSizeHint, ContentType contentType)
-
StringAsyncEntityProducer
public StringAsyncEntityProducer(java.lang.CharSequence content, int bufferSize, ContentType contentType)
-
StringAsyncEntityProducer
public StringAsyncEntityProducer(java.lang.CharSequence content, ContentType contentType)
-
StringAsyncEntityProducer
public StringAsyncEntityProducer(java.lang.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 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
protected void produceData(StreamChannel<java.nio.CharBuffer> channel) throws java.io.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 classAbstractCharAsyncEntityProducer
- Parameters:
channel
- the data channel capable to accepting more data.- Throws:
java.io.IOException
-
failed
public void failed(java.lang.Exception cause)
Description copied from interface:AsyncEntityProducer
Triggered to signal a failure in data generation.- Parameters:
cause
- the cause of the failure.
-
getException
public java.lang.Exception getException()
-
releaseResources
public void releaseResources()
- Specified by:
releaseResources
in interfaceResourceHolder
- Overrides:
releaseResources
in classAbstractCharAsyncEntityProducer
-
-