Package org.simpleframework.http.message
Class PartEntryConsumer
java.lang.Object
org.simpleframework.http.message.PartEntryConsumer
- All Implemented Interfaces:
ByteConsumer
The
PartEntryConsumer
object is used to consume each
part from the part list. This is combines the task of consuming
the part, which consists of a header and a body, and a boundary
which identifies the end of the message content.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BoundaryConsumer
This is used to consume the boundary at the end of a part.private final ByteConsumer
This is used to consume the actual part from the list. -
Constructor Summary
ConstructorsConstructorDescriptionPartEntryConsumer
(Allocator allocator, PartSeries series, byte[] terminal, long length) Constructor for thePartEntryConsumer
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
consume
(ByteCursor cursor) This is used to consume the part body from the cursor.boolean
isEnd()
This is used to determine whether the terminal token read is the final terminal token.boolean
This is used to determine whether the part body has been read from the cursor successfully.
-
Field Details
-
boundary
This is used to consume the boundary at the end of a part. -
consumer
This is used to consume the actual part from the list.
-
-
Constructor Details
-
PartEntryConsumer
Constructor for thePartEntryConsumer
object. This is used to create a consumer that will read the message part and the boundary that terminates the part. All contents that are read are appended to an internal buffer.- Parameters:
allocator
- this is the allocator used for the bufferseries
- this is the list used to accumulate the partsterminal
- this is the terminal token for the part listlength
- this is the length of the parent part series
-
-
Method Details
-
consume
This is used to consume the part body from the cursor. This initially reads the body of the part, which represents the actual content exposed via thePart
interface once the content has been consumed the terminal is consumed.- Specified by:
consume
in interfaceByteConsumer
- Parameters:
cursor
- this is the cursor to consume the body from- Throws:
IOException
-
isFinished
public boolean isFinished()This is used to determine whether the part body has been read from the cursor successfully. In order to determine if all of the bytes have been read successfully this will check to see of the terminal token had been consumed.- Specified by:
isFinished
in interfaceByteConsumer
- Returns:
- true if the part body and terminal have been read
-
isEnd
public boolean isEnd()This is used to determine whether the terminal token read is the final terminal token. The final terminal token is a normal terminal token, however it ends with two hyphens and a carriage return line feed, this ends the part list.- Returns:
- true if this was the last part within the list
-