Package org.apache.http.impl.nio.codecs
Class AbstractContentEncoder
java.lang.Object
org.apache.http.impl.nio.codecs.AbstractContentEncoder
- All Implemented Interfaces:
ContentEncoder
- Direct Known Subclasses:
ChunkEncoder,IdentityEncoder,LengthDelimitedEncoder
Abstract
ContentEncoder that serves as a base for all content
encoder implementations.- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final SessionOutputBufferprotected final WritableByteChannelprotected booleanTODO: make privateprotected final HttpTransportMetricsImpl -
Constructor Summary
ConstructorsConstructorDescriptionAbstractContentEncoder(WritableByteChannel channel, SessionOutputBuffer buffer, HttpTransportMetricsImpl metrics) Creates an instance of this class. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidcomplete()Terminates the content stream.private intdoWriteChunk(ByteBuffer src, boolean direct) private intdoWriteChunk(ByteBuffer src, int chunk, boolean direct) protected intFlushes content of the session buffer to the channel and updates transport metrics.booleanReturnstrueif the entity has been transferred in its entirety.protected intwriteToBuffer(ByteBuffer src, int limit) Transfers content of the source to the buffer and updates transport metrics.protected intwriteToChannel(ByteBuffer src) Flushes content of the given buffer to the channel and updates transport metrics.protected intwriteToChannel(ByteBuffer src, int limit) Transfers content of the source to the channel and updates transport metrics.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.http.nio.ContentEncoder
write
-
Field Details
-
channel
-
buffer
-
metrics
-
completed
protected boolean completedTODO: make private
-
-
Constructor Details
-
AbstractContentEncoder
public AbstractContentEncoder(WritableByteChannel channel, SessionOutputBuffer buffer, HttpTransportMetricsImpl metrics) Creates an instance of this class.- Parameters:
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.
-
-
Method Details
-
isCompleted
public boolean isCompleted()Description copied from interface:ContentEncoderReturnstrueif the entity has been transferred in its entirety.- Specified by:
isCompletedin interfaceContentEncoder- Returns:
trueif all the content has been produced,falseotherwise.
-
complete
Description copied from interface:ContentEncoderTerminates the content stream.- Specified by:
completein interfaceContentEncoder- Throws:
IOException- if I/O error occurs while writing content
-
assertNotCompleted
protected void assertNotCompleted() -
flushToChannel
Flushes content of the session buffer to the channel and updates transport metrics.- Returns:
- number of bytes written to the channel.
- Throws:
IOException- Since:
- 4.3
-
writeToChannel
Flushes content of the given buffer to the channel and updates transport metrics.- Returns:
- number of bytes written to the channel.
- Throws:
IOException- Since:
- 4.3
-
writeToChannel
Transfers content of the source to the channel and updates transport metrics.- Parameters:
src- source.limit- max number of bytes to transfer.- Returns:
- number of bytes transferred.
- Throws:
IOException- Since:
- 4.3
-
writeToBuffer
Transfers content of the source to the buffer and updates transport metrics.- Parameters:
src- source.limit- max number of bytes to transfer.- Returns:
- number of bytes transferred.
- Throws:
IOException- Since:
- 4.3
-
doWriteChunk
- Throws:
IOException
-
doWriteChunk
- Throws:
IOException
-