Class PartEntryConsumer

  • All Implemented Interfaces:
    ByteConsumer

    class PartEntryConsumer
    extends java.lang.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 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 the PartEntryConsumer 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 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 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 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:
        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 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