Package jakarta.mail.internet
Class MimePartDataSource
- java.lang.Object
-
- jakarta.mail.internet.MimePartDataSource
-
- All Implemented Interfaces:
DataSource
,MessageAware
public class MimePartDataSource extends Object implements DataSource, MessageAware
A utility class that implements a DataSource out of a MimePart. This class is primarily meant for service providers.- Author:
- John Mani
- See Also:
MimePart
,DataSource
-
-
Constructor Summary
Constructors Constructor Description MimePartDataSource(MimePart part)
Constructor, that constructs a DataSource from a MimePart.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getContentType()
Returns the content-type of this DataSource.InputStream
getInputStream()
Returns an input stream from this MimePart.MessageContext
getMessageContext()
Return theMessageContext
for the current part.String
getName()
DataSource method to return a name.OutputStream
getOutputStream()
DataSource method to return an output stream.
-
-
-
Field Detail
-
part
protected MimePart part
The MimePart that provides the data for this DataSource.- Since:
- JavaMail 1.4
-
-
Constructor Detail
-
MimePartDataSource
public MimePartDataSource(MimePart part)
Constructor, that constructs a DataSource from a MimePart.- Parameters:
part
- the MimePart
-
-
Method Detail
-
getInputStream
public InputStream getInputStream() throws IOException
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 theMimeUtility.decode()
method.- Specified by:
getInputStream
in interfaceDataSource
- Returns:
- decoded input stream
- Throws:
IOException
- for failures creating the InputStream- See Also:
MimeMessage.getContentStream()
,MimeBodyPart.getContentStream()
,MimeUtility.decode(java.io.InputStream, java.lang.String)
-
getOutputStream
public OutputStream getOutputStream() throws IOException
DataSource method to return an output stream.This implementation throws the UnknownServiceException.
- Specified by:
getOutputStream
in interfaceDataSource
- Returns:
- an OutputStream
- Throws:
IOException
- for failures creating the OutputStream
-
getContentType
public String getContentType()
Returns the content-type of this DataSource.This implementation just invokes the
getContentType
method on the MimePart.- Specified by:
getContentType
in interfaceDataSource
- Returns:
- the MIME Type
-
getName
public String getName()
DataSource method to return a name.This implementation just returns an empty string.
- Specified by:
getName
in interfaceDataSource
- Returns:
- the name of the object.
-
getMessageContext
public MessageContext getMessageContext()
Return theMessageContext
for the current part.- Specified by:
getMessageContext
in interfaceMessageAware
- Returns:
- the message context
- Since:
- JavaMail 1.1
-
-