BodyPart abstract class and the MimePart
interface. MimeBodyParts are contained in MimeMultipart
objects.
MimeBodyPart uses the InternetHeaders class to parse
and store the headers of that body part.
RFC 822 header fields must contain only
US-ASCII characters. MIME allows non ASCII characters to be present
in certain portions of certain headers, by encoding those characters.
RFC 2047 specifies the rules for doing this. 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.
jakarta.mail.Part , jakarta.mail.internet.MimePart , jakarta.mail.internet.MimeUtility
| Modifier and Type | Class and Description |
|---|---|
| private static class | MimeBodyPart.
A FileDataSource class that allows us to specify the Content-Type and Content-Transfer-Encoding. |
| pack-priv static class | MimeBodyPart.
A special DataHandler used only as a marker to indicate that the source of the data is a MimePart (that is, a byte array or a stream). |
| Modifier and Type | Field and Description |
|---|---|
| private static final boolean | |
| protected Object | cachedContent
If our content is a Multipart of Message object, we save it the first time it's created by parsing a stream so that changes to the contained objects will not be lost. |
| pack-priv static final boolean | |
| protected byte[] | content
Byte array that holds the bytes of the content of this Part. |
| protected InputStream | contentStream
If the data for this body part was supplied by an
InputStream that implements the SharedInputStream interface,
|
| private static final boolean | |
| protected DataHandler | dh
The DataHandler object representing this Part's content. |
| private static final boolean | |
| protected InternetHeaders | headers
The InternetHeaders object that stores all the headers of this body part. |
| private static final boolean | |
| private static final boolean | |
| private static final boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | MimeBodyPart(InputStream
the body part Input Stream is)Constructs a MimeBodyPart by reading and parsing the data from the specified input stream. |
| public | MimeBodyPart(InternetHeaders
The header of this part headers, byte[] bytes representing the body of this part. content)Constructs a MimeBodyPart using the given header and content bytes. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addHeader(String
header name name, String header value value)Implements jakarta. Add this value to the existing values for this header_name. |
| public void | addHeaderLine(String
the line to add line)Implements jakarta. Add a header line to this body part |
| public void | attachFile(File
the File object to attach file)Use the specified file to provide the data for this part. |
| public void | attachFile(String
the name of the file to attach file)Use the specified file to provide the data for this part. |
| public void | attachFile(File
the File object to attach file, String the Content-Type, or null contentType, String the Content-Transfer-Encoding, or null encoding)Use the specified file with the specified Content-Type and Content-Transfer-Encoding to provide the data for this part. |
| public void | attachFile(String
the name of the file file, String the Content-Type, or null contentType, String the Content-Transfer-Encoding, or null encoding)Use the specified file with the specified Content-Type and Content-Transfer-Encoding to provide the data for this part. |
| public Enumeration | getAllHeaderLines()
Implements jakarta. Get all header lines as an Enumeration of Strings. |
| public Enumeration | getAllHeaders()
Implements jakarta. Return all the headers from this Message as an Enumeration of Header objects. |
| public Object | Returns: ObjectImplements jakarta. Return the content as a Java object. |
| public String | getContentID()
Implements jakarta. Returns the value of the "Content-ID" header field. |
| public String[] | getContentLanguage()
Implements jakarta. Get the languages specified in the Content-Language header of this MimePart. |
| pack-priv static String[] | |
| public String | getContentMD5()
Implements jakarta. Return the value of the "Content-MD5" header field. |
| protected InputStream | Returns: an InputStream containing the raw bytesProduce the raw bytes of the content. |
| public String | Returns: Content-Type of this body partImplements jakarta. Returns the value of the RFC 822 "Content-Type" header field. |
| public DataHandler | getDataHandler()
Implements jakarta. Return a DataHandler for this body part's content. |
| public String | Returns: content descriptionImplements jakarta. Returns the "Content-Description" header field of this body part. |
| pack-priv static String | |
| public String | getDisposition()
Implements jakarta. Returns the disposition from the "Content-Disposition" header field. |
| pack-priv static String | |
| public String | getEncoding()
Implements jakarta. Returns the content transfer encoding from the "Content-Transfer-Encoding" header field. |
| pack-priv static String | |
| public String | Returns: filenameImplements jakarta. Get the filename associated with this body part. |
| pack-priv static String | |
| public String[] | Returns: array of headersname of header name)Implements jakarta. Get all the headers for this header_name. |
| public String | Returns: the value fields for all headers with this namethe name of this header name, String delimiter between fields in returned string delimiter)Implements jakarta. Get all the headers for this header name, returned as a single String, with headers separated by the delimiter. |
| public InputStream | Returns: an InputStreamImplements jakarta. Return a decoded input stream for this body part's "content". |
| public int | Returns: number of lines, or -1 if not knownImplements jakarta. Return the number of lines for the content of this Part. |
| public Enumeration | getMatchingHeaderLines(String[]
the headers to return names)Implements jakarta. Get matching header lines as an Enumeration of Strings. |
| public Enumeration | getMatchingHeaders(String[]
the headers to match names)Implements jakarta. Return matching headers from this Message as an Enumeration of Header objects. |
| public Enumeration | getNonMatchingHeaderLines(String[]
the headers to not return names)Implements jakarta. Get non-matching header lines as an Enumeration of Strings. |
| public Enumeration | getNonMatchingHeaders(String[]
the headers to not match names)Implements jakarta. Return non-matching headers from this Message as an Enumeration of Header objects. |
| public InputStream | Returns: an InputStream containing the raw bytesReturn an InputStream to the raw data with any Content-Transfer-Encoding intact. |
| public int | Returns: size in bytes, or -1 if not knownImplements jakarta. Return the size of the content of this body part in bytes. |
| pack-priv static void | |
| public boolean | isMimeType(String
the MIME type to test mimeType)Implements jakarta. Is this Part of the specified MIME type? |
| pack-priv static boolean | |
| public void | removeHeader(String
the name of this header name)Implements jakarta. Remove all headers with this name. |
| pack-priv static String | restrictEncoding(MimePart part, String encoding)
Restrict the encoding to values allowed for the Content-Type of the specified MimePart. |
| public void | |
| public void | |
| public void | setContent(Object
the content object o, String Mime type of the object type)Implements jakarta. A convenience method for setting this body part's content. |
| public void | setContent(Multipart
The multipart object that is the Message's content mp)Implements jakarta. This method sets the body part's content to a Multipart object. |
| public void | |
| public void | setContentLanguage(String[]
array of language tags languages)Implements jakarta. Set the Content-Language header of this MimePart. |
| pack-priv static void | |
| public void | setContentMD5(String
the MD5 value md5)Implements jakarta. Set the "Content-MD5" header field of this body part. |
| public void | setDataHandler(DataHandler
The DataHandler for the content dh)Implements jakarta. This method provides the mechanism to set this body part's content. |
| public void | setDescription(String
content description description)Implements jakarta. Set the "Content-Description" header field for this body part. |
| public void | setDescription(String
Description description, String Charset for encoding charset)Set the "Content-Description" header field for this body part. |
| pack-priv static void | |
| public void | setDisposition(String
disposition of this part disposition)Implements jakarta. Set the disposition in the "Content-Disposition" header field of this body part. |
| pack-priv static void | |
| pack-priv static void | |
| public void | setFileName(String
the file name filename)Implements jakarta. Set the filename associated with this body part, if possible. |
| pack-priv static void | |
| public void | setHeader(String
header name name, String header value value)Implements jakarta. Set the value for this header_name. |
| public void | setText(String
the text content to set text)Implements jakarta. Convenience method that sets the given String as this part's content, with a MIME type of "text/plain". |
| public void | setText(String
the text content to set text, String the charset to use for the text charset)Implements jakarta. Convenience method that sets the given String as this part's content, with a MIME type of "text/plain" and the specified charset. |
| public void | setText(String
the text content to set text, String the charset to use for the text charset, String the MIME subtype to use (e.g., "html") subtype)Implements jakarta. Convenience method that sets the given String as this part's content, with a primary MIME type of "text" and the specified MIME subtype. |
| pack-priv static void | |
| protected void | |
| pack-priv static void | |
| public void | writeTo(OutputStream
the stream to write to os)Implements jakarta. Output the body part as an RFC 822 format stream. |
| pack-priv static void |