javax.mail.internet

Interface MimePart

public interface MimePart extends Part

A MIME part is an Entity as defined by MIME (RFC2045, Section 2.4).

The string representation of RFC822 and MIME header fields must contain only US-ASCII characters. Non US-ASCII characters must be encoded as per the rules in RFC 2047. This class does not enforce those rules; the caller is expected to use MimeUtility to ensure that header values are correctly encoded.

Version: 1.4

Author: Chris Burdess

Method Summary
voidaddHeaderLine(String line)
Adds an RFC822 header-line.
EnumerationgetAllHeaderLines()
Returns all the header-lines.
StringgetContentID()
Returns the value of the Content-ID header field of this part.
String[]getContentLanguage()
Returns the languages specified in the Content-Language header of this part, as defined by RFC 1766.
StringgetContentMD5()
Returns the value of the Content-MD5 header field of this part.
StringgetEncoding()
Returns the value of the Content-Transfer-Encoding header field of this part.
StringgetHeader(String header_name, String delimiter)
Returns the values of all header fields for the specified name, returned as a single String with the values separated by the given delimiter.
EnumerationgetMatchingHeaderLines(String[] names)
Returns all the header-lines with any of the given names.
EnumerationgetNonMatchingHeaderLines(String[] names)
Returns all the header-lines without any of the given names.
voidsetContentLanguage(String[] languages)
Sets the Content-Language header of this part.
voidsetContentMD5(String md5)
Sets the Content-MD5 header value for this part.
voidsetText(String text)
Sets the content of this message using the specified text, and with a MIME type of "text/plain".
voidsetText(String text, String charset)
Sets the content of this message using the specified text, and with a MIME type of "text/plain".
voidsetText(String text, String charset, String subtype)
Sets the content of this message using the specified text, and with a text MIME type of the specified subtype.

Method Detail

addHeaderLine

public void addHeaderLine(String line)
Adds an RFC822 header-line.

Throws: IllegalWriteException if the underlying implementation does not support modification IllegalStateException if this part is obtained from a READ_ONLY folder

getAllHeaderLines

public Enumeration getAllHeaderLines()
Returns all the header-lines.

Returns: an Enumeration of Strings

getContentID

public String getContentID()
Returns the value of the Content-ID header field of this part.

getContentLanguage

public String[] getContentLanguage()
Returns the languages specified in the Content-Language header of this part, as defined by RFC 1766. This method returns null if this header is not available.

getContentMD5

public String getContentMD5()
Returns the value of the Content-MD5 header field of this part.

getEncoding

public String getEncoding()
Returns the value of the Content-Transfer-Encoding header field of this part.

getHeader

public String getHeader(String header_name, String delimiter)
Returns the values of all header fields for the specified name, returned as a single String with the values separated by the given delimiter. If the delimiter is null, only the first value is returned.

Parameters: header_name the header name

getMatchingHeaderLines

public Enumeration getMatchingHeaderLines(String[] names)
Returns all the header-lines with any of the given names.

Returns: an Enumeration of Strings

getNonMatchingHeaderLines

public Enumeration getNonMatchingHeaderLines(String[] names)
Returns all the header-lines without any of the given names.

Returns: an Enumeration of Strings

setContentLanguage

public void setContentLanguage(String[] languages)
Sets the Content-Language header of this part.

Parameters: languages the array of language tags

Throws: IllegalWriteException if the underlying implementation does not support modification IllegalStateException if this Part is obtained from a READ_ONLY folder

setContentMD5

public void setContentMD5(String md5)
Sets the Content-MD5 header value for this part.

Parameters: IllegalStateException if this part is obtained from a READ_ONLY folder

Throws: IllegalWriteException if the underlying implementation does not support modification

setText

public void setText(String text)
Sets the content of this message using the specified text, and with a MIME type of "text/plain".

If the string contains non US-ASCII characters, it will be encoded using the platform default charset.

Parameters: text the text content

setText

public void setText(String text, String charset)
Sets the content of this message using the specified text, and with a MIME type of "text/plain".

If the string contains non US-ASCII characters, it will be encoded using the specified charset.

Parameters: text the text content charset the charset to use for any encoding

setText

public void setText(String text, String charset, String subtype)
Sets the content of this message using the specified text, and with a text MIME type of the specified subtype.

If the string contains non US-ASCII characters, it will be encoded using the specified charset.

Parameters: text the text content charset the charset to use for any encoding subtype the MIME text subtype (e.g. "plain", "html")

Since: JavaMail 1.4

© Copyright 2003, 2004 The Free Software Foundation, All rights reserved