Class PartConsumer
java.lang.Object
org.simpleframework.http.message.PartConsumer
- All Implemented Interfaces:
ByteConsumer
The
PartConsumer object is used to consume a part
from a part list. A part consists of a header and a body, which
can be either a simple chunk of data or another part list. This
must be able to cope with either a simple body or a part list.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BodyConsumerThis is used to consume the body data from the part.private ByteConsumerThis is the current consumer used to read from the cursor.private PartFactoryThis is used to determine what type the body data is.private SegmentConsumerThis is used to consume the header message of the part.private PartSeriesThis is used to add the consumed parts to when finished.private byte[]This is the terminal token that ends the part payload. -
Constructor Summary
ConstructorsConstructorDescriptionPartConsumer(Allocator allocator, PartSeries series, byte[] terminal, long length) Constructor for thePartConsumerobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidconsume(ByteCursor cursor) This is used to consume the part body from the cursor.private BodyConsumerThis is used to create a new body consumer used to consume the part body from for the list.booleanThis is used to determine whether the part body has been read from the cursor successfully.
-
Field Details
-
header
This is used to consume the header message of the part. -
body
This is used to consume the body data from the part. -
factory
This is used to determine what type the body data is. -
series
This is used to add the consumed parts to when finished. -
current
This is the current consumer used to read from the cursor. -
terminal
private byte[] terminalThis is the terminal token that ends the part payload.
-
-
Constructor Details
-
PartConsumer
Constructor for thePartConsumerobject. This is used to create a consumer used to read the contents of a part and the boundary that terminates the content. Any parts that are created by this are added to the provided part list.- Parameters:
allocator- this is the allocator used to creat buffersseries- this is the part list used to store the partsterminal- this is the terminal token for the partlength- this is the length of the parent part series
-
-
Method Details
-
getConsumer
This is used to create a new body consumer used to consume the part body from for the list. This will ensure that the part data is created based on the part header consumed. The types of part supported are part lists and part body.- Returns:
- this returns a consumed for the part content
-
consume
This is used to consume the part body from the cursor. This initially reads the body of the part, which represents the actual payload exposed via thePartinterface once the payload has been consumed the terminal is consumed.- Specified by:
consumein 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:
isFinishedin interfaceByteConsumer- Returns:
- true if the part body and terminal have been read
-