Class FixedLengthConsumer
java.lang.Object
org.simpleframework.http.message.UpdateConsumer
org.simpleframework.http.message.FixedLengthConsumer
- All Implemented Interfaces:
BodyConsumer, ByteConsumer
The
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.- Author:
- Niall Gallagher
-
Field Summary
Fields inherited from class UpdateConsumer
array, finished -
Constructor Summary
ConstructorsConstructorDescriptionFixedLengthConsumer(Allocator allocator, long limit) Constructor for theFixedLengthConsumerobject. -
Method Summary
Methods inherited from class UpdateConsumer
commit, consume, isFinished
-
Constructor Details
-
FixedLengthConsumer
Constructor for theFixedLengthConsumerobject. 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.- Parameters:
allocator- this is used to allocate the internal bufferlimit- this is the number of bytes that are to be read
-
-
Method Details
-
getBody
This is used to acquire the body that has been consumed. This will return a body which can be used to read the content of the message, also if the request is multipart upload then all of the parts are provided asAttachmentobjects. Each part can then be read as an individual message.- Returns:
- the body that has been consumed by this instance
-
update
This is used to process the bytes that have been read from the cursor. This will count the number of bytes read, once all of the bytes that form the body have been read this returns the number of bytes that represent the overflow.- Specified by:
updatein classUpdateConsumer- Parameters:
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 array- Returns:
- this returns the number of bytes overflow that is read
- Throws:
IOException
-