Package org.apache.axiom.mime
Class MultipartBodyWriter
java.lang.Object
org.apache.axiom.mime.MultipartBodyWriter
Writes a MIME multipart body as used by XOP/MTOM and SOAP with Attachments. MIME parts are
written using
writePart(ContentType, ContentTransferEncoding, String, List)
or
writePart(Blob, ContentType, ContentTransferEncoding, String, List)
. Calls to both methods can be mixed, i.e.
it is not required to use the same method for all MIME parts. Instead, the caller should choose
the most convenient method for each part (depending on the form in which the content is
available). After all parts have been written, complete()
must be called to write the
final MIME boundary.
The following semantics are defined for the contentTransferEncoding
and contentID
arguments of the two write methods:
- The content transfer encoding specified by the
contentTransferEncoding
argument is applied by the write method; the caller only provides the unencoded data. The implementation ensures that the MIME part has aContent-Transfer-Encoding
header appropriate for the applied encoding. - The content ID passed as argument is always the raw ID (without the angle brackets). The
implementation translates this into a properly formatted
Content-ID
header.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
complete()
Complete writing of the MIME multipart package.void
writePart
(Blob blob, ContentType contentType, ContentTransferEncoding contentTransferEncoding, String contentID, List<Header> extraHeaders) Write a MIME part.writePart
(ContentType contentType, ContentTransferEncoding contentTransferEncoding, String contentID, List<Header> extraHeaders) Start writing a MIME part.
-
Constructor Details
-
MultipartBodyWriter
Constructor.- Parameters:
out
- the output stream to write the multipart body toboundary
- the MIME boundary- See Also:
-
-
Method Details
-
writePart
public OutputStream writePart(ContentType contentType, ContentTransferEncoding contentTransferEncoding, String contentID, List<Header> extraHeaders) throws IOException Start writing a MIME part. The methods returns anOutputStream
that the caller can use to write the content of the MIME part. After writing the content,OutputStream.close()
must be called to complete the writing of the MIME part.- Parameters:
contentType
- the content type of the MIME part; may benull
contentTransferEncoding
- the content transfer encoding to be used (see above); must not benull
contentID
- the content ID of the MIME part (see above); may benull
extraHeaders
- a list ofHeader
objects with additional headers to write to the MIME part; may benull
- 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, ContentType contentType, ContentTransferEncoding contentTransferEncoding, String contentID, List<Header> extraHeaders) throws IOException Write a MIME part.- Parameters:
blob
- the content of the MIME part to writecontentType
- the content type; may benull
contentTransferEncoding
- the content transfer encoding to be used (see above); must not benull
contentID
- the content ID of the MIME part (see above)extraHeaders
- a list ofHeader
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
-
complete
Complete writing of the MIME multipart package. This method does not close the underlying stream.- Throws:
IOException
- if an I/O error occurs when writing to the underlying stream
-