|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Part
A part consists of a set of attributes and a content. Some of the attributes provide metadata describing the content and its encoding, others may describe how to process the part. The Part interface is the common base interface for Messages and BodyParts.
The content of a part is available in various forms:
getDataHandler
method.
getInputStream
method.
getContent
method.
writeTo
method can be used to write the part to a
byte stream in mail-safe form suitable for transmission.
In MIME terms, Part models an Entity (RFC 2045, Section 2.4).
Field Summary | |
---|---|
static String |
ATTACHMENT
This part should be presented as an attachment. |
static String |
INLINE
This part should be presented inline. |
Method Summary | |
---|---|
void |
addHeader(String name,
String value)
Adds the specified value to the existing values for this header name. |
Enumeration |
getAllHeaders()
Returns all the headers from this part. |
Object |
getContent()
Returns the content of this part as a Java object. |
String |
getContentType()
Returns the content-type of the content of this part, or null if the content-type could not be determined. |
DataHandler |
getDataHandler()
Returns a data handler for the content of this part. |
String |
getDescription()
Returns the description of this part. |
String |
getDisposition()
Returns the disposition of this part. |
String |
getFileName()
Returns the filename associated with this part, if available. |
String[] |
getHeader(String name)
Returns all the values for the specified header name, or null if no such headers are available. |
InputStream |
getInputStream()
Returns an input stream for reading the content of this part. |
int |
getLineCount()
Returns the number of lines in the content of this part, or -1 if the number cannot be determined. |
Enumeration |
getMatchingHeaders(String[] names)
Returns the matching headers from this part. |
Enumeration |
getNonMatchingHeaders(String[] names)
Returns the non-matching headers from this part. |
int |
getSize()
Returns the size of the content of this part in bytes, or -1 if the size cannot be determined. |
boolean |
isMimeType(String mimeType)
Is this part of the specified MIME type? This method compares only the primary type and subtype. |
void |
removeHeader(String name)
Removes all headers of the specified name. |
void |
setContent(Multipart mp)
Sets the multipart content of this part. |
void |
setContent(Object obj,
String type)
Sets the content of this part using the specified object. |
void |
setDataHandler(DataHandler dh)
Sets the content of this part using the specified data handler. |
void |
setDescription(String description)
Sets the description of this part. |
void |
setDisposition(String disposition)
Sets the disposition of this part. |
void |
setFileName(String filename)
Sets the filename associated with this part. |
void |
setHeader(String name,
String value)
Sets the value for the specified header name. |
void |
setText(String text)
Sets the textual content of this part, using a MIME type of text/plain . |
void |
writeTo(OutputStream os)
Writes this part to the specified byte stream. |
Field Detail |
---|
static final String ATTACHMENT
static final String INLINE
Method Detail |
---|
int getSize() throws MessagingException
Note that the size may not be an exact measure of the content size, but will be suitable for display in a user interface to give the user an idea of the size of this part.
MessagingException
int getLineCount() throws MessagingException
MessagingException
String getContentType() throws MessagingException
null
if the content-type could not be determined.
The MIME typing system is used to name content-types.
MessagingException
boolean isMimeType(String mimeType) throws MessagingException
If the subtype of mimeType
is the special character '*',
then the subtype is ignored during the comparison.
MessagingException
String getDisposition() throws MessagingException
MessagingException
void setDisposition(String disposition) throws MessagingException
disposition
- the disposition of this part
IllegalWriteException
- if the underlying implementation
does not support modification of this header
IllegalStateException
- if this part is obtained from
a READ_ONLY folder
MessagingException
String getDescription() throws MessagingException
MessagingException
void setDescription(String description) throws MessagingException
description
- the description of this part
IllegalWriteException
- if the underlying implementation
does not support modification of this header
IllegalStateException
- if this Part is obtained from
a READ_ONLY folder
MessagingException
String getFileName() throws MessagingException
MessagingException
void setFileName(String filename) throws MessagingException
filename
- the filename to associate with this part
IllegalWriteException
- if the underlying implementation
does not support modification of this header
IllegalStateException
- if this Part is obtained from
a READ_ONLY folder
MessagingException
InputStream getInputStream() throws IOException, MessagingException
IOException
- when a data handler error occurs
MessagingException
DataHandler getDataHandler() throws MessagingException
MessagingException
Object getContent() throws IOException, MessagingException
IOException
- when a data handler error occurs
MessagingException
void setDataHandler(DataHandler dh) throws MessagingException
dh
- the data handler for the content
IllegalWriteException
- if the underlying implementation
does not support modification
IllegalStateException
- if this part is obtained from
a READ_ONLY folder
MessagingException
void setContent(Object obj, String type) throws MessagingException
obj
- a Java objecttype
- the MIME content-type of this object
IllegalWriteException
- if the underlying implementation
does not support modification
IllegalStateException
- if this part is obtained from
a READ_ONLY folder
MessagingException
void setText(String text) throws MessagingException
text/plain
.
text
- the textual content
IllegalWriteException
- if the underlying implementation
does not support modification
IllegalStateException
- if this part is obtained from
a READ_ONLY folder
MessagingException
void setContent(Multipart mp) throws MessagingException
mp
- the multipart content
IllegalWriteException
- if the underlying implementation
does not support modification
IllegalStateException
- if this part is obtained from
a READ_ONLY folder
MessagingException
void writeTo(OutputStream os) throws IOException, MessagingException
IOException
- if an error occurs writing to the stream
or if an error occurs in the data handler system.
MessagingException
- if an error occurs fetching the data
to be writtenString[] getHeader(String name) throws MessagingException
null
if no such headers are available.
name
- the header name
MessagingException
void setHeader(String name, String value) throws MessagingException
name
- the header namevalue
- the new value
IllegalWriteException
- if the underlying implementation
does not support modification of this header
IllegalStateException
- if this part is obtained from
a READ_ONLY folder
MessagingException
void addHeader(String name, String value) throws MessagingException
name
- the header namevalue
- the value to add
IllegalWriteException
- if the underlying implementation
does not support modification of this header
IllegalStateException
- if this part is obtained from
a READ_ONLY folder
MessagingException
void removeHeader(String name) throws MessagingException
name
- the header name
IllegalWriteException
- if the underlying implementation
does not support modification of this header
IllegalStateException
- if this part is obtained from
a READ_ONLY folder
MessagingException
Enumeration getAllHeaders() throws MessagingException
MessagingException
Enumeration getMatchingHeaders(String[] names) throws MessagingException
names
- the header names to match
MessagingException
Enumeration getNonMatchingHeaders(String[] names) throws MessagingException
names
- the header names to ignore
MessagingException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |