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
BasicAsyncDataProducerimplementation 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 intavailableData()Returns the number of bytes immediately available for output.voidfailed(java.lang.Exception cause)Triggered to signal a failure in data generation.java.lang.ExceptiongetException()booleanisRepeatable()Determines whether the producer can consistently produce the same content after invocation ofResourceHolder.releaseResources().protected voidproduceData(StreamChannel<java.nio.CharBuffer> channel)Triggered to signal the ability of the underlying char channel to accept more data.voidreleaseResources()-
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:AsyncEntityProducerDetermines whether the producer can consistently produce the same content after invocation ofResourceHolder.releaseResources().
-
availableData
protected int availableData()
Description copied from class:AbstractCharAsyncEntityProducerReturns 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:
availableDatain 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:AbstractCharAsyncEntityProducerTriggered 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.StreamChannelpassed to this method is threading-safe.- Specified by:
produceDatain 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:AsyncEntityProducerTriggered 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:
releaseResourcesin interfaceResourceHolder- Overrides:
releaseResourcesin classAbstractCharAsyncEntityProducer
-
-