public class FixedLengthConsumer extends UpdateConsumer
FixedLengthConsumer
object reads a fixed number of
bytes from a cursor. This is typically used when the Content-Length
header is used as the body delimiter. In order to determine when
the full body has been consumed this counts the bytes read. Once
all the bytes have been read any overflow will be reset. All of the
bytes read are appended to the internal buffer so they can be read.array, finished
Constructor and Description |
---|
FixedLengthConsumer(Allocator allocator,
long limit)
Constructor for the
FixedLengthConsumer object. |
Modifier and Type | Method and Description |
---|---|
Body |
getBody()
This is used to acquire the body that has been consumed.
|
protected int |
update(byte[] array,
int off,
int count)
This is used to process the bytes that have been read from the
cursor.
|
commit, consume, isFinished
public FixedLengthConsumer(Allocator allocator, long limit)
FixedLengthConsumer
object. This
is used to create a consumer that reads a fixed number of bytes
from a cursor and accumulates those bytes in an internal buffer
so that it can be read at a later stage.allocator
- this is used to allocate the internal bufferlimit
- this is the number of bytes that are to be readpublic Body getBody()
Attachment
objects.
Each part can then be read as an individual message.protected int update(byte[] array, int off, int count) throws IOException
update
in class UpdateConsumer
array
- this is a chunk read from the cursoroff
- this is the offset within the array the chunk startscount
- this is the number of bytes within the arrayIOException
Copyright © 2021. All rights reserved.