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

public Class IdentityEncoder

extends AbstractContentEncoder
implements FileContentEncoder
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.nio.FileContentEncoder, org.apache.hc.core5.http.nio.ContentEncoder
Imports
java.io.IOException, java.nio.ByteBuffer, java.nio.channels.FileChannel, .WritableByteChannel, org.apache.hc.core5.http.impl.BasicHttpTransportMetrics, org.apache.hc.core5.http.nio.FileContentEncoder, .SessionOutputBuffer

Content encoder that writes data without any transformation. The end of the content entity is demarcated 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 a FileChannel to the underlying I/O session's channel whenever possible avoiding intermediate buffering in the session buffer.

Since
4.0

Field Summary

Modifier and TypeField and Description
private final int
Inherited from org.apache.hc.core5.http.impl.nio.AbstractContentEncoder:
bufferchannelcompletedmetrics

Constructor Summary

AccessConstructor and Description
public
IdentityEncoder(final WritableByteChannel
underlying channel.
channel
,
final SessionOutputBuffer
session buffer.
buffer
,
final BasicHttpTransportMetrics
transport metrics.
metrics
,
final int
fragment size hint defining an minimal size of a fragment that should be written out directly to the channel bypassing the session buffer. Value 0 disables fragment buffering.
chunkSizeHint
)

public

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public long
transfer(final FileChannel
the source FileChannel to transfer data from.
src
,
final long
The position within the file at which the transfer is to begin; must be non-negative
position
,
final long
The maximum number of bytes to be transferred; must be non-negative
count
)

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

Transfers a portion of entity content from the given file channel to the underlying network channel.
public int
write(final ByteBuffer
The buffer from which content is to be retrieved
src
)

Implements org.apache.hc.core5.http.nio.ContentEncoder.write.

Writes a portion of entity content to the underlying channel.
Inherited from org.apache.hc.core5.http.impl.nio.AbstractContentEncoder:
assertNotCompletedbufferchannelcompletecompleteflushToChannelisCompletedmetricswriteToBufferwriteToChannelwriteToChannel

Field Detail

fragHintback to summary
private final int fragHint

Constructor Detail

IdentityEncoderback to summary
public IdentityEncoder(final WritableByteChannel channel, final SessionOutputBuffer buffer, final BasicHttpTransportMetrics metrics, final int chunkSizeHint)
Parameters
channel:WritableByteChannel

underlying channel.

buffer:SessionOutputBuffer

session buffer.

metrics:BasicHttpTransportMetrics

transport metrics.

chunkSizeHint:int

fragment size hint defining an minimal size of a fragment that should be written out directly to the channel bypassing the session buffer. Value 0 disables fragment buffering.

Since
4.3
IdentityEncoderback to summary
public IdentityEncoder(final WritableByteChannel channel, final SessionOutputBuffer buffer, final BasicHttpTransportMetrics metrics)

Method Detail

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 src, final long position, final long count) throws IOException

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

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

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

Parameters
src:FileChannel

the source FileChannel to transfer data from.

position:long

The position within the file at which the transfer is to begin; must be non-negative

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.
writeback to summary
public int write(final ByteBuffer src) throws IOException

Implements org.apache.hc.core5.http.nio.ContentEncoder.write.

Doc from org.apache.hc.core5.http.nio.ContentEncoder.write.

Writes a portion of entity content to the underlying channel.

Parameters
src:ByteBuffer

The buffer from which content is to be retrieved

Returns:int

The number of bytes read, possibly zero

Annotations
@Override
Exceptions
IOException:
if I/O error occurs while writing content