Top Description Fields Constructors Methods
javax.mail.internet

public Class MimePartDataSource

extends Object
implements DataSource, MessageAware
Class Inheritance
All Implemented Interfaces
javax.mail.MessageAware, javax.activation.DataSource
Imports
javax.mail.*, javax.activation.*, java.io.*, java.net.UnknownServiceException, com.sun.mail.util.PropUtil, .FolderClosedIOException

A utility class that implements a DataSource out of a MimePart. This class is primarily meant for service providers.
Author
John Mani
See Also
javax.mail.internet.MimePart, javax.activation.DataSource

Field Summary

Modifier and TypeField and Description
private MessageContext
protected MimePart
part

The MimePart that provides the data for this DataSource.

Constructor Summary

AccessConstructor and Description
public
MimePartDataSource(MimePart
the MimePart
part
)

Constructor, that constructs a DataSource from a MimePart.

Method Summary

Modifier and TypeMethod and Description
public String
getContentType()

Implements javax.activation.DataSource.getContentType.

Returns the content-type of this DataSource.
public InputStream

Returns:

decoded input stream
getInputStream
()

Implements javax.activation.DataSource.getInputStream.

Returns an input stream from this MimePart.
public synchronized MessageContext
getMessageContext()

Implements javax.mail.MessageAware.getMessageContext.

Return the MessageContext for the current part.
public String
getName()

Implements javax.activation.DataSource.getName.

DataSource method to return a name.
public OutputStream
getOutputStream()

Implements javax.activation.DataSource.getOutputStream.

DataSource method to return an output stream.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
private MessageContext context
partback to summary
protected MimePart part

The MimePart that provides the data for this DataSource.

Since
JavaMail 1.4

Constructor Detail

MimePartDataSourceback to summary
public MimePartDataSource(MimePart part)

Constructor, that constructs a DataSource from a MimePart.

Parameters
part:MimePart

the MimePart

Method Detail

getContentTypeback to summary
public String getContentType()

Implements javax.activation.DataSource.getContentType.

Returns the content-type of this DataSource.

This implementation just invokes the getContentType method on the MimePart.

Returns:String

Doc from javax.activation.DataSource.getContentType.

the MIME Type

Annotations
@Override
getInputStreamback to summary
public InputStream getInputStream() throws IOException

Implements javax.activation.DataSource.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:InputStream

decoded input stream

Annotations
@Override
Exceptions
IOException:

Doc from javax.activation.DataSource.getInputStream.

for failures creating the InputStream

See Also
javax.mail.internet.MimeMessage#getContentStream, javax.mail.internet.MimeBodyPart#getContentStream, javax.mail.internet.MimeUtility#decode
getMessageContextback to summary
public synchronized MessageContext getMessageContext()

Implements javax.mail.MessageAware.getMessageContext.

Return the MessageContext for the current part.

Returns:MessageContext

Doc from javax.mail.MessageAware.getMessageContext.

the message context

Annotations
@Override
Since
JavaMail 1.1
getNameback to summary
public String getName()

Implements javax.activation.DataSource.getName.

DataSource method to return a name.

This implementation just returns an empty string.

Returns:String

Doc from javax.activation.DataSource.getName.

the name of the object.

Annotations
@Override
getOutputStreamback to summary
public OutputStream getOutputStream() throws IOException

Implements javax.activation.DataSource.getOutputStream.

DataSource method to return an output stream.

This implementation throws the UnknownServiceException.

Returns:OutputStream

Doc from javax.activation.DataSource.getOutputStream.

an OutputStream

Annotations
@Override
Exceptions
IOException:

Doc from javax.activation.DataSource.getOutputStream.

for failures creating the OutputStream