void | addHeader(String name, String value) Add this value to the existing values for this header name. |
Enumeration | Return all the headers from this part as an Enumeration of Header objects. |
Object | Return the content as a Java object. |
String | Returns the Content-Type of the content of this part. |
DataHandler | Return a DataHandler for the content within this part. |
String | Return a description String for this part. |
String | Return the disposition of this part. |
String | Get the filename associated with this part, if possible. |
String[] | getHeader(String name) Get all the headers for this header name. |
InputStream | Return an input stream for this part's "content". |
int | Return the number of lines in the content of this part. |
Enumeration | getMatchingHeaders(String[] names) Return matching headers from this part as an Enumeration of Header objects. |
Enumeration | getNonMatchingHeaders(String[] names) Return non-matching headers from this envelope as an Enumeration of Header objects. |
int | getSize() Return the size of the content of this part in bytes. |
boolean | isMimeType(String mimeType) Is this Part of the specified MIME type? This method compares only the primaryType and subType. |
void | removeHeader(String name) Remove all headers with this name. |
void | setContent(Object obj, String type) A convenience method for setting this part's content. |
void | setContent(Multipart mp) This method sets the given Multipart object as this message's content. |
void | setDataHandler(DataHandler dh) This method provides the mechanism to set this part's content. |
void | setDescription(String description) Set a description String for this part. |
void | setDisposition(String disposition) Set the disposition of this part. |
void | setFileName(String filename) Set the filename associated with this part, if possible. |
void | setHeader(String name, String value) Set the value for this header name. |
void | setText(String text) A convenience method that sets the given String as this part's content with a MIME type of "text/plain". |
void | writeTo(OutputStream os) Output a bytestream for this Part. |
public void addHeader(String name, String value)
IllegalWriteException
- if the underlying implementation
does not support modification of this header
- if this Part is obtained from
a READ_ONLY folderpublic Enumeration getAllHeaders()
public Object getContent()
getContent()
method
- this is typically thrown by the DataHandler.public String getContentType()
public DataHandler getDataHandler()
public String getDescription()
public String getDisposition()
String disp = part.getDisposition(); if (disp == null || disp.equalsIgnoreCase(Part.ATTACHMENT)) // treat as attachment if not first par
public String getFileName()
public String[] getHeader(String name)
public InputStream getInputStream()
getInputStream()
method.
- this is typically thrown by the DataHandler.public int getLineCount()
public Enumeration getMatchingHeaders(String[] names)
public Enumeration getNonMatchingHeaders(String[] names)
public int getSize()
public boolean isMimeType(String mimeType)
public void removeHeader(String name)
IllegalWriteException
- if the underlying implementation
does not support modification of this header
- if this Part is obtained from
a READ_ONLY folderpublic void setContent(Object obj, String type)
setContent(foobar, "application/x-foobar")
,
a DataContentHandler for "application/x-foobar" should be installed.
Refer to the Java Activation Framework for more information.
IllegalWriteException
- if the underlying implementation
does not support modification of this header
- if this Part is obtained from
a READ_ONLY folderpublic void setContent(Multipart mp)
IllegalWriteException
- if the underlying implementation
does not support modification of this header
- if this Part is obtained from
a READ_ONLY folderpublic void setDataHandler(DataHandler dh)
IllegalWriteException
- if the underlying implementation
does not support modification of this header
- if this Part is obtained from
a READ_ONLY folderpublic void setDescription(String description)
IllegalWriteException
- if the underlying implementation
does not support modification of this header
- if this Part is obtained from
a READ_ONLY folderpublic void setDisposition(String disposition)
IllegalWriteException
- if the underlying implementation
does not support modification of this header
- if this Part is obtained from
a READ_ONLY folderpublic void setFileName(String filename)
IllegalWriteException
- if the underlying implementation
does not support modification of this header
- if this Part is obtained from
a READ_ONLY folderpublic void setHeader(String name, String value)
IllegalWriteException
- if the underlying implementation
does not support modification of this header
- if this Part is obtained from
a READ_ONLY folderpublic void setText(String text)
IllegalWriteException
- if the underlying implementation
does not support modification of this header
- if this Part is obtained from
a READ_ONLY folderpublic void writeTo(OutputStream os)
- if an error occurs writing to the stream
or if an error is generated by the javax.activation layer.MessagingException
- if an error occurs fetching the data
to be written
getContentType()
method. The MIME typing system is used to name data types. The "content" of a Part is available in various formats:getDataHandler()
method. The "content" of a Part is also available through a javax.activation.DataHandler object. The DataHandler object allows clients to discover the operations available on the content, and to instantiate the appropriate component to perform those operations.getInputStream()
method. Any mail-specific encodings are decoded before this stream is returned.getContent()
method. This method returns the "content" as a Java object. The returned object is of course dependent on the content itself. In particular, a "multipart" Part's content is always a Multipart or subclass thereof. That is,getContent()
on a "multipart" type Part will always return a Multipart (or subclass) object.writeTo()
method that streams out its bytestream in mail-safe form suitable for transmission. This bytestream is typically an aggregation of the Part attributes and its content's bytestream. Message and BodyPart implement the Part interface. Note that in MIME parlance, Part models an Entity (RFC 2045, Section 2.4).