public class IMAPBodyPart extends MimeBodyPart implements ReadableMime
ATTACHMENT, INLINE
Modifier and Type | Method and Description |
---|---|
void |
addHeader(java.lang.String name,
java.lang.String value)
Add this value to the existing values for this header_name.
|
void |
addHeaderLine(java.lang.String line)
Add a header line to this body part
|
java.util.Enumeration<java.lang.String> |
getAllHeaderLines()
Get all header lines as an Enumeration of Strings.
|
java.util.Enumeration<Header> |
getAllHeaders()
Return all the headers from this Message as an Enumeration of
Header objects.
|
java.lang.String |
getContentID()
Returns the value of the "Content-ID" header field.
|
java.lang.String |
getContentMD5()
Return the value of the "Content-MD5" header field.
|
java.lang.String |
getContentType()
Returns the value of the RFC 822 "Content-Type" header field.
|
javax.activation.DataHandler |
getDataHandler()
Return a DataHandler for this body part's content.
|
java.lang.String |
getDescription()
Returns the "Content-Description" header field of this body part.
|
java.lang.String |
getDisposition()
Returns the disposition from the "Content-Disposition" header field.
|
java.lang.String |
getEncoding()
Returns the content transfer encoding from the
"Content-Transfer-Encoding" header
field.
|
java.lang.String |
getFileName()
Get the filename associated with this body part.
|
java.lang.String[] |
getHeader(java.lang.String name)
Get all the headers for this header_name.
|
int |
getLineCount()
Return the number of lines for the content of this Part.
|
java.util.Enumeration<java.lang.String> |
getMatchingHeaderLines(java.lang.String[] names)
Get matching header lines as an Enumeration of Strings.
|
java.util.Enumeration<Header> |
getMatchingHeaders(java.lang.String[] names)
Return matching headers from this Message as an Enumeration of
Header objects.
|
java.io.InputStream |
getMimeStream()
Return the MIME format stream corresponding to this message part.
|
java.util.Enumeration<java.lang.String> |
getNonMatchingHeaderLines(java.lang.String[] names)
Get non-matching header lines as an Enumeration of Strings.
|
java.util.Enumeration<Header> |
getNonMatchingHeaders(java.lang.String[] names)
Return non-matching headers from this Message as an
Enumeration of Header objects.
|
int |
getSize()
Return the size of the content of this body part in bytes.
|
void |
removeHeader(java.lang.String name)
Remove all headers with this name.
|
void |
setContent(Multipart mp)
This method sets the body part's content to a Multipart object.
|
void |
setContent(java.lang.Object o,
java.lang.String type)
A convenience method for setting this body part's content.
|
void |
setContentMD5(java.lang.String md5)
Set the "Content-MD5" header field of this body part.
|
void |
setDataHandler(javax.activation.DataHandler content)
This method provides the mechanism to set this body part's content.
|
void |
setDescription(java.lang.String description,
java.lang.String charset)
Set the "Content-Description" header field for this body part.
|
void |
setDisposition(java.lang.String disposition)
Set the disposition in the "Content-Disposition" header field
of this body part.
|
void |
setFileName(java.lang.String filename)
Set the filename associated with this body part, if possible.
|
void |
setHeader(java.lang.String name,
java.lang.String value)
Set the value for this header_name.
|
attachFile, attachFile, attachFile, attachFile, getContent, getContentLanguage, getHeader, getInputStream, getRawInputStream, isMimeType, saveFile, saveFile, setContentID, setContentLanguage, setDescription, setText, setText, setText, writeTo
public int getSize() throws MessagingException
MimeBodyPart
Note that this number may not be an exact measure of the content size and may or may not account for any transfer encoding of the content.
This implementation returns the size of the content
array (if not null), or, if contentStream
is not
null, and the available
method returns a positive
number, it returns that number as the size. Otherwise, it returns
-1.
getSize
in interface Part
getSize
in class MimeBodyPart
MessagingException
- for failurespublic int getLineCount() throws MessagingException
MimeBodyPart
Note that this number may not be an exact measure of the content length and may or may not account for any transfer encoding of the content.
This implementation returns -1.
getLineCount
in interface Part
getLineCount
in class MimeBodyPart
MessagingException
- for failurespublic java.lang.String getContentType() throws MessagingException
MimeBodyPart
This implementation uses getHeader(name)
to obtain the requisite header field.
getContentType
in interface Part
getContentType
in class MimeBodyPart
MessagingException
- for failuresDataHandler
public java.lang.String getDisposition() throws MessagingException
MimeBodyPart
If the Content-Disposition field is unavailable, null is returned.
This implementation uses getHeader(name)
to obtain the requisite header field.
getDisposition
in interface Part
getDisposition
in class MimeBodyPart
MessagingException
- for failuresMimeBodyPart.headers
public void setDisposition(java.lang.String disposition) throws MessagingException
MimeBodyPart
setDisposition
in interface Part
setDisposition
in class MimeBodyPart
disposition
- disposition of this partIllegalWriteException
- if the underlying
implementation does not support modificationMessagingException
- for other failuresPart.ATTACHMENT
,
Part.INLINE
,
Part.setFileName(java.lang.String)
public java.lang.String getEncoding() throws MessagingException
MimeBodyPart
null
if the header is unavailable
or its value is absent.
This implementation uses getHeader(name)
to obtain the requisite header field.
getEncoding
in interface MimePart
getEncoding
in class MimeBodyPart
MessagingException
- for failuresMimeBodyPart.headers
public java.lang.String getContentID() throws MessagingException
MimeBodyPart
null
if the field is unavailable or its value is
absent.
This implementation uses getHeader(name)
to obtain the requisite header field.
getContentID
in interface MimePart
getContentID
in class MimeBodyPart
MessagingException
- for failurespublic java.lang.String getContentMD5() throws MessagingException
MimeBodyPart
null
if this field is unavailable or its value
is absent.
This implementation uses getHeader(name)
to obtain the requisite header field.
getContentMD5
in interface MimePart
getContentMD5
in class MimeBodyPart
MessagingException
- for failurespublic void setContentMD5(java.lang.String md5) throws MessagingException
MimeBodyPart
setContentMD5
in interface MimePart
setContentMD5
in class MimeBodyPart
md5
- the MD5 valueIllegalWriteException
- if the underlying
implementation does not support modificationMessagingException
public java.lang.String getDescription() throws MessagingException
MimeBodyPart
If the Content-Description field is encoded as per RFC 2047, it is decoded and converted into Unicode. If the decoding or conversion fails, the raw data is returned as is.
This implementation uses getHeader(name)
to obtain the requisite header field.
getDescription
in interface Part
getDescription
in class MimeBodyPart
MessagingException
- for failurespublic void setDescription(java.lang.String description, java.lang.String charset) throws MessagingException
MimeBodyPart
null
, then any
existing "Content-Description" fields are removed. If the description contains non US-ASCII characters, it will be encoded using the specified charset. If the description contains only US-ASCII characters, no encoding is done and it is used as is.
Note that if the charset encoding process fails, a MessagingException is thrown, and an UnsupportedEncodingException is included in the chain of nested exceptions within the MessagingException.
setDescription
in class MimeBodyPart
description
- Descriptioncharset
- Charset for encodingIllegalWriteException
- if the underlying
implementation does not support modificationMessagingException
- otherwise; an
UnsupportedEncodingException may be included
in the exception chain if the charset
conversion fails.public java.lang.String getFileName() throws MessagingException
MimeBodyPart
Returns the value of the "filename" parameter from the
"Content-Disposition" header field of this body part. If its
not available, returns the value of the "name" parameter from
the "Content-Type" header field of this body part.
Returns null
if both are absent.
If the mail.mime.decodefilename
System property
is set to true, the MimeUtility.decodeText
method will be used to decode the
filename. While such encoding is not supported by the MIME
spec, many mailers use this technique to support non-ASCII
characters in filenames. The default value of this property
is false.
getFileName
in interface Part
getFileName
in class MimeBodyPart
MessagingException
- for failurespublic void setFileName(java.lang.String filename) throws MessagingException
MimeBodyPart
Sets the "filename" parameter of the "Content-Disposition" header field of this body part. For compatibility with older mailers, the "name" parameter of the "Content-Type" header is also set.
If the mail.mime.encodefilename
System property
is set to true, the MimeUtility.encodeText
method will be used to encode the
filename. While such encoding is not supported by the MIME
spec, many mailers use this technique to support non-ASCII
characters in filenames. The default value of this property
is false.
setFileName
in interface Part
setFileName
in class MimeBodyPart
filename
- the file nameIllegalWriteException
- if the underlying
implementation does not support modificationMessagingException
- for other failurespublic java.io.InputStream getMimeStream() throws MessagingException
getMimeStream
in interface ReadableMime
MessagingException
- for failurespublic javax.activation.DataHandler getDataHandler() throws MessagingException
MimeBodyPart
The implementation provided here works just like the the implementation in MimeMessage.
getDataHandler
in interface Part
getDataHandler
in class MimeBodyPart
MessagingException
- for failuresMimeMessage.getDataHandler()
public void setDataHandler(javax.activation.DataHandler content) throws MessagingException
MimeBodyPart
setDataHandler
in interface Part
setDataHandler
in class MimeBodyPart
content
- The DataHandler for the contentIllegalWriteException
- if the underlying implementation
does not support modification of existing valuesMessagingException
- for other failurespublic void setContent(java.lang.Object o, java.lang.String type) throws MessagingException
MimeBodyPart
The content is wrapped in a DataHandler object. Note that a
DataContentHandler class for the specified type should be
available to the JavaMail implementation for this to work right.
That is, to do setContent(foobar, "application/x-foobar")
,
a DataContentHandler for "application/x-foobar" should be installed.
Refer to the Java Activation Framework for more information.
setContent
in interface Part
setContent
in class MimeBodyPart
o
- the content objecttype
- Mime type of the objectIllegalWriteException
- if the underlying implementation
does not support modification of existing valuesMessagingException
- for other failurespublic void setContent(Multipart mp) throws MessagingException
MimeBodyPart
setContent
in interface Part
setContent
in class MimeBodyPart
mp
- The multipart object that is the Message's contentIllegalWriteException
- if the underlying
implementation does not support modification of
existing valuesMessagingException
- for other failurespublic java.lang.String[] getHeader(java.lang.String name) throws MessagingException
MimeBodyPart
getHeader
in interface Part
getHeader
in class MimeBodyPart
name
- name of headerMessagingException
- for failuresMimeUtility
public void setHeader(java.lang.String name, java.lang.String value) throws MessagingException
MimeBodyPart
setHeader
in interface Part
setHeader
in class MimeBodyPart
name
- header namevalue
- header valueIllegalWriteException
- if the underlying
implementation does not support modification
of existing valuesMessagingException
- for other failuresMimeUtility
public void addHeader(java.lang.String name, java.lang.String value) throws MessagingException
MimeBodyPart
addHeader
in interface Part
addHeader
in class MimeBodyPart
name
- header namevalue
- header valueIllegalWriteException
- if the underlying
implementation does not support modification
of existing valuesMessagingException
- for other failuresMimeUtility
public void removeHeader(java.lang.String name) throws MessagingException
MimeBodyPart
removeHeader
in interface Part
removeHeader
in class MimeBodyPart
name
- the name of this headerIllegalWriteException
- if the underlying
implementation does not support modification
of existing valuesMessagingException
- for other failurespublic java.util.Enumeration<Header> getAllHeaders() throws MessagingException
MimeBodyPart
getAllHeaders
in interface Part
getAllHeaders
in class MimeBodyPart
MessagingException
- for failurespublic java.util.Enumeration<Header> getMatchingHeaders(java.lang.String[] names) throws MessagingException
MimeBodyPart
getMatchingHeaders
in interface Part
getMatchingHeaders
in class MimeBodyPart
names
- the headers to matchMessagingException
- for failurespublic java.util.Enumeration<Header> getNonMatchingHeaders(java.lang.String[] names) throws MessagingException
MimeBodyPart
getNonMatchingHeaders
in interface Part
getNonMatchingHeaders
in class MimeBodyPart
names
- the headers to not matchMessagingException
- for failurespublic void addHeaderLine(java.lang.String line) throws MessagingException
MimeBodyPart
addHeaderLine
in interface MimePart
addHeaderLine
in class MimeBodyPart
line
- the line to addIllegalWriteException
- if the underlying
implementation does not support modificationMessagingException
- for other failurespublic java.util.Enumeration<java.lang.String> getAllHeaderLines() throws MessagingException
MimeBodyPart
getAllHeaderLines
in interface MimePart
getAllHeaderLines
in class MimeBodyPart
MessagingException
- for failurespublic java.util.Enumeration<java.lang.String> getMatchingHeaderLines(java.lang.String[] names) throws MessagingException
MimeBodyPart
getMatchingHeaderLines
in interface MimePart
getMatchingHeaderLines
in class MimeBodyPart
names
- the headers to returnMessagingException
- for failurespublic java.util.Enumeration<java.lang.String> getNonMatchingHeaderLines(java.lang.String[] names) throws MessagingException
MimeBodyPart
getNonMatchingHeaderLines
in interface MimePart
getNonMatchingHeaderLines
in class MimeBodyPart
names
- the headers to not returnMessagingException
- for failuresCopyright © 2010 - 2020 Adobe. All Rights Reserved