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