|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.mail.BodyPart
javax.mail.internet.MimeBodyPart
com.sun.mail.imap.IMAPBodyPart
public class IMAPBodyPart
An IMAP body part.
| Field Summary |
|---|
| Fields inherited from class javax.mail.internet.MimeBodyPart |
|---|
content, contentStream, dh, headers |
| Fields inherited from class javax.mail.BodyPart |
|---|
parent |
| Fields inherited from interface javax.mail.Part |
|---|
ATTACHMENT, INLINE |
| Constructor Summary | |
|---|---|
protected |
IMAPBodyPart(BODYSTRUCTURE bs,
String sid,
IMAPMessage message)
|
| Method Summary | |
|---|---|
void |
addHeader(String name,
String value)
Add this value to the existing values for this header_name. |
void |
addHeaderLine(String line)
Add a header line to this body part |
Enumeration |
getAllHeaderLines()
Get all header lines as an Enumeration of Strings. |
Enumeration |
getAllHeaders()
Return all the headers from this Message as an Enumeration of Header objects. |
String |
getContentID()
Returns the value of the "Content-ID" header field. |
String |
getContentMD5()
Return the value of the "Content-MD5" header field. |
protected InputStream |
getContentStream()
Produce the raw bytes of the content. |
String |
getContentType()
Returns the value of the RFC 822 "Content-Type" header field. |
DataHandler |
getDataHandler()
Return a DataHandler for this body part's content. |
String |
getDescription()
Returns the "Content-Description" header field of this body part. |
String |
getDisposition()
Returns the value of the "Content-Disposition" header field. |
String |
getEncoding()
Returns the content transfer encoding from the "Content-Transfer-Encoding" header field. |
String |
getFileName()
Get the filename associated with this body part. |
String[] |
getHeader(String name)
Get all the headers for this header_name. |
int |
getLineCount()
Return the number of lines for the content of this Part. |
Enumeration |
getMatchingHeaderLines(String[] names)
Get matching header lines as an Enumeration of Strings. |
Enumeration |
getMatchingHeaders(String[] names)
Return matching headers from this Message as an Enumeration of Header objects. |
InputStream |
getMimeStream()
Return the MIME format stream corresponding to this message part. |
Enumeration |
getNonMatchingHeaderLines(String[] names)
Get non-matching header lines as an Enumeration of Strings. |
Enumeration |
getNonMatchingHeaders(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(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(Object o,
String type)
A convenience method for setting this body part's content. |
void |
setContentMD5(String md5)
Set the "Content-MD5" header field of this body part. |
void |
setDataHandler(DataHandler content)
This method provides the mechanism to set this body part's content. |
void |
setDescription(String description,
String charset)
Set the "Content-Description" header field for this body part. |
void |
setDisposition(String disposition)
Set the "Content-Disposition" header field of this body part. |
void |
setFileName(String filename)
Set the filename associated with this body part, if possible. |
void |
setHeader(String name,
String value)
Set the value for this header_name. |
protected void |
updateHeaders()
Examine the content of this body part and update the appropriate MIME headers. |
| Methods inherited from class javax.mail.internet.MimeBodyPart |
|---|
attachFile, attachFile, getContent, getContentLanguage, getHeader, getInputStream, getRawInputStream, isMimeType, saveFile, saveFile, setContentID, setContentLanguage, setDescription, setText, setText, setText, writeTo |
| Methods inherited from class javax.mail.BodyPart |
|---|
getParent |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected IMAPBodyPart(BODYSTRUCTURE bs,
String sid,
IMAPMessage message)
| Method Detail |
|---|
protected void updateHeaders()
MimeBodyPartContent-Type and Content-Transfer-Encoding.
Headers might need to be updated in two cases:
Message.saveChanges method.
updateHeaders in class MimeBodyPart
public int getSize()
throws MessagingException
MimeBodyPartNote 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 PartgetSize in class MimeBodyPartMessagingException
public int getLineCount()
throws MessagingException
MimeBodyPartNote 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 PartgetLineCount in class MimeBodyPartMessagingException
public String getContentType()
throws MessagingException
MimeBodyPart
This implementation uses getHeader(name)
to obtain the requisite header field.
getContentType in interface PartgetContentType in class MimeBodyPartMessagingExceptionDataHandler
public String getDisposition()
throws MessagingException
MimeBodyPartIf the Content-Disposition field is unavailable, null is returned.
This implementation uses getHeader(name)
to obtain the requisite header field.
getDisposition in interface PartgetDisposition in class MimeBodyPartMessagingExceptionMimeBodyPart.headers
public void setDisposition(String disposition)
throws MessagingException
MimeBodyPart
setDisposition in interface PartsetDisposition in class MimeBodyPartdisposition - disposition of this part
MessagingException
IllegalWriteException - if the underlying implementation
does not support modification of this headerPart.ATTACHMENT,
Part.INLINE,
Part.setFileName(java.lang.String)
public String getEncoding()
throws MessagingException
MimeBodyPartnull if the header is unavailable
or its value is absent.
This implementation uses getHeader(name)
to obtain the requisite header field.
getEncoding in interface MimePartgetEncoding in class MimeBodyPartMessagingExceptionMimeBodyPart.headers
public String getContentID()
throws MessagingException
MimeBodyPartnull if the field is unavailable or its value is
absent.
This implementation uses getHeader(name)
to obtain the requisite header field.
getContentID in interface MimePartgetContentID in class MimeBodyPartMessagingException
public String getContentMD5()
throws MessagingException
MimeBodyPartnull if this field is unavailable or its value
is absent.
This implementation uses getHeader(name)
to obtain the requisite header field.
getContentMD5 in interface MimePartgetContentMD5 in class MimeBodyPartMessagingException
public void setContentMD5(String md5)
throws MessagingException
MimeBodyPart
setContentMD5 in interface MimePartsetContentMD5 in class MimeBodyPartmd5 - the MD5 value
IllegalWriteException - if the underlying
implementation does not support modification
MessagingException
public String getDescription()
throws MessagingException
MimeBodyPartIf 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 PartgetDescription in class MimeBodyPartMessagingException
public void setDescription(String description,
String charset)
throws MessagingException
MimeBodyPartnull, 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 MimeBodyPartdescription - Descriptioncharset - Charset for encoding
IllegalWriteException - if the underlying
implementation does not support modification
MessagingException - otherwise; an
UnsupportedEncodingException may be included
in the exception chain if the charset
conversion fails.
public 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 PartgetFileName in class MimeBodyPartMessagingException
public void setFileName(String filename)
throws MessagingException
MimeBodyPartSets 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 PartsetFileName in class MimeBodyPartfilename - Filename to associate with this part
IllegalWriteException - if the underlying implementation
does not support modification of this header
MessagingException
protected InputStream getContentStream()
throws MessagingException
MimeBodyPart
getContentStream in class MimeBodyPartMessagingExceptionMimeBodyPart.content,
MimeMessage.getContentStream()
public InputStream getMimeStream()
throws MessagingException
getMimeStream in interface ReadableMimeMessagingException
public DataHandler getDataHandler()
throws MessagingException
MimeBodyPartThe implementation provided here works just like the the implementation in MimeMessage.
getDataHandler in interface PartgetDataHandler in class MimeBodyPartMessagingExceptionMimeMessage.getDataHandler()
public void setDataHandler(DataHandler content)
throws MessagingException
MimeBodyPart
setDataHandler in interface PartsetDataHandler in class MimeBodyPartcontent - The DataHandler for the content
MessagingException
IllegalWriteException - if the underlying implementation
does not support modification of existing values
public void setContent(Object o,
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 PartsetContent in class MimeBodyParto - the content objecttype - Mime type of the object
IllegalWriteException - if the underlying implementation
does not support modification of existing values
MessagingException
public void setContent(Multipart mp)
throws MessagingException
MimeBodyPart
setContent in interface PartsetContent in class MimeBodyPartmp - The multipart object that is the Message's content
IllegalWriteException - if the underlying
implementation does not support modification of
existing values
MessagingException
public String[] getHeader(String name)
throws MessagingException
MimeBodyPart
getHeader in interface PartgetHeader in class MimeBodyPartname - name of header
MessagingExceptionMimeUtility
public void setHeader(String name,
String value)
throws MessagingException
MimeBodyPart
setHeader in interface PartsetHeader in class MimeBodyPartname - header namevalue - header value
MessagingException
IllegalWriteException - if the underlying
implementation does not support modification
of existing valuesMimeUtility
public void addHeader(String name,
String value)
throws MessagingException
MimeBodyPart
addHeader in interface PartaddHeader in class MimeBodyPartname - header namevalue - header value
MessagingException
IllegalWriteException - if the underlying
implementation does not support modification
of existing valuesMimeUtility
public void removeHeader(String name)
throws MessagingException
MimeBodyPart
removeHeader in interface PartremoveHeader in class MimeBodyPartname - the name of this header
MessagingException
IllegalWriteException - if the underlying
implementation does not support modification
of existing values
public Enumeration getAllHeaders()
throws MessagingException
MimeBodyPart
getAllHeaders in interface PartgetAllHeaders in class MimeBodyPartMessagingException
public Enumeration getMatchingHeaders(String[] names)
throws MessagingException
MimeBodyPart
getMatchingHeaders in interface PartgetMatchingHeaders in class MimeBodyPartMessagingException
public Enumeration getNonMatchingHeaders(String[] names)
throws MessagingException
MimeBodyPart
getNonMatchingHeaders in interface PartgetNonMatchingHeaders in class MimeBodyPartMessagingException
public void addHeaderLine(String line)
throws MessagingException
MimeBodyPart
addHeaderLine in interface MimePartaddHeaderLine in class MimeBodyPartIllegalWriteException - if the underlying
implementation does not support modification
MessagingException
public Enumeration getAllHeaderLines()
throws MessagingException
MimeBodyPart
getAllHeaderLines in interface MimePartgetAllHeaderLines in class MimeBodyPartMessagingException
public Enumeration getMatchingHeaderLines(String[] names)
throws MessagingException
MimeBodyPart
getMatchingHeaderLines in interface MimePartgetMatchingHeaderLines in class MimeBodyPartMessagingException
public Enumeration getNonMatchingHeaderLines(String[] names)
throws MessagingException
MimeBodyPart
getNonMatchingHeaderLines in interface MimePartgetNonMatchingHeaderLines in class MimeBodyPartMessagingException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||