public class IMAPBodyPart extends MimeBodyPart implements ReadableMime
cachedContent, content, contentStream, dh, headersATTACHMENT, INLINE| 限定符 | 构造器和说明 |
|---|---|
protected |
IMAPBodyPart(BODYSTRUCTURE bs,
String sid,
IMAPMessage message) |
| 限定符和类型 | 方法和说明 |
|---|---|
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<String> |
getAllHeaderLines()
Get all header lines as an Enumeration of Strings.
|
Enumeration<Header> |
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 disposition from 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<String> |
getMatchingHeaderLines(String[] names)
Get matching header lines as an Enumeration of Strings.
|
Enumeration<Header> |
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<String> |
getNonMatchingHeaderLines(String[] names)
Get non-matching header lines as an Enumeration of Strings.
|
Enumeration<Header> |
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 disposition in 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.
|
attachFile, attachFile, attachFile, attachFile, getContent, getContentLanguage, getHeader, getInputStream, getRawInputStream, isMimeType, saveFile, saveFile, setContentID, setContentLanguage, setDescription, setText, setText, setText, writeToprotected IMAPBodyPart(BODYSTRUCTURE bs, String sid, IMAPMessage message)
protected void updateHeaders()
MimeBodyPartContent-Type and Content-Transfer-Encoding.
Headers might need to be updated in two cases:
Message.saveChanges method.
If the MimeBodyPart.cachedContent field is not null (that is,
it references a Multipart or Message object), then
that object is used to set a new DataHandler, any
stream data used to create this object is discarded,
and the MimeBodyPart.cachedContent field is cleared.
updateHeaders 在类中 MimeBodyPartpublic 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 在接口中 PartgetSize 在类中 MimeBodyPartMessagingException - for failurespublic 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 在接口中 PartgetLineCount 在类中 MimeBodyPartMessagingException - for failurespublic String getContentType() throws MessagingException
MimeBodyPart
This implementation uses getHeader(name)
to obtain the requisite header field.
getContentType 在接口中 PartgetContentType 在类中 MimeBodyPartMessagingException - for failuresDataHandlerpublic 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 在接口中 PartgetDisposition 在类中 MimeBodyPartMessagingException - for failuresMimeBodyPart.headerspublic void setDisposition(String disposition) throws MessagingException
MimeBodyPartsetDisposition 在接口中 PartsetDisposition 在类中 MimeBodyPartdisposition - disposition of this partIllegalWriteException - if the underlying
implementation does not support modificationMessagingException - for other failuresPart.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 在接口中 MimePartgetEncoding 在类中 MimeBodyPartMessagingException - for failuresMimeBodyPart.headerspublic 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 在接口中 MimePartgetContentID 在类中 MimeBodyPartMessagingException - for failurespublic 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 在接口中 MimePartgetContentMD5 在类中 MimeBodyPartMessagingException - for failurespublic void setContentMD5(String md5) throws MessagingException
MimeBodyPartsetContentMD5 在接口中 MimePartsetContentMD5 在类中 MimeBodyPartmd5 - the MD5 valueIllegalWriteException - if the underlying
implementation does not support modificationMessagingExceptionpublic 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 在接口中 PartgetDescription 在类中 MimeBodyPartMessagingException - for failurespublic 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 在类中 MimeBodyPartdescription - 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 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 在接口中 PartgetFileName 在类中 MimeBodyPartMessagingException - for failurespublic 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 在接口中 PartsetFileName 在类中 MimeBodyPartfilename - the file nameIllegalWriteException - if the underlying
implementation does not support modificationMessagingException - for other failuresprotected InputStream getContentStream() throws MessagingException
MimeBodyPartgetContentStream 在类中 MimeBodyPartMessagingException - for failuresMimeBodyPart.content,
MimeMessage.getContentStream()public InputStream getMimeStream() throws MessagingException
getMimeStream 在接口中 ReadableMimeMessagingException - for failurespublic DataHandler getDataHandler() throws MessagingException
MimeBodyPartThe implementation provided here works just like the the implementation in MimeMessage.
getDataHandler 在接口中 PartgetDataHandler 在类中 MimeBodyPartMessagingException - for failuresMimeMessage.getDataHandler()public void setDataHandler(DataHandler content) throws MessagingException
MimeBodyPartsetDataHandler 在接口中 PartsetDataHandler 在类中 MimeBodyPartcontent - The DataHandler for the contentIllegalWriteException - if the underlying implementation
does not support modification of existing valuesMessagingException - for other failurespublic 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 在接口中 PartsetContent 在类中 MimeBodyParto - 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
MimeBodyPartsetContent 在接口中 PartsetContent 在类中 MimeBodyPartmp - The multipart object that is the Message's contentIllegalWriteException - if the underlying
implementation does not support modification of
existing valuesMessagingException - for other failurespublic String[] getHeader(String name) throws MessagingException
MimeBodyPartgetHeader 在接口中 PartgetHeader 在类中 MimeBodyPartname - name of headerMessagingException - for failuresMimeUtilitypublic void setHeader(String name, String value) throws MessagingException
MimeBodyPartsetHeader 在接口中 PartsetHeader 在类中 MimeBodyPartname - header namevalue - header valueIllegalWriteException - if the underlying
implementation does not support modification
of existing valuesMessagingException - for other failuresMimeUtilitypublic void addHeader(String name, String value) throws MessagingException
MimeBodyPartaddHeader 在接口中 PartaddHeader 在类中 MimeBodyPartname - header namevalue - header valueIllegalWriteException - if the underlying
implementation does not support modification
of existing valuesMessagingException - for other failuresMimeUtilitypublic void removeHeader(String name) throws MessagingException
MimeBodyPartremoveHeader 在接口中 PartremoveHeader 在类中 MimeBodyPartname - the name of this headerIllegalWriteException - if the underlying
implementation does not support modification
of existing valuesMessagingException - for other failurespublic Enumeration<Header> getAllHeaders() throws MessagingException
MimeBodyPartgetAllHeaders 在接口中 PartgetAllHeaders 在类中 MimeBodyPartMessagingException - for failurespublic Enumeration<Header> getMatchingHeaders(String[] names) throws MessagingException
MimeBodyPartgetMatchingHeaders 在接口中 PartgetMatchingHeaders 在类中 MimeBodyPartnames - the headers to matchMessagingException - for failurespublic Enumeration<Header> getNonMatchingHeaders(String[] names) throws MessagingException
MimeBodyPartgetNonMatchingHeaders 在接口中 PartgetNonMatchingHeaders 在类中 MimeBodyPartnames - the headers to not matchMessagingException - for failurespublic void addHeaderLine(String line) throws MessagingException
MimeBodyPartaddHeaderLine 在接口中 MimePartaddHeaderLine 在类中 MimeBodyPartline - the line to addIllegalWriteException - if the underlying
implementation does not support modificationMessagingException - for other failurespublic Enumeration<String> getAllHeaderLines() throws MessagingException
MimeBodyPartgetAllHeaderLines 在接口中 MimePartgetAllHeaderLines 在类中 MimeBodyPartMessagingException - for failurespublic Enumeration<String> getMatchingHeaderLines(String[] names) throws MessagingException
MimeBodyPartgetMatchingHeaderLines 在接口中 MimePartgetMatchingHeaderLines 在类中 MimeBodyPartnames - the headers to returnMessagingException - for failurespublic Enumeration<String> getNonMatchingHeaderLines(String[] names) throws MessagingException
MimeBodyPartgetNonMatchingHeaderLines 在接口中 MimePartgetNonMatchingHeaderLines 在类中 MimeBodyPartnames - the headers to not returnMessagingException - for failuresCopyright © 2021 Oracle. All rights reserved.