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

public final Class PathEntityProducer

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, java.nio.channels.SeekableByteChannel, java.nio.file.Files, .OpenOption, .Path, 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 a data stream from the content at a Path.
Since
5.2

Field Summary

Modifier and TypeField and Description
private static final int
private final ByteBuffer
private final AtomicReference<SeekableByteChannel>
private final boolean
private final ContentType
private boolean
private final AtomicReference<Exception>
private final Path
private final long
private final OpenOption[]

Constructor Summary

AccessConstructor and Description
public
PathEntityProducer(final Path file, final ContentType contentType, final boolean chunked, final OpenOption... openOptions)

public
PathEntityProducer(final Path file, final ContentType contentType, final OpenOption... openOptions)

public
PathEntityProducer(final Path file, final int bufferSize, final ContentType contentType, final boolean chunked, final OpenOption... openOptions)

public
PathEntityProducer(final Path file, final OpenOption... openOptions)

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.
dataStreamChannel
)

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

BUFFER_SIZEback to summary
private static final int BUFFER_SIZE
byteBufferback to summary
private final ByteBuffer byteBuffer
channelRefback to summary
private final AtomicReference<SeekableByteChannel> channelRef
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 Path file
lengthback to summary
private final long length
openOptionsback to summary
private final OpenOption[] openOptions

Constructor Detail

PathEntityProducerback to summary
public PathEntityProducer(final Path file, final ContentType contentType, final boolean chunked, final OpenOption... openOptions) throws IOException
PathEntityProducerback to summary
public PathEntityProducer(final Path file, final ContentType contentType, final OpenOption... openOptions) throws IOException
PathEntityProducerback to summary
public PathEntityProducer(final Path file, final int bufferSize, final ContentType contentType, final boolean chunked, final OpenOption... openOptions) throws IOException
PathEntityProducerback to summary
public PathEntityProducer(final Path file, final OpenOption... openOptions) throws IOException

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 dataStreamChannel) 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
dataStreamChannel: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