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

public final Class FileEntityProducer

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.File, .IOException, .RandomAccessFile, java.nio.ByteBuffer, 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.io.Closer, org.apache.hc.core5.util.Args, .Asserts

AsyncEntityProducer implementation that generates data stream from content of a File.
Since
5.0

Field Summary

Modifier and TypeField and Description
private final AtomicReference<RandomAccessFile>
private final ByteBuffer
private final boolean
private final ContentType
private boolean
private final AtomicReference<Exception>
private final File
private final long

Constructor Summary

AccessConstructor and Description
public
FileEntityProducer(final File file, final int bufferSize, final ContentType contentType, final boolean chunked)

public
FileEntityProducer(final File file, final ContentType contentType, final boolean chunked)

public
FileEntityProducer(final File file, 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 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 String
getContentType()

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

Returns content type of the entity, if known.
public 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 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

accessFileRefback to summary
private final AtomicReference<RandomAccessFile> accessFileRef
byteBufferback to summary
private final ByteBuffer byteBuffer
chunkedback to summary
private final boolean chunked
contentTypeback to summary
private final ContentType contentType
eofback to summary
private boolean eof
exceptionback to summary
private final AtomicReference<Exception> exception
fileback to summary
private final File file
lengthback to summary
private final long length

Constructor Detail

FileEntityProducerback to summary
public FileEntityProducer(final File file, final int bufferSize, final ContentType contentType, final boolean chunked)
FileEntityProducerback to summary
public FileEntityProducer(final File file, final ContentType contentType, final boolean chunked)
FileEntityProducerback to summary
public FileEntityProducer(final File file, final ContentType contentType)
FileEntityProducerback to summary
public FileEntityProducer(final File file)

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 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 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 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 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