MimePart (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.mail.internet Interface MimePart

所有父接口:
Part
所有已知实现子孙类:
MimeBodyPart, MimeMessage, PreencodedMimeBodyPart

public interface MimePart
extends Part

The MimePart interface models an Entity as defined by MIME (RFC2045, Section 2.4).

MimePart extends the Part interface to add additional RFC822 and MIME specific semantics and attributes. It provides the base interface for the MimeMessage and MimeBodyPart classes


A note on RFC822 and MIME headers

RFC822 and MIME header fields must contain only US-ASCII characters. If a header contains non US-ASCII characters, it must be encoded as per the rules in RFC 2047. The MimeUtility class provided in this package can be used to to achieve this. Callers of the setHeader, addHeader, and addHeaderLine methods are responsible for enforcing the MIME requirements for the specified headers. In addition, these header fields must be folded (wrapped) before being sent if they exceed the line length limitation for the transport (1000 bytes for SMTP). Received headers may have been folded. The application is responsible for folding and unfolding headers as appropriate.

作者:
John Mani
另请参见:
MimeUtility, Part

字段摘要
 
Fields inherited from interface javax.mail.Part
ATTACHMENT, INLINE
 
方法摘要
 void addHeaderLine(String line)
          Add a raw RFC822 header-line.
 Enumeration getAllHeaderLines()
          Get all header lines as an Enumeration of Strings.
 String getContentID()
          Get the Content-ID of this part.
 String[] getContentLanguage()
          Get the language tags specified in the Content-Language header of this MimePart.
 String getContentMD5()
          Get the Content-MD5 digest of this part.
 String getEncoding()
          Get the transfer encoding of this part.
 String getHeader(String name, String delimiter)
          Get the values of all header fields available for this header, returned as a single String, with the values separated by the delimiter.
 Enumeration getMatchingHeaderLines(String[] names)
          Get matching header lines as an Enumeration of Strings.
 Enumeration getNonMatchingHeaderLines(String[] names)
          Get non-matching header lines as an Enumeration of Strings.
 void setContentLanguage(String[] languages)
          Set the Content-Language header of this MimePart.
 void setContentMD5(String md5)
          Set the Content-MD5 of this part.
 void setText(String text)
          Convenience method that sets the given String as this part's content, with a MIME type of "text/plain".
 void setText(String text, String charset)
          Convenience method that sets the given String as this part's content, with a MIME type of "text/plain" and the specified charset.
 void setText(String text, String charset, String subtype)
          Convenience method that sets the given String as this part's content, with a primary MIME type of "text" and the specified MIME subtype.
 
Methods inherited from interface javax.mail.Part
addHeader, getAllHeaders, getContent, getContentType, getDataHandler, getDescription, getDisposition, getFileName, getHeader, getInputStream, getLineCount, getMatchingHeaders, getNonMatchingHeaders, getSize, isMimeType, removeHeader, setContent, setContent, setDataHandler, setDescription, setDisposition, setFileName, setHeader, writeTo
 

方法详细信息

getHeader

String getHeader(String name,
                 String delimiter)
                 throws MessagingException
Get the values of all header fields available for this header, returned as a single String, with the values separated by the delimiter. If the delimiter is null, only the first value is returned.

参数:
name - the name of this header
delimiter - delimiter between fields in returned string
返回:
the value fields for all headers with this name
抛出异常:
MessagingException

addHeaderLine

void addHeaderLine(String line)
                   throws MessagingException
Add a raw RFC822 header-line.

抛出异常:
IllegalWriteException - if the underlying implementation does not support modification
IllegalStateException - if this Part is obtained from a READ_ONLY folder
MessagingException

getAllHeaderLines

Enumeration getAllHeaderLines()
                              throws MessagingException
Get all header lines as an Enumeration of Strings. A Header line is a raw RFC822 header-line, containing both the "name" and "value" field.

抛出异常:
MessagingException

getMatchingHeaderLines

Enumeration getMatchingHeaderLines(String[] names)
                                   throws MessagingException
Get matching header lines as an Enumeration of Strings. A Header line is a raw RFC822 header-line, containing both the "name" and "value" field.

抛出异常:
MessagingException

getNonMatchingHeaderLines

Enumeration getNonMatchingHeaderLines(String[] names)
                                      throws MessagingException
Get non-matching header lines as an Enumeration of Strings. A Header line is a raw RFC822 header-line, containing both the "name" and "value" field.

抛出异常:
MessagingException

getEncoding

String getEncoding()
                   throws MessagingException
Get the transfer encoding of this part.

返回:
content-transfer-encoding
抛出异常:
MessagingException

getContentID

String getContentID()
                    throws MessagingException
Get the Content-ID of this part. Returns null if none present.

返回:
content-ID
抛出异常:
MessagingException

getContentMD5

String getContentMD5()
                     throws MessagingException
Get the Content-MD5 digest of this part. Returns null if none present.

返回:
content-MD5
抛出异常:
MessagingException

setContentMD5

void setContentMD5(String md5)
                   throws MessagingException
Set the Content-MD5 of this part.

参数:
md5 - the MD5 value
抛出异常:
IllegalWriteException - if the underlying implementation does not support modification
IllegalStateException - if this Part is obtained from a READ_ONLY folder
MessagingException

getContentLanguage

String[] getContentLanguage()
                            throws MessagingException
Get the language tags specified in the Content-Language header of this MimePart. The Content-Language header is defined by RFC 1766. Returns null if this header is not available.

抛出异常:
MessagingException

setContentLanguage

void setContentLanguage(String[] languages)
                        throws MessagingException
Set the Content-Language header of this MimePart. The Content-Language header is defined by RFC1766.

参数:
languages - array of language tags
抛出异常:
IllegalWriteException - if the underlying implementation does not support modification
IllegalStateException - if this Part is obtained from a READ_ONLY folder
MessagingException

setText

void setText(String text)
             throws MessagingException
Convenience method that sets the given String as this part's content, with a MIME type of "text/plain". If the string contains non US-ASCII characters. it will be encoded using the platform's default charset. The charset is also used to set the "charset" parameter.

Note that there may be a performance penalty if text is large, since this method may have to scan all the characters to determine what charset to use.

If the charset is already known, use the setText method that takes the charset parameter.

规范说明:
setText in interface Part
参数:
text - the text content to set
抛出异常:
MessagingException - if an error occurs
另请参见:
setText(String text, String charset)

setText

void setText(String text,
             String charset)
             throws MessagingException
Convenience method that sets the given String as this part's content, with a MIME type of "text/plain" and the specified charset. The given Unicode string will be charset-encoded using the specified charset. The charset is also used to set "charset" parameter.

参数:
text - the text content to set
charset - the charset to use for the text
抛出异常:
MessagingException - if an error occurs

setText

void setText(String text,
             String charset,
             String subtype)
             throws MessagingException
Convenience method that sets the given String as this part's content, with a primary MIME type of "text" and the specified MIME subtype. The given Unicode string will be charset-encoded using the specified charset. The charset is also used to set the "charset" parameter.

参数:
text - the text content to set
charset - the charset to use for the text
subtype - the MIME subtype to use (e.g., "html")
抛出异常:
MessagingException - if an error occurs
从以下版本开始:
JavaMail 1.4

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.