站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Java Platform, Enterprise Edition v1.4 API Specifications

MimePartDataSource (Java 2 Platform Ent. Ed. v1.4) - Java Platform, Enterprise Edition v1.4 API Specifications

JavaTM 2 Platform
Ent. Ed. v1.4

javax.mail.internet
Class MimePartDataSource

java.lang.Object
  extended byjavax.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
MimePartDataSource(MimePart part)
          Constructor, that constructs a DataSource from a MimePart.
 
Method Summary
 String getContentType()
          Returns the content-type of this DataSource.
 InputStream getInputStream()
          Returns an input stream from this MimePart.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimePartDataSource

public MimePartDataSource(MimePart part)
Constructor, that constructs a DataSource from a 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 the MimeUtility.decode() method.

Specified by:
getInputStream in interface DataSource
Returns:
decoded input stream
Throws:
IOException
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 interface DataSource
Returns:
an OutputStream
Throws:
IOException

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 interface DataSource
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 interface DataSource
Returns:
the name of the object.

getMessageContext

public MessageContext getMessageContext()
Return the MessageContext for the current part.

Specified by:
getMessageContext in interface MessageAware
Since:
JavaMail 1.1

JavaTM 2 Platform
Ent. Ed. v1.4

Submit a bug or feature

Copyright 2003 Sun Microsystems, Inc. All rights reserved.