Class PartEntryConsumer

java.lang.Object
org.simpleframework.http.message.PartEntryConsumer
All Implemented Interfaces:
ByteConsumer

class PartEntryConsumer extends Object implements 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

    Fields
    Modifier and Type
    Field
    Description
    private 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

    Constructors
    Constructor
    Description
    PartEntryConsumer(Allocator allocator, PartSeries series, byte[] terminal, long length)
    Constructor for the PartEntryConsumer object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This is used to consume the part body from the cursor.
    boolean
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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 Details

    • PartEntryConsumer

      public PartEntryConsumer(Allocator allocator, PartSeries series, byte[] terminal, long length)
      Constructor for the PartEntryConsumer 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 buffer
      series - this is the list used to accumulate the parts
      terminal - this is the terminal token for the part list
      length - this is the length of the parent part series
  • Method Details

    • consume

      public void consume(ByteCursor cursor) throws 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 the Part interface once the content has been consumed the terminal is consumed.
      Specified by:
      consume in interface ByteConsumer
      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 interface ByteConsumer
      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