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

public Class BasicAsyncEntityProducer

extends Object
implements AsyncEntityProducer
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.nio.AsyncEntityProducer, org.apache.hc.core5.http.EntityDetails, org.apache.hc.core5.http.nio.AsyncDataProducer, org.apache.hc.core5.http.nio.ResourceHolder
Imports
java.io.IOException, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.Charset, .StandardCharsets, java.util.Set, java.util.concurrent.atomic.AtomicReference, org.apache.hc.core5.http.ContentType, org.apache.hc.core5.http.nio.AsyncEntityProducer, .DataStreamChannel, org.apache.hc.core5.util.Args

Basic AsyncEntityProducer implementation that generates data stream from content of a byte array.
Since
5.0

Field Summary

Modifier and TypeField and Description
private final ByteBuffer
private final boolean
private final ContentType
private final AtomicReference<Exception>
private final int

Constructor Summary

AccessConstructor and Description
public
BasicAsyncEntityProducer(final byte[] content, final ContentType contentType, final boolean chunked)

public
BasicAsyncEntityProducer(final byte[] content, final ContentType contentType)

public
BasicAsyncEntityProducer(final byte[] content)

public
BasicAsyncEntityProducer(final CharSequence content, final ContentType contentType, final boolean chunked)

public
BasicAsyncEntityProducer(final CharSequence content, final ContentType contentType)

public

Method Summary

Modifier and TypeMethod and Description
public int
available()

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.available.

Returns the number of bytes immediately available for output.
public final 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 String
getContentEncoding()

Implements org.apache.hc.core5.http.EntityDetails.getContentEncoding.

Returns content encoding of the entity, if known.
public long
getContentLength()

Implements org.apache.hc.core5.http.EntityDetails.getContentLength.

Returns length of the entity, if known.
public final String
getContentType()

Implements org.apache.hc.core5.http.EntityDetails.getContentType.

Returns content type of the entity, if known.
public final Exception
public Set<String>
getTrailerNames()

Implements org.apache.hc.core5.http.EntityDetails.getTrailerNames.

Preliminary declaration of trailing headers.
public boolean
isChunked()

Implements org.apache.hc.core5.http.EntityDetails.isChunked.

Returns chunked transfer hint for this entity.
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().
public final void
produce(final DataStreamChannel
the data channel capable to accepting more data.
channel
)

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.produce.

Triggered to signal the ability of the underlying data channel to accept more data.
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bytebufback to summary
private final ByteBuffer bytebuf
chunkedback to summary
private final boolean chunked
contentTypeback to summary
private final ContentType contentType
exceptionback to summary
private final AtomicReference<Exception> exception
lengthback to summary
private final int length

Constructor Detail

BasicAsyncEntityProducerback to summary
public BasicAsyncEntityProducer(final byte[] content, final ContentType contentType, final boolean chunked)
BasicAsyncEntityProducerback to summary
public BasicAsyncEntityProducer(final byte[] content, final ContentType contentType)
BasicAsyncEntityProducerback to summary
public BasicAsyncEntityProducer(final byte[] content)
BasicAsyncEntityProducerback to summary
public BasicAsyncEntityProducer(final CharSequence content, final ContentType contentType, final boolean chunked)
BasicAsyncEntityProducerback to summary
public BasicAsyncEntityProducer(final CharSequence content, final ContentType contentType)
BasicAsyncEntityProducerback to summary
public BasicAsyncEntityProducer(final CharSequence content)

Method Detail

availableback to summary
public int available()

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.available.

Doc from org.apache.hc.core5.http.nio.AsyncDataProducer.available.

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 final 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
getContentEncodingback to summary
public String getContentEncoding()

Implements org.apache.hc.core5.http.EntityDetails.getContentEncoding.

Doc from org.apache.hc.core5.http.EntityDetails.getContentEncoding.

Returns content encoding of the entity, if known.

Annotations
@Override
getContentLengthback to summary
public long getContentLength()

Implements org.apache.hc.core5.http.EntityDetails.getContentLength.

Doc from org.apache.hc.core5.http.EntityDetails.getContentLength.

Returns length of the entity, if known.

Annotations
@Override
getContentTypeback to summary
public final String getContentType()

Implements org.apache.hc.core5.http.EntityDetails.getContentType.

Doc from org.apache.hc.core5.http.EntityDetails.getContentType.

Returns content type of the entity, if known.

Annotations
@Override
getExceptionback to summary
public final Exception getException()
getTrailerNamesback to summary
public Set<String> getTrailerNames()

Implements org.apache.hc.core5.http.EntityDetails.getTrailerNames.

Doc from org.apache.hc.core5.http.EntityDetails.getTrailerNames.

Preliminary declaration of trailing headers.

Annotations
@Override
isChunkedback to summary
public boolean isChunked()

Implements org.apache.hc.core5.http.EntityDetails.isChunked.

Doc from org.apache.hc.core5.http.EntityDetails.isChunked.

Returns chunked transfer hint for this entity.

The behavior of wrapping entities is implementation dependent, but should respect the primary purpose.

Annotations
@Override
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
produceback to summary
public final void produce(final DataStreamChannel channel) throws IOException

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.produce.

Doc from org.apache.hc.core5.http.nio.AsyncDataProducer.produce.

Triggered to signal the ability of the underlying data channel to accept more data. The data producer can choose to write data immediately inside the call or asynchronously at some later point.

Parameters
channel:DataStreamChannel

the data channel capable to accepting more data.

Annotations
@Override
releaseResourcesback to summary
public void releaseResources()

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

Annotations
@Override