Package org.simpleframework.http.message
Class PartEntryConsumer
- java.lang.Object
-
- org.simpleframework.http.message.PartEntryConsumer
-
- All Implemented Interfaces:
ByteConsumer
class PartEntryConsumer extends java.lang.Object implements ByteConsumer
ThePartEntryConsumer
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
Fields Modifier and Type Field Description private BoundaryConsumer
boundary
This is used to consume the boundary at the end of a part.private ByteConsumer
consumer
This is used to consume the actual part from the list.
-
Constructor Summary
Constructors Constructor Description PartEntryConsumer(Allocator allocator, PartSeries series, byte[] terminal, long length)
Constructor for thePartEntryConsumer
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
isFinished()
This is used to determine whether the part body has been read from the cursor successfully.
-
-
-
Field Detail
-
boundary
private final BoundaryConsumer boundary
This is used to consume the boundary at the end of a part.
-
consumer
private final ByteConsumer consumer
This is used to consume the actual part from the list.
-
-
Constructor Detail
-
PartEntryConsumer
public PartEntryConsumer(Allocator allocator, PartSeries series, byte[] terminal, long length)
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 Detail
-
consume
public void consume(ByteCursor cursor) throws java.io.IOException
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:
java.io.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
-
-