Package org.apache.http.impl.nio.codecs
Class AbstractContentDecoder
java.lang.Object
org.apache.http.impl.nio.codecs.AbstractContentDecoder
- All Implemented Interfaces:
ContentDecoder
- Direct Known Subclasses:
ChunkDecoder,IdentityDecoder,LengthDelimitedDecoder
Abstract
ContentDecoder that serves as a base for all content
decoder implementations.- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final SessionInputBufferprotected final ReadableByteChannelprotected booleanprotected final org.apache.http.impl.io.HttpTransportMetricsImpl -
Constructor Summary
ConstructorsConstructorDescriptionAbstractContentDecoder(ReadableByteChannel channel, SessionInputBuffer buffer, org.apache.http.impl.io.HttpTransportMetricsImpl metrics) Creates an instance of this class. -
Method Summary
Modifier and TypeMethodDescriptionprotected intReads from the channel to the session buffer.booleanReturnstrueif the entity has been received in its entirety.protected intReads from the channel to the destination.protected intreadFromChannel(ByteBuffer dst, int limit) Reads from the channel to the destination.protected voidSets the completed status of this decoder to true.voidsetCompleted(boolean completed) Sets the completed status of this decoder.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.ContentDecoder
read
-
Field Details
-
channel
-
buffer
-
metrics
protected final org.apache.http.impl.io.HttpTransportMetricsImpl metrics -
completed
protected boolean completed
-
-
Constructor Details
-
AbstractContentDecoder
public AbstractContentDecoder(ReadableByteChannel channel, SessionInputBuffer buffer, org.apache.http.impl.io.HttpTransportMetricsImpl metrics) Creates an instance of this class.- Parameters:
channel- the source channel.buffer- the session input 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:ContentDecoderReturnstrueif the entity has been received in its entirety.- Specified by:
isCompletedin interfaceContentDecoder- Returns:
trueif all the content has been consumed,falseotherwise.
-
setCompleted
public void setCompleted(boolean completed) Sets the completed status of this decoder. Normally this is not necessary (the decoder will automatically complete when the underlying channel returns EOF). It is useful to mark the decoder as completed if you have some other means to know all the necessary data has been read and want to reuse the underlying connection for more messages.- Parameters:
completed- the completed status of this decoder.- Since:
- 4.4.11
-
setCompleted
protected void setCompleted()Sets the completed status of this decoder to true. Normally this is not necessary (the decoder will automatically complete when the underlying channel returns EOF). It is useful to mark the decoder as completed if you have some other means to know all the necessary data has been read and want to reuse the underlying connection for more messages.- Since:
- 4.4.11
-
readFromChannel
Reads from the channel to the destination.- Parameters:
dst- destination.- Returns:
- number of bytes transferred.
- Throws:
IOException- Since:
- 4.3
-
fillBufferFromChannel
Reads from the channel to the session buffer.- Returns:
- number of bytes transferred.
- Throws:
IOException- Since:
- 4.3
-
readFromChannel
Reads from the channel to the destination.- Parameters:
dst- destination.limit- max number of bytes to transfer.- Returns:
- number of bytes transferred.
- Throws:
IOException- Since:
- 4.3
-