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

public Class IdentityDecoder

extends AbstractContentDecoder
implements FileContentDecoder
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.nio.FileContentDecoder, org.apache.hc.core5.http.nio.ContentDecoder
Imports
java.io.IOException, java.nio.ByteBuffer, java.nio.channels.FileChannel, .ReadableByteChannel, org.apache.hc.core5.http.impl.BasicHttpTransportMetrics, org.apache.hc.core5.http.nio.FileContentDecoder, .SessionInputBuffer, org.apache.hc.core5.util.Args

Content decoder that reads data without any transformation. The end of the content entity is delineated by closing the underlying connection (EOF condition). Entities transferred using this input stream can be of unlimited length.

This decoder is optimized to transfer data directly from the underlying I/O session's channel to a FileChannel, whenever possible avoiding intermediate buffering in the session buffer.

Since
4.0

Field Summary

Inherited from org.apache.hc.core5.http.impl.nio.AbstractContentDecoder:
bufferchannelcompletedmetrics

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
read(final ByteBuffer
The buffer into which entity content is to be transferred
dst
)

Implements org.apache.hc.core5.http.nio.ContentDecoder.read.

Reads a portion of content from the underlying channel
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public long
transfer(final FileChannel
the target FileChannel to transfer data into.
dst
,
final long
The position within the file at which the transfer is to begin; must be non-negative. Must be less than or equal to the size of the file
position
,
final long
The maximum number of bytes to be transferred; must be non-negative
count
)

Implements org.apache.hc.core5.http.nio.FileContentDecoder.transfer.

Transfers a portion of entity content from the underlying network channel into the given file channel.
Inherited from org.apache.hc.core5.http.impl.nio.AbstractContentDecoder:
bufferchannelfillBufferFromChannelgetTrailersisCompletedmetricsreadFromChannelreadFromChannelsetCompletedsetCompleted

Constructor Detail

IdentityDecoderback to summary
public IdentityDecoder(final ReadableByteChannel channel, final SessionInputBuffer buffer, final BasicHttpTransportMetrics metrics)

Method Detail

readback to summary
public int read(final ByteBuffer dst) throws IOException

Implements org.apache.hc.core5.http.nio.ContentDecoder.read.

Doc from org.apache.hc.core5.http.nio.ContentDecoder.read.

Reads a portion of content from the underlying channel

Parameters
dst:ByteBuffer

The buffer into which entity content is to be transferred

Returns:int

The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream

Annotations
@Override
Exceptions
IOException:
if I/O error occurs while reading content
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
transferback to summary
public long transfer(final FileChannel dst, final long position, final long count) throws IOException

Implements org.apache.hc.core5.http.nio.FileContentDecoder.transfer.

Doc from org.apache.hc.core5.http.nio.FileContentDecoder.transfer.

Transfers a portion of entity content from the underlying network channel into the given file channel.

Warning

Many implementations cannot write beyond the length of the file. If the position exceeds the channel's size, some implementations may throw an IOException.

Parameters
dst:FileChannel

the target FileChannel to transfer data into.

position:long

The position within the file at which the transfer is to begin; must be non-negative. Must be less than or equal to the size of the file

count:long

The maximum number of bytes to be transferred; must be non-negative

Returns:long

The number of bytes, possibly zero, that were actually transferred

Annotations
@Override
Exceptions
IOException:
if some I/O error occurs.