Class AbstractContentDecoder
- java.lang.Object
-
- org.apache.hc.core5.http.impl.nio.AbstractContentDecoder
-
- All Implemented Interfaces:
ContentDecoder
- Direct Known Subclasses:
ChunkDecoder
,IdentityDecoder
,LengthDelimitedDecoder
public abstract class AbstractContentDecoder extends java.lang.Object implements ContentDecoder
AbstractContentDecoder
that serves as a base for all content decoder implementations.- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description (package private) SessionInputBuffer
buffer
(package private) java.nio.channels.ReadableByteChannel
channel
protected boolean
completed
(package private) BasicHttpTransportMetrics
metrics
-
Constructor Summary
Constructors Constructor Description AbstractContentDecoder(java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics)
Creates an instance of this class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SessionInputBuffer
buffer()
protected java.nio.channels.ReadableByteChannel
channel()
protected int
fillBufferFromChannel()
Reads from the channel to the session buffer.java.util.List<? extends Header>
getTrailers()
Returns content trailers if availableboolean
isCompleted()
Returnstrue
if the entity has been received in its entirety.protected BasicHttpTransportMetrics
metrics()
protected int
readFromChannel(java.nio.ByteBuffer dst)
Reads from the channel to the destination.protected int
readFromChannel(java.nio.ByteBuffer dst, int limit)
Reads from the channel to the destination.protected void
setCompleted()
Sets the completed status of this decoder to true.void
setCompleted(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, wait
-
Methods inherited from interface org.apache.hc.core5.http.nio.ContentDecoder
read
-
-
-
-
Field Detail
-
channel
final java.nio.channels.ReadableByteChannel channel
-
buffer
final SessionInputBuffer buffer
-
metrics
final BasicHttpTransportMetrics metrics
-
completed
protected boolean completed
-
-
Constructor Detail
-
AbstractContentDecoder
public AbstractContentDecoder(java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics 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 Detail
-
channel
protected java.nio.channels.ReadableByteChannel channel()
-
buffer
protected SessionInputBuffer buffer()
-
metrics
protected BasicHttpTransportMetrics metrics()
-
isCompleted
public boolean isCompleted()
Description copied from interface:ContentDecoder
Returnstrue
if the entity has been received in its entirety.- Specified by:
isCompleted
in interfaceContentDecoder
- Returns:
true
if all the content has been consumed,false
otherwise.
-
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
protected int readFromChannel(java.nio.ByteBuffer dst) throws java.io.IOException
Reads from the channel to the destination.- Parameters:
dst
- destination.- Returns:
- number of bytes transferred.
- Throws:
java.io.IOException
- Since:
- 4.3
-
fillBufferFromChannel
protected int fillBufferFromChannel() throws java.io.IOException
Reads from the channel to the session buffer.- Returns:
- number of bytes transferred.
- Throws:
java.io.IOException
- Since:
- 4.3
-
readFromChannel
protected int readFromChannel(java.nio.ByteBuffer dst, int limit) throws java.io.IOException
Reads from the channel to the destination.- Parameters:
dst
- destination.limit
- max number of bytes to transfer.- Returns:
- number of bytes transferred.
- Throws:
java.io.IOException
- Since:
- 4.3
-
getTrailers
public java.util.List<? extends Header> getTrailers()
Description copied from interface:ContentDecoder
Returns content trailers if available- Specified by:
getTrailers
in interfaceContentDecoder
- Returns:
- list of trailers
-
-