public class MimeBodyPart extends BodyPart implements MimePart
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
content
This message's content (unless sourced from a SharedInputStream).
|
protected InputStream |
contentStream
If the data for this message was supplied by a
SharedInputStream
then this is another such stream representing the content of this message;
if this field is non-null, then content will be null. |
protected javax.activation.DataHandler |
dh
The
DataHandler for this Message's content. |
protected InternetHeaders |
headers
This message's headers.
|
ATTACHMENT, INLINE| Constructor and Description |
|---|
MimeBodyPart() |
MimeBodyPart(InputStream in) |
MimeBodyPart(InternetHeaders headers,
byte[] content) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String name,
String value)
Add this value to the existing headers with the given name.
|
void |
addHeaderLine(String line) |
void |
attachFile(File file)
Attach a file to this body part from a File object.
|
void |
attachFile(String file)
Attach a file to this body part from a file name.
|
Enumeration |
getAllHeaderLines() |
Enumeration |
getAllHeaders()
Return all headers as an Enumeration of Header objects.
|
Object |
getContent()
Return a content object for this Part.
|
String |
getContentID()
Retrieve the value of the "Content-ID" header.
|
String[] |
getContentLanguage() |
String |
getContentMD5() |
protected InputStream |
getContentStream() |
String |
getContentType()
Get the ContentType for this part, or null if the
ContentType has not been set.
|
javax.activation.DataHandler |
getDataHandler()
Returns a DataHandler instance for the content
with in the Part.
|
String |
getDescription()
Returns a description string for this Part.
|
String |
getDisposition()
Retrieve the message "Content-Disposition" header field.
|
String |
getEncoding()
Retrieves the current value of the "Content-Transfer-Encoding"
header.
|
String |
getFileName()
Get a file name associated with this part.
|
String[] |
getHeader(String name)
Get all Headers for this header name.
|
String |
getHeader(String name,
String delimiter) |
InputStream |
getInputStream()
Return an InputStream for accessing the Part
content.
|
int |
getLineCount()
Return the number of lines in the content, or
-1 if the line count cannot be determined.
|
Enumeration |
getMatchingHeaderLines(String[] names) |
Enumeration |
getMatchingHeaders(String[] name)
Return all headers that match the list of names as an Enumeration of
Header objects.
|
Enumeration |
getNonMatchingHeaderLines(String[] names) |
Enumeration |
getNonMatchingHeaders(String[] name)
Return an Enumeration of all Headers except those that match the names
given in the exclusion list.
|
InputStream |
getRawInputStream() |
int |
getSize()
Return the content size of this message.
|
boolean |
isMimeType(String type)
Tests to see if this message has a mime-type match with the
given type name.
|
void |
removeHeader(String name)
Remove all headers with the given name from the Part.
|
void |
saveFile(File file)
Save the body part content to a given target file.
|
void |
saveFile(String file)
Save the body part content to a given target file.
|
void |
setContent(Multipart part) |
void |
setContent(Object content,
String type)
Set a content object for this part.
|
void |
setContentID(String cid) |
void |
setContentLanguage(String[] languages) |
void |
setContentMD5(String md5) |
void |
setDataHandler(javax.activation.DataHandler handler)
Set a DataHandler for this part that defines the
Part content.
|
void |
setDescription(String description)
Set a descriptive string for this part.
|
void |
setDescription(String description,
String charset) |
void |
setDisposition(String disposition)
Set a new dispostion value for the "Content-Disposition" field.
|
void |
setFileName(String name)
Set a descriptive file name for this part.
|
void |
setHeader(String name,
String value)
Sets a value for the given header.
|
void |
setText(String text)
Set the Part content as text.
|
void |
setText(String text,
String charset) |
void |
setText(String text,
String charset,
String subtype) |
protected void |
updateHeaders() |
void |
writeTo(OutputStream out)
Write the Part content out to the provided OutputStream as a byte
stream using an encoding appropriate to the Part content.
|
protected javax.activation.DataHandler dh
DataHandler for this Message's content.protected byte[] content
protected InputStream contentStream
SharedInputStream
then this is another such stream representing the content of this message;
if this field is non-null, then content will be null.protected InternetHeaders headers
public MimeBodyPart()
public MimeBodyPart(InputStream in) throws MessagingException
MessagingExceptionpublic MimeBodyPart(InternetHeaders headers, byte[] content) throws MessagingException
MessagingExceptionpublic int getSize()
throws MessagingException
getSize in interface PartMessagingExceptionpublic int getLineCount()
throws MessagingException
PartgetLineCount in interface PartMessagingExceptionpublic String getContentType() throws MessagingException
PartgetContentType in interface PartMessagingExceptionpublic boolean isMimeType(String type) throws MessagingException
isMimeType in interface Parttype - The tested type name.MessagingExceptionpublic String getDisposition() throws MessagingException
getDisposition in interface PartMessagingExceptionpublic void setDisposition(String disposition) throws MessagingException
setDisposition in interface Partdisposition - The new disposition value.MessagingExceptionpublic String getEncoding() throws MessagingException
getEncoding in interface MimePartMessagingExceptionpublic String getContentID() throws MessagingException
getContentID in interface MimePartMessagingExceptionpublic void setContentID(String cid) throws MessagingException
MessagingExceptionpublic String getContentMD5() throws MessagingException
getContentMD5 in interface MimePartMessagingExceptionpublic void setContentMD5(String md5) throws MessagingException
setContentMD5 in interface MimePartMessagingExceptionpublic String[] getContentLanguage() throws MessagingException
getContentLanguage in interface MimePartMessagingExceptionpublic void setContentLanguage(String[] languages) throws MessagingException
setContentLanguage in interface MimePartMessagingExceptionpublic String getDescription() throws MessagingException
PartgetDescription in interface PartMessagingExceptionpublic void setDescription(String description) throws MessagingException
PartsetDescription in interface Partdescription - The new description.MessagingExceptionpublic void setDescription(String description, String charset) throws MessagingException
MessagingExceptionpublic String getFileName() throws MessagingException
PartgetFileName in interface PartMessagingExceptionpublic void setFileName(String name) throws MessagingException
PartsetFileName in interface Partname - The new name value.MessagingExceptionpublic InputStream getInputStream() throws MessagingException, IOException
PartgetInputStream in interface PartMessagingExceptionIOExceptionprotected InputStream getContentStream() throws MessagingException
MessagingExceptionpublic InputStream getRawInputStream() throws MessagingException
MessagingExceptionpublic javax.activation.DataHandler getDataHandler()
throws MessagingException
PartgetDataHandler in interface PartMessagingExceptionpublic Object getContent() throws MessagingException, IOException
PartgetContent in interface PartMessagingExceptionIOExceptionpublic void setDataHandler(javax.activation.DataHandler handler)
throws MessagingException
PartsetDataHandler in interface Parthandler - The DataHandler instance.MessagingExceptionpublic void setContent(Object content, String type) throws MessagingException
PartsetContent in interface Partcontent - The content object.type - The MIME type for the inserted content Object.MessagingExceptionpublic void setText(String text) throws MessagingException
PartsetText in interface MimePartsetText in interface Parttext - The new text content, as a String object.MessagingExceptionpublic void setText(String text, String charset) throws MessagingException
setText in interface MimePartMessagingExceptionpublic void setText(String text, String charset, String subtype) throws MessagingException
setText in interface MimePartMessagingExceptionpublic void setContent(Multipart part) throws MessagingException
setContent in interface PartMessagingExceptionpublic void writeTo(OutputStream out) throws IOException, MessagingException
PartwriteTo in interface Partout - The target OutputStream.IOExceptionMessagingExceptionpublic String[] getHeader(String name) throws MessagingException
PartgetHeader in interface Partname - The target header name.MessagingExceptionpublic String getHeader(String name, String delimiter) throws MessagingException
getHeader in interface MimePartMessagingExceptionpublic void setHeader(String name, String value) throws MessagingException
PartsetHeader in interface Partname - The name of the target header.value - The new value for the indicated header.MessagingExceptionpublic void addHeader(String name, String value) throws MessagingException
PartaddHeader in interface Partname - The name of the target header.value - The value to be added to the header set.MessagingExceptionpublic void removeHeader(String name) throws MessagingException
PartremoveHeader in interface Partname - The target header name used for removal.MessagingExceptionpublic Enumeration getAllHeaders() throws MessagingException
PartgetAllHeaders in interface PartMessagingExceptionpublic Enumeration getMatchingHeaders(String[] name) throws MessagingException
PartgetMatchingHeaders in interface Partname - An array of names of the desired headers.MessagingExceptionpublic Enumeration getNonMatchingHeaders(String[] name) throws MessagingException
PartgetNonMatchingHeaders in interface Partname - An array of String header names that will be excluded from the return
Enumeration set.MessagingExceptionpublic void addHeaderLine(String line) throws MessagingException
addHeaderLine in interface MimePartMessagingExceptionpublic Enumeration getAllHeaderLines() throws MessagingException
getAllHeaderLines in interface MimePartMessagingExceptionpublic Enumeration getMatchingHeaderLines(String[] names) throws MessagingException
getMatchingHeaderLines in interface MimePartMessagingExceptionpublic Enumeration getNonMatchingHeaderLines(String[] names) throws MessagingException
getNonMatchingHeaderLines in interface MimePartMessagingExceptionprotected void updateHeaders()
throws MessagingException
MessagingExceptionpublic void attachFile(File file) throws IOException, MessagingException
file - The source File object.IOExceptionMessagingExceptionpublic void attachFile(String file) throws IOException, MessagingException
file - The source file name.IOExceptionMessagingExceptionpublic void saveFile(File file) throws IOException, MessagingException
file - The File object used to store the information.IOExceptionMessagingExceptionpublic void saveFile(String file) throws IOException, MessagingException
file - The file name used to store the information.IOExceptionMessagingExceptionCopyright © 2013. All Rights Reserved.