Top Description Fields Constructors Methods
org.apache.hc.core5.http.nio.entity

public Class StringAsyncEntityProducer

extends AbstractCharAsyncEntityProducer
Class Inheritance
Imports
java.io.IOException, java.nio.CharBuffer, java.util.concurrent.atomic.AtomicReference, org.apache.hc.core5.http.ContentType, org.apache.hc.core5.http.nio.StreamChannel, org.apache.hc.core5.util.Args, .Asserts

Basic org.apache.hc.core5.http.nio.AsyncDataProducer implementation that generates data stream from content of a string.
Since
5.0

Field Summary

Modifier and TypeField and Description
private final CharBuffer
private final AtomicReference<Exception>

Constructor Summary

AccessConstructor and Description
public
StringAsyncEntityProducer(final CharSequence content, final int bufferSize, final int fragmentSizeHint, final ContentType contentType)

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

public
StringAsyncEntityProducer(final CharSequence content, final ContentType contentType)

public

Method Summary

Modifier and TypeMethod and Description
protected int
availableData()

Implements abstract org.apache.hc.core5.http.nio.entity.AbstractCharAsyncEntityProducer.availableData.

Returns the number of bytes immediately available for output.
public void
failed(final Exception
the cause of the failure.
cause
)

Implements org.apache.hc.core5.http.nio.AsyncEntityProducer.failed.

Triggered to signal a failure in data generation.
public Exception
public boolean
isRepeatable()

Implements org.apache.hc.core5.http.nio.AsyncEntityProducer.isRepeatable.

Determines whether the producer can consistently produce the same content after invocation of ResourceHolder#releaseResources().
protected void
produceData(final StreamChannel<CharBuffer>
the data channel capable to accepting more data.
channel
)

Implements abstract org.apache.hc.core5.http.nio.entity.AbstractCharAsyncEntityProducer.produceData.

Triggered to signal the ability of the underlying char channel to accept more data.
public void
Inherited from org.apache.hc.core5.http.nio.entity.AbstractCharAsyncEntityProducer:
availablegetContentEncodinggetContentLengthgetContentTypegetTrailerNamesisChunkedproducestreamEndwriteData

Field Detail

contentback to summary
private final CharBuffer content
exceptionback to summary
private final AtomicReference<Exception> exception

Constructor Detail

StringAsyncEntityProducerback to summary
public StringAsyncEntityProducer(final CharSequence content, final int bufferSize, final int fragmentSizeHint, final ContentType contentType)
StringAsyncEntityProducerback to summary
public StringAsyncEntityProducer(final CharSequence content, final int bufferSize, final ContentType contentType)
StringAsyncEntityProducerback to summary
public StringAsyncEntityProducer(final CharSequence content, final ContentType contentType)
StringAsyncEntityProducerback to summary
public StringAsyncEntityProducer(final CharSequence content)

Method Detail

availableDataback to summary
protected int availableData()

Implements abstract org.apache.hc.core5.http.nio.entity.AbstractCharAsyncEntityProducer.availableData.

Doc from org.apache.hc.core5.http.nio.entity.AbstractCharAsyncEntityProducer.availableData.

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.

Returns:int

the number of bytes immediately available for output

Annotations
@Override
failedback to summary
public void failed(final Exception cause)

Implements org.apache.hc.core5.http.nio.AsyncEntityProducer.failed.

Doc from org.apache.hc.core5.http.nio.AsyncEntityProducer.failed.

Triggered to signal a failure in data generation.

Parameters
cause:Exception

the cause of the failure.

Annotations
@Override
getExceptionback to summary
public Exception getException()
isRepeatableback to summary
public boolean isRepeatable()

Implements org.apache.hc.core5.http.nio.AsyncEntityProducer.isRepeatable.

Doc from org.apache.hc.core5.http.nio.AsyncEntityProducer.isRepeatable.

Determines whether the producer can consistently produce the same content after invocation of ResourceHolder#releaseResources().

Annotations
@Override
produceDataback to summary
protected void produceData(final StreamChannel<CharBuffer> channel) throws IOException

Implements abstract org.apache.hc.core5.http.nio.entity.AbstractCharAsyncEntityProducer.produceData.

Doc from org.apache.hc.core5.http.nio.entity.AbstractCharAsyncEntityProducer.produceData.

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.

Parameters
channel:StreamChannel<CharBuffer>

the data channel capable to accepting more data.

Annotations
@Override
releaseResourcesback to summary
public void releaseResources()

Overrides org.apache.hc.core5.http.nio.entity.AbstractCharAsyncEntityProducer.releaseResources.

Implements org.apache.hc.core5.http.nio.ResourceHolder.releaseResources.

Annotations
@Override