ContentEncoderChunkEncoder, IdentityEncoder, LengthDelimitedEncoderpublic abstract class AbstractContentEncoder extends java.lang.Object implements ContentEncoder
ContentEncoder that serves as a base for all content
encoder implementations.| Modifier and Type | Field | Description |
|---|---|---|
protected SessionOutputBuffer |
buffer |
|
protected java.nio.channels.WritableByteChannel |
channel |
|
protected boolean |
completed |
TODO: make private
|
protected org.apache.http.impl.io.HttpTransportMetricsImpl |
metrics |
| Constructor | Description |
|---|---|
AbstractContentEncoder(java.nio.channels.WritableByteChannel channel,
SessionOutputBuffer buffer,
org.apache.http.impl.io.HttpTransportMetricsImpl metrics) |
Creates an instance of this class.
|
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
assertNotCompleted() |
|
void |
complete() |
Terminates the content stream.
|
protected int |
flushToChannel() |
Flushes content of the session buffer to the channel and updates transport metrics.
|
boolean |
isCompleted() |
Returns
true if the entity has been transferred in its
entirety. |
protected int |
writeToBuffer(java.nio.ByteBuffer src,
int limit) |
Transfers content of the source to the buffer and updates transport metrics.
|
protected int |
writeToChannel(java.nio.ByteBuffer src) |
Flushes content of the given buffer to the channel and updates transport metrics.
|
protected int |
writeToChannel(java.nio.ByteBuffer src,
int limit) |
Transfers content of the source to the channel and updates transport metrics.
|
writeprotected final java.nio.channels.WritableByteChannel channel
protected final SessionOutputBuffer buffer
protected final org.apache.http.impl.io.HttpTransportMetricsImpl metrics
protected boolean completed
public AbstractContentEncoder(java.nio.channels.WritableByteChannel channel,
SessionOutputBuffer buffer,
org.apache.http.impl.io.HttpTransportMetricsImpl metrics)
channel - the destination channel.buffer - the session output buffer that can be used to store
session data for intermediate processing.metrics - Transport metrics of the underlying HTTP transport.public boolean isCompleted()
ContentEncodertrue if the entity has been transferred in its
entirety.isCompleted in interface ContentEncodertrue if all the content has been produced,
false otherwise.public void complete()
throws java.io.IOException
ContentEncodercomplete in interface ContentEncoderjava.io.IOException - if I/O error occurs while writing contentprotected void assertNotCompleted()
protected int flushToChannel()
throws java.io.IOException
java.io.IOExceptionprotected int writeToChannel(java.nio.ByteBuffer src)
throws java.io.IOException
java.io.IOExceptionprotected int writeToChannel(java.nio.ByteBuffer src,
int limit)
throws java.io.IOException
src - source.limit - max number of bytes to transfer.java.io.IOExceptionprotected int writeToBuffer(java.nio.ByteBuffer src,
int limit)
throws java.io.IOException
src - source.limit - max number of bytes to transfer.java.io.IOException