Class MultipartBody

java.lang.Object
org.apache.axiom.mime.MultipartBody
All Implemented Interfaces:
Iterable<Part>

public final class MultipartBody extends Object implements Iterable<Part>
A MIME multipart message read from a stream. This class exposes an API that represents the message as a sequence of Part instances. It implements the Iterable interface to enable access to all parts. In addition, it supports lookup by content ID. Data is read from the stream on demand. This means that the stream must be kept open until all parts have been processed or detach() has been called. It also means that any invocation of a method on an instance of this class or an individual Part instance may trigger a MIMEException if there is an I/O error on the stream or a MIME parsing error.

Instances of this class are created using a fluent builder; see builder().

  • Method Details

    • builder

      public static MultipartBody.Builder builder()
    • getContentType

      public ContentType getContentType()
    • getPart

      public Part getPart(String contentID)
      Get the MIME part with the given content ID.
      Parameters:
      contentID - the content ID of the part to retrieve
      Returns:
      the MIME part, or null if the message doesn't have a part with the given content ID
    • getPartCount

      public int getPartCount()
      Get the number of parts in this multipart.
      Returns:
      the number of parts
    • getRootPart

      public Part getRootPart()
    • iterator

      public Iterator<Part> iterator()
      Specified by:
      iterator in interface Iterable<Part>
    • detach

      public void detach()