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

public abstract Class AbstractContentEncoder

extends Object
implements ContentEncoder
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.nio.ContentEncoder
Known Direct Subclasses
org.apache.hc.core5.http.impl.nio.ChunkEncoder, org.apache.hc.core5.http.impl.nio.IdentityEncoder, org.apache.hc.core5.http.impl.nio.LengthDelimitedEncoder
Imports
java.io.IOException, java.nio.ByteBuffer, java.nio.channels.WritableByteChannel, java.util.List, org.apache.hc.core5.http.Header, org.apache.hc.core5.http.impl.BasicHttpTransportMetrics, org.apache.hc.core5.http.nio.ContentEncoder, .SessionOutputBuffer, org.apache.hc.core5.util.Args, .Asserts

Abstract ContentEncoder that serves as a base for all content encoder implementations.
Since
4.0

Field Summary

Modifier and TypeField and Description
pack-priv final SessionOutputBuffer
pack-priv final WritableByteChannel
pack-priv boolean
pack-priv final BasicHttpTransportMetrics

Constructor Summary

AccessConstructor and Description
public
AbstractContentEncoder(final WritableByteChannel
the destination channel.
channel
,
final SessionOutputBuffer
the session output buffer that can be used to store session data for intermediate processing.
buffer
,
final BasicHttpTransportMetrics
Transport metrics of the underlying HTTP transport.
metrics
)

Creates an instance of this class.

Method Summary

Modifier and TypeMethod and Description
protected void
protected SessionOutputBuffer
protected WritableByteChannel
public void
complete(final List<? extends Header> trailers)

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

Terminates the content stream.
public final void
private int
doWriteChunk(final ByteBuffer src, final int chunk, final boolean direct)

private int
doWriteChunk(final ByteBuffer src, final boolean direct)

protected int

Returns:

number of bytes written to the channel.
flushToChannel
()

Flushes content of the session buffer to the channel and updates transport metrics.

public boolean
isCompleted()

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

Returns true if the entity has been transferred in its entirety.
protected BasicHttpTransportMetrics
protected int

Returns:

number of bytes transferred.
writeToBuffer
(final ByteBuffer
source.
src
,
final int
max number of bytes to transfer.
limit
)

Transfers content of the source to the buffer and updates transport metrics.

protected int

Returns:

number of bytes written to the channel.
writeToChannel
(final ByteBuffer src)

Flushes content of the given buffer to the channel and updates transport metrics.

protected int

Returns:

number of bytes transferred.
writeToChannel
(final ByteBuffer
source.
src
,
final int
max number of bytes to transfer.
limit
)

Transfers content of the source to the channel and updates transport metrics.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
pack-priv final SessionOutputBuffer buffer
channelback to summary
pack-priv final WritableByteChannel channel
completedback to summary
pack-priv boolean completed
metricsback to summary
pack-priv final BasicHttpTransportMetrics metrics

Constructor Detail

AbstractContentEncoderback to summary
public AbstractContentEncoder(final WritableByteChannel channel, final SessionOutputBuffer buffer, final BasicHttpTransportMetrics metrics)

Creates an instance of this class.

Parameters
channel:WritableByteChannel

the destination channel.

buffer:SessionOutputBuffer

the session output buffer that can be used to store session data for intermediate processing.

metrics:BasicHttpTransportMetrics

Transport metrics of the underlying HTTP transport.

Method Detail

assertNotCompletedback to summary
protected void assertNotCompleted()
bufferback to summary
protected SessionOutputBuffer buffer()
channelback to summary
protected WritableByteChannel channel()
completeback to summary
public void complete(final List<? extends Header> trailers) throws IOException

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

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

Terminates the content stream.

Annotations
@Override
Exceptions
IOException:
if I/O error occurs while writing content
completeback to summary
public final void complete() throws IOException
doWriteChunkback to summary
private int doWriteChunk(final ByteBuffer src, final int chunk, final boolean direct) throws IOException
doWriteChunkback to summary
private int doWriteChunk(final ByteBuffer src, final boolean direct) throws IOException
flushToChannelback to summary
protected int flushToChannel() throws IOException

Flushes content of the session buffer to the channel and updates transport metrics.

Returns:int

number of bytes written to the channel.

Since
4.3
isCompletedback to summary
public boolean isCompleted()

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

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

Returns true if the entity has been transferred in its entirety.

Returns:boolean

true if all the content has been produced, false otherwise.

Annotations
@Override
metricsback to summary
protected BasicHttpTransportMetrics metrics()
writeToBufferback to summary
protected int writeToBuffer(final ByteBuffer src, final int limit) throws IOException

Transfers content of the source to the buffer and updates transport metrics.

Parameters
src:ByteBuffer

source.

limit:int

max number of bytes to transfer.

Returns:int

number of bytes transferred.

Since
4.3
writeToChannelback to summary
protected int writeToChannel(final ByteBuffer src) throws IOException

Flushes content of the given buffer to the channel and updates transport metrics.

Returns:int

number of bytes written to the channel.

Since
4.3
writeToChannelback to summary
protected int writeToChannel(final ByteBuffer src, final int limit) throws IOException

Transfers content of the source to the channel and updates transport metrics.

Parameters
src:ByteBuffer

source.

limit:int

max number of bytes to transfer.

Returns:int

number of bytes transferred.

Since
4.3