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.EncodedFileDataSource
A FileDataSource class that allows us to specify the Content-Type and Content-Transfer-Encoding. |
| pack-priv static class | MimeBodyPart.MimePartDataHandler
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. |
| public void | addHeaderLine(String
the line to add line)Implements jakarta. |
| 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. |
| public Enumeration | getAllHeaders()
Implements jakarta. |
| public Object | Returns: ObjectImplements jakarta. |
| public String | getContentID()
Implements jakarta. |
| public String[] | getContentLanguage()
Implements jakarta. |
| pack-priv static String[] | |
| public String | getContentMD5()
Implements jakarta. |
| 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. |
| public DataHandler | getDataHandler()
Implements jakarta. |
| public String | Returns: content descriptionImplements jakarta. |
| pack-priv static String | |
| public String | getDisposition()
Implements jakarta. |
| pack-priv static String | |
| public String | getEncoding()
Implements jakarta. |
| pack-priv static String | |
| public String | Returns: filenameImplements jakarta. |
| pack-priv static String | |
| public String[] | Returns: array of headersname of header name)Implements jakarta. |
| 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. |
| public InputStream | Returns: an InputStreamImplements jakarta. |
| public int | Returns: number of lines, or -1 if not knownImplements jakarta. |
| public Enumeration | getMatchingHeaderLines(String[]
the headers to return names)Implements jakarta. |
| public Enumeration | getMatchingHeaders(String[]
the headers to match names)Implements jakarta. |
| public Enumeration | getNonMatchingHeaderLines(String[]
the headers to not return names)Implements jakarta. |
| public Enumeration | getNonMatchingHeaders(String[]
the headers to not match names)Implements jakarta. |
| 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. |
| pack-priv static void | |
| public boolean | isMimeType(String
the MIME type to test mimeType)Implements jakarta. |
| pack-priv static boolean | |
| public void | removeHeader(String
the name of this header name)Implements jakarta. |
| 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. |
| public void | setContent(Multipart
The multipart object that is the Message's content mp)Implements jakarta. |
| public void | |
| public void | setContentLanguage(String[]
array of language tags languages)Implements jakarta. |
| pack-priv static void | |
| public void | setContentMD5(String
the MD5 value md5)Implements jakarta. |
| public void | setDataHandler(DataHandler
The DataHandler for the content dh)Implements jakarta. |
| public void | setDescription(String
content description description)Implements jakarta. |
| 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. |
| pack-priv static void | |
| pack-priv static void | |
| public void | setFileName(String
the file name filename)Implements jakarta. |
| pack-priv static void | |
| public void | setHeader(String
header name name, String header value value)Implements jakarta. |
| public void | setText(String
the text content to set text)Implements jakarta. |
| public void | setText(String
the text content to set text, String the charset to use for the text charset)Implements jakarta. |
| 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. |
| pack-priv static void | |
| protected void | |
| pack-priv static void | |
| public void | writeTo(OutputStream
the stream to write to os)Implements jakarta. |
| pack-priv static void |