Package org.apache.axiom.om.impl

# Class OMMultipartWriter

java.lang.Object
org.apache.axiom.om.impl.OMMultipartWriter

public class OMMultipartWriter extends Object
Writes a MIME multipart package as used by XOP/MTOM and SOAP with Attachments. This class wraps a `MultipartBodyWriter`, providing a higher level API. In particular it will configure content types and content transfer encodings based on information from an `OMOutputFormat` object.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OMMultipartWriter(OutputStream out, OMOutputFormat format)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `complete()`
  Complete writing of the MIME multipart package.
  `ContentType`
  `getRootPartContentType()`
  Get the content type of the root part, as determined by the `OMOutputFormat` passed to the constructor of this object.
  `void`
  `writePart(Blob blob, String contentID)`
  Write a MIME part.
  `void`
  `writePart(Blob blob, String contentID, List<Header> extraHeaders)`
  Write a MIME part.
  `OutputStream`
  `writePart(ContentType contentType, String contentID)`
  Start writing an attachment part of the MIME package.
  `OutputStream`
  `writePart(ContentType contentType, String contentID, List<Header> extraHeaders)`
  Start writing an attachment part of the MIME package.
  `void`
  `writePart(PartBlob blob, String contentID, boolean preserve)`
  Write a MIME part.
  `OutputStream`
  `writeRootPart()`
  Start writing the root part of the MIME package.

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

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

- ## Constructor Details

  - ### OMMultipartWriter

    public OMMultipartWriter(OutputStream out, OMOutputFormat format)

- ## Method Details

  - ### getRootPartContentType

    public ContentType getRootPartContentType()
    Get the content type of the root part, as determined by the `OMOutputFormat` passed to the constructor of this object.
    Returns:
      the content type of the root part

  - ### writeRootPart

    public OutputStream writeRootPart() throws IOException
    Start writing the root part of the MIME package. This method delegates to `MultipartBodyWriter.writePart(ContentType, ContentTransferEncoding, String, List)`, but computes the content type, content transfer encoding and content ID from the `OMOutputFormat`.
    Returns:
      an output stream to write the content of the MIME part
    Throws:
      `IOException` - if an I/O error occurs when writing to the underlying stream

  - ### writePart

    public OutputStream writePart(ContentType contentType, String contentID) throws IOException
    Start writing an attachment part of the MIME package. This method delegates to `MultipartBodyWriter.writePart(ContentType, ContentTransferEncoding, String, List)`, but computes the content transfer encoding based on the content type and the `OMOutputFormat`.
    Parameters:
      `contentType` - the content type of the MIME part to write
      `contentID` - the content ID of the MIME part
    Returns:
      an output stream to write the content of the MIME part
    Throws:
      `IOException` - if an I/O error occurs when writing to the underlying stream

  - ### writePart

    public OutputStream writePart(ContentType contentType, String contentID, List<Header> extraHeaders) throws IOException
    Start writing an attachment part of the MIME package. This method delegates to `MultipartBodyWriter.writePart(ContentType, ContentTransferEncoding, String, List)`, but computes the content transfer encoding based on the content type and the `OMOutputFormat`.
    Parameters:
      `contentType` - the content type of the MIME part to write
      `contentID` - the content ID of the MIME part
      `extraHeaders` - a list of `Header` objects with additional headers to write to the MIME part
    Returns:
      an output stream to write the content of the MIME part
    Throws:
      `IOException` - if an I/O error occurs when writing to the underlying stream

  - ### writePart

    public void writePart(Blob blob, String contentID, List<Header> extraHeaders) throws IOException
    Write a MIME part. This method delegates to `MultipartBodyWriter.writePart(Blob, ContentType, ContentTransferEncoding, String, List)`, but computes the appropriate content transfer encoding from the `OMOutputFormat`.
    Parameters:
      `blob` - the content of the MIME part to write
      `contentID` - the content ID of the MIME part
      `extraHeaders` - a list of `Header` objects with additional headers to write to the MIME part
    Throws:
      `IOException` - if an I/O error occurs when writing the part to the underlying stream

  - ### writePart

    public void writePart(Blob blob, String contentID) throws IOException
    Write a MIME part. This method delegates to `MultipartBodyWriter.writePart(Blob, ContentType, ContentTransferEncoding, String, List)`, but computes the appropriate content transfer encoding from the `OMOutputFormat`.
    Parameters:
      `blob` - the content of the MIME part to write
      `contentID` - the content ID of the MIME part
    Throws:
      `IOException` - if an I/O error occurs when writing the part to the underlying stream

  - ### writePart

    public void writePart(PartBlob blob, String contentID, boolean preserve) throws IOException
    Write a MIME part. This is similar to `writePart(Blob, String)`, but optionally consumes the blob (which is only supported for `PartBlob` instances).
    Parameters:
      `blob` - the content of the MIME part to write
      `contentID` - the content ID of the MIME part
      `preserve` - whether the content of the original MIME part should be preserved
    Throws:
      `IOException` - if an I/O error occurs when writing the part to the underlying stream

  - ### complete

    public void complete() throws IOException
    Complete writing of the MIME multipart package. This method delegates to `MultipartBodyWriter.complete()`.
    Throws:
      `IOException` - if an I/O error occurs when writing to the underlying stream