@NotThreadSafe public abstract class AbstractContentEncoder extends java.lang.Object implements ContentEncoder
ContentEncoder that serves as a base for all content
encoder implementations.| 限定符和类型 | 字段和说明 |
|---|---|
protected SessionOutputBuffer |
buffer |
protected java.nio.channels.WritableByteChannel |
channel |
protected boolean |
completed
TODO: make private
|
protected HttpTransportMetricsImpl |
metrics |
| 构造器和说明 |
|---|
AbstractContentEncoder(java.nio.channels.WritableByteChannel channel,
SessionOutputBuffer buffer,
HttpTransportMetricsImpl metrics)
Creates an instance of this class.
|
| 限定符和类型 | 方法和说明 |
|---|---|
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitwriteprotected final java.nio.channels.WritableByteChannel channel
protected final SessionOutputBuffer buffer
protected final HttpTransportMetricsImpl metrics
protected boolean completed
public AbstractContentEncoder(java.nio.channels.WritableByteChannel channel,
SessionOutputBuffer buffer,
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 在接口中 ContentEncodertrue if all the content has been produced,
false otherwise.public void complete()
throws java.io.IOException
ContentEncodercomplete 在接口中 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