Package org.apache.axiom.mime

# 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()`.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `MultipartBody.Builder`
  `static interface`
  `MultipartBody.PartCreationListener`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static MultipartBody.Builder`
  `builder()`
  `void`
  `detach()`
  `ContentType`
  `getContentType()`
  `Part`
  `getPart(String contentID)`
  Get the MIME part with the given content ID.
  `int`
  `getPartCount()`
  Get the number of parts in this multipart.
  `Part`
  `getRootPart()`
  `Iterator<Part>`
  `iterator()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## 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()