All Packages Class Hierarchy This Package Previous Next Index
Interface com.ibm.network.mail.base.MimePart
- public interface MimePart
The MimePart
interface is the common base interface for
MimeMessage
s and MimeBodyPart
s.
MimePart
consists of a set of attributes and a "Content".
Attributes:
An attribute is a name/value pair of strings. Each MimePart
has following predefined attributes.
- Content-Type: MIME data type of the this
MimePart
's
content.
- Content-Transfer-Encoding: Or simply Encoding that is the encoding
scheme used to encode the content of this
MimePart
.
- Content-Disposition: How to render this
MimePart
. Valid
values are ATTACHMENT and INLINE.
- File name: The name of the file whose contents are used to create
this
MimePart
. This is optional.
Apart from these, any user defined attributes can be added using
addHeader()
.
Content:
The data type of the "content" is returned by
the getContentType()
method. The MIME typing system
is used to name data types.
The content of a body part is available in various formats:
- As an input stream - using the
getInputStream()
method.
- As a java object - using the
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" body part's content is always a
Multipart or subclass thereof. i.e. getContent()
on a
"multipart" type MimePart
will always return a Multipart
(or subclass) object.
MimePart
provides the putByteStream()
method that
streams out its content as a byte stream in a form suitable for transmission. Before
invoking this method, the content should be encoded by a MIME
encoder. This byte stream is an aggregation of the body part attributes
and its content's byte stream.
MimeMessage
and MimeBodyPart
implement the
MimePart
interface.
- Author:
- Abdul Majeed Ghadialy
- See Also:
- MimeMessage, MimeBodyPart
-
ATTACHMENT
-
-
BASE64
-
-
INLINE
-
-
SEVENBIT
-
-
addHeader(String, String)
- Adds a new field to the
Header
of this part.
-
getContent()
- Returns the content of this part.
-
getContentType()
- Returns the MIME data type of this part.
-
getDisposition()
- Returns the Content-Disposition of this part.
-
getEncoding()
- Returns the Content-Transfer-Encoding of this part.
-
getFileName()
- Returns the file name of this part, if any.
-
getHeader(String)
- Returns the header field value for the specified header field key.
-
getInputStream()
- Returns an
InputStream
connected to the content of this
part.
-
putByteStream(OutputStream)
- Writes the header and encoded data to the
OutputStream
.
-
setContent(Object, String)
- Sets the content and the MIME data type of this part.
-
setDisposition(int)
- Sets the Content-Disposition of this part.
-
setEncoding(int)
- Sets the Content-Transfer-Encoding of this part.
-
setFileName(String)
- Sets the file name of this part.
-
setHeader(String, String)
- Sets the header fields of this part.
ATTACHMENT
public static final int ATTACHMENT
INLINE
public static final int INLINE
BASE64
public static final int BASE64
SEVENBIT
public static final int SEVENBIT
addHeader
public abstract void addHeader(String name,
String value)
- Adds a new field to the
Header
of this part.
- Parameters:
- name - header field key.
- value - header field value.
- See Also:
- addField
getContent
public abstract Object getContent()
- Returns the content of this part.
- Returns:
- the content of this part.
getContentType
public abstract String getContentType()
- Returns the MIME data type of this part.
- Returns:
- the MIME data type of this part.
getDisposition
public abstract int getDisposition()
- Returns the Content-Disposition of this part. The disposition describes how the part
should be presented to the user.
- Returns:
- the Content-Disposition of this part.
getEncoding
public abstract int getEncoding()
- Returns the Content-Transfer-Encoding of this part.
- Returns:
- the Content-Transfer-Encoding of this part.
getFileName
public abstract String getFileName()
- Returns the file name of this part, if any.
- Returns:
- the file name of this part, if any.
getHeader
public abstract String getHeader(String name)
- Returns the header field value for the specified header field key.
- Parameters:
- name - header field key.
- Returns:
- header field value.
getInputStream
public abstract InputStream getInputStream()
- Returns an
InputStream
connected to the content of this
part.
- Returns:
-
InputStream
connected to the content of this
part.
putByteStream
public abstract void putByteStream(OutputStream os) throws IOException
- Writes the header and encoded data to the
OutputStream
.
- Parameters:
- os - OutputStream to write header and content of this part.
- Throws: IOException
- in case an IO error is encountered.
- See Also:
- putByteStream
setContent
public abstract void setContent(Object content,
String type)
- Sets the content and the MIME data type of this part.
- Parameters:
- content - content to be set this part.
- type - MIME data type.
setDisposition
public abstract void setDisposition(int disp)
- Sets the Content-Disposition of this part.
- Parameters:
- disp - Content-Disposition.
setEncoding
public abstract void setEncoding(int encoding)
- Sets the Content-Transfer-Encoding of this part.
- Parameters:
- encoding - Content-Transfer-Encoding.
setFileName
public abstract void setFileName(String fileName)
- Sets the file name of this part.
- Parameters:
- fileName - name of the file.
setHeader
public abstract void setHeader(String name,
String value)
- Sets the header fields of this part.
- Parameters:
- hdr -
Header
to read fields from and set the header fields
of this part.
All Packages Class Hierarchy This Package Previous Next Index