MimePartDataSource (Java EE 5)

Java EE API


javax.mail.internet Class MimePartDataSource

java.lang.Object
  extended by javax.mail.internet.MimePartDataSource
All Implemented Interfaces:
DataSource, MessageAware

public class MimePartDataSource
extends Object
implements DataSource, MessageAware


实现 MimePart 中的 DataSource 的实用工具类。此类主要供服务提供者使用。
英文文档:

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

Field Summary
protected  MimePart
 
Constructor Summary
 
Method Summary
 String
 InputStream
 MessageContext
 String
 OutputStream
 
Methods inherited from class java.lang.Object
 

Field Detail

英文文档:

part

protected MimePart part
The MimePart that provides the data for this DataSource.

Since:
JavaMail 1.4

Constructor Detail

public MimePartDataSource(MimePart part)
构造方法,根据 MimePart 构造 DataSource。
英文文档:

MimePartDataSource

public MimePartDataSource(MimePart part)
Constructor, that constructs a DataSource from a MimePart.

Method Detail

public java.io.InputStream getInputStream() throws java.io.IOException
返回此 MimePart 的输入流。

此方法根据此 MimePart 的 Content-Transfer-Encoding 属性的不同应用相应的传输编码。因此,返回的输入流是已解码的字节流。

此实现使用 getContentStream() 方法从 Part 中获取原始内容,并使用 MimeUtility.decode() 方法对它进行解码。

return 已解码的输入流
See also getContentStream, getContentStream, decode

英文文档:

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)

public java.io.OutputStream getOutputStream() throws java.io.IOException
返回输出流的 DataSource 方法。

此实现抛出 UnknownServiceException。

英文文档:

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

public String getContentType()
返回此 DataSource 的内容类型。

此实现仅对 MimePart 调用 getContentType 方法。

英文文档:

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

public String getName()
返回名称的 DataSource 方法。

此实现仅返回一个空字符串。

英文文档:

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.

public MessageContext getMessageContext()
返回当前部分的 MessageContext
since
JavaMail 1.1
英文文档:

getMessageContext

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

Specified by:
getMessageContext in interface MessageAware
Since:
JavaMail 1.1


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!