public class

MimePartDataSource

extends Object
implements DataSource MessageAware
java.lang.Object
   ↳ com.google.code.javax.mail.internet.MimePartDataSource
Known Direct Subclasses

Class Overview

A utility class that implements a DataSource out of a MimePart. This class is primarily meant for service providers.

See Also
  • javax.mail.internet.MimePart
  • javax.activation.DataSource

Summary

Fields
private MessageContext context
protected MimePart part The MimePart that provides the data for this DataSource.
Public Constructors
MimePartDataSource(MimePart part)
Constructor, that constructs a DataSource from a MimePart.
Public Methods
String getContentType()
Returns the content-type of this DataSource.
InputStream getInputStream()
Returns an input stream from this MimePart.
synchronized MessageContext getMessageContext()
Return the MessageContext for the current part.
String getName()
DataSource method to return a name.
OutputStream getOutputStream()
DataSource method to return an output stream.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.code.javax.activation.DataSource
From interface com.google.code.javax.mail.MessageAware

Fields

private MessageContext context

protected MimePart part

The MimePart that provides the data for this DataSource.

Public Constructors

public MimePartDataSource (MimePart part)

Constructor, that constructs a DataSource from a MimePart.

Parameters
part

Public Methods

public String getContentType ()

Returns the content-type of this DataSource.

This implementation just invokes the getContentType method on the MimePart.

Returns
  • the MIME Type

public InputStream getInputStream ()

Returns an input stream from this MimePart.

This method applies the appropriate transfer-decoding, based on the Content-Transfer-Encoding attribute of this MimePart. Thus the returned input stream is a decoded stream of bytes.

This implementation obtains the raw content from the Part using the getContentStream() method and decodes it using the MimeUtility.decode() method.

Returns
  • decoded input stream
Throws
IOException
See Also
  • javax.mail.internet.MimeMessage#getContentStream
  • javax.mail.internet.MimeBodyPart#getContentStream
  • javax.mail.internet.MimeUtility#decode

public synchronized MessageContext getMessageContext ()

Return the MessageContext for the current part.

public String getName ()

DataSource method to return a name.

This implementation just returns an empty string.

Returns
  • the name of the object.

public OutputStream getOutputStream ()

DataSource method to return an output stream.

This implementation throws the UnknownServiceException.

Returns
  • an OutputStream
Throws
IOException