Package org.simpleframework.http.message
Class PartSeriesConsumer
- java.lang.Object
-
- org.simpleframework.http.message.PartSeriesConsumer
-
- All Implemented Interfaces:
BodyConsumer
,ByteConsumer
class PartSeriesConsumer extends java.lang.Object implements BodyConsumer
ThePartSeriesConsumer
object is used to consume a list of parts encoded in the multipart format. This is can consume any number of parts from a cursor. Each part consumed is added to an internal part list which can be used to acquire the contents of the upload and inspect the headers provided for each uploaded part. To ensure that only a fixed number of bytes are consumed this uses a content length for an internal buffer.
-
-
Field Summary
Fields Modifier and Type Field Description private BufferAllocator
buffer
This is used to both allocate and buffer the part list body.private PartEntryConsumer
consumer
This is used to consume individual parts from the part list.private PartEntryFactory
factory
This is the factory that is used to create the consumers used.private PartSeries
series
This is used to accumulate all the parts of the upload.
-
Constructor Summary
Constructors Constructor Description PartSeriesConsumer(Allocator allocator, byte[] boundary)
Constructor for thePartSeriesConsumer
object.PartSeriesConsumer(Allocator allocator, byte[] boundary, long length)
Constructor for thePartSeriesConsumer
object.PartSeriesConsumer(Allocator allocator, PartSeries series, byte[] boundary)
Constructor for thePartSeriesConsumer
object.PartSeriesConsumer(Allocator allocator, PartSeries series, byte[] boundary, long length)
Constructor for thePartSeriesConsumer
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 list from the cursor.Body
getBody()
This is used to acquire the body that has been consumed.boolean
isFinished()
This is used to determine whether the part body has been read from the cursor successfully.
-
-
-
Field Detail
-
consumer
private PartEntryConsumer consumer
This is used to consume individual parts from the part list.
-
factory
private PartEntryFactory factory
This is the factory that is used to create the consumers used.
-
buffer
private BufferAllocator buffer
This is used to both allocate and buffer the part list body.
-
series
private PartSeries series
This is used to accumulate all the parts of the upload.
-
-
Constructor Detail
-
PartSeriesConsumer
public PartSeriesConsumer(Allocator allocator, byte[] boundary)
Constructor for thePartSeriesConsumer
object. This will create a consumer that is capable of breaking an upload in to individual parts so that they can be accessed and used by the receiver of the HTTP request message.- Parameters:
allocator
- this is used to allocate the internal bufferboundary
- this is the boundary used for the upload
-
PartSeriesConsumer
public PartSeriesConsumer(Allocator allocator, byte[] boundary, long length)
Constructor for thePartSeriesConsumer
object. This will create a consumer that is capable of breaking an upload in to individual parts so that they can be accessed and used by the receiver of the HTTP request message.- Parameters:
allocator
- this is used to allocate the internal bufferboundary
- this is the boundary used for the uploadlength
- this is the number of bytes the upload should be
-
PartSeriesConsumer
public PartSeriesConsumer(Allocator allocator, PartSeries series, byte[] boundary)
Constructor for thePartSeriesConsumer
object. This will create a consumer that is capable of breaking an upload in to individual parts so that they can be accessed and used by the receiver of the HTTP request message.- Parameters:
allocator
- this is used to allocate the internal bufferboundary
- this is the boundary used for the uploadseries
- this is the part list used to accumulate the parts
-
PartSeriesConsumer
public PartSeriesConsumer(Allocator allocator, PartSeries series, byte[] boundary, long length)
Constructor for thePartSeriesConsumer
object. This will create a consumer that is capable of breaking an upload in to individual parts so that they can be accessed and used by the receiver of the HTTP request message.- Parameters:
allocator
- this is used to allocate the internal bufferseries
- this is the part list used to accumulate the partsboundary
- this is the boundary used for the uploadlength
- this is the number of bytes the upload should be
-
-
Method Detail
-
getBody
public Body 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 asAttachment
objects. Each part can then be read as an individual message.- Specified by:
getBody
in interfaceBodyConsumer
- Returns:
- the body that has been consumed by this instance
-
consume
public void consume(ByteCursor cursor) throws java.io.IOException
This is used to consume the part list from the cursor. This initially reads the list of parts, which represents the actual content exposed via thePartSeries
object, once the content has been consumed the terminal is consumed.- Specified by:
consume
in interfaceByteConsumer
- Parameters:
cursor
- this is the cursor to consume the list 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
-
-