|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.mail Class Multipart
java.lang.Object javax.mail.Multipart
- Direct Known Subclasses:
- MimeMultipart
public abstract class Multipart
- extends Object
Multipart 是保存多个正文部分的容器。Multipart 提供获取和设置其子部分的方法。
Multipart 还充当多数 Multipart DataContentHandler 所返回的内容对象的基类。例如,对其源为 "multipart/signed" 数据源的 DataHandler 调用 getContent() 方法可能返回相应的 Multipart 子类。
一些消息传递系统提供不同的 Multipart 子类型。例如,MIME 指定了一组包括 "alternative"、"mixed"、"related"、"parallel"、"signed" 等在内的子类型。
Multipart 是一个抽象类。子类提供实际实现。
version | 1.16, 07/05/04 |
Multipart is a container that holds multiple body parts. Multipart provides methods to retrieve and set its subparts.
Multipart also acts as the base class for the content object returned by most Multipart DataContentHandlers. For example, invoking getContent() on a DataHandler whose source is a "multipart/signed" data source may return an appropriate subclass of Multipart.
Some messaging systems provide different subtypes of Multiparts. For example, MIME specifies a set of subtypes that include "alternative", "mixed", "related", "parallel", "signed", etc.
Multipart is an abstract class. Subclasses provide actual implementations.
- Version:
- 1.16, 07/05/04
- Author:
- John Mani
Field Summary | |
---|---|
protected String |
contentType
This field specifies the content-type of this multipart object. |
protected Part |
parent
The Part containing this Multipart ,
if known. |
protected Vector |
parts
Vector of BodyPart objects. |
Constructor Summary | |
---|---|
protected |
Multipart()
Default constructor. |
Method Summary | |
---|---|
void |
addBodyPart(BodyPart part)
Adds a Part to the multipart. |
void |
addBodyPart(BodyPart part,
int index)
Adds a BodyPart at position index . |
BodyPart |
getBodyPart(int index)
Get the specified Part. |
String |
getContentType()
Return the content-type of this Multipart. |
int |
getCount()
Return the number of enclosed BodyPart objects. |
Part |
getParent()
Return the Part that contains this Multipart
object, or null if not known. |
boolean |
removeBodyPart(BodyPart part)
Remove the specified part from the multipart message. |
void |
removeBodyPart(int index)
Remove the part at specified location (starting from 0). |
protected void |
setMultipartDataSource(MultipartDataSource mp)
Setup this Multipart object from the given MultipartDataSource. |
void |
setParent(Part parent)
Set the parent of this Multipart to be the specified
Part . |
abstract void |
writeTo(OutputStream os)
Output an appropriately encoded bytestream to the given OutputStream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
英文文档:
parts
protected Vector parts
- Vector of BodyPart objects.
英文文档:
contentType
protected String contentType
- This field specifies the content-type of this multipart
object. It defaults to "multipart/mixed".
英文文档:
parent
protected Part parent
- The
Part
containing thisMultipart
, if known.- Since:
- JavaMail 1.1
Constructor Detail |
---|
protected
Multipart()
默认构造方法。创建一个空的 Multipart 对象。
英文文档:
Multipart
protected Multipart()
- Default constructor. An empty Multipart object is created.
Method Detail |
---|
protected void
setMultipartDataSource(MultipartDataSource mp) throws MessagingException
根据给定 MultipartDataSource 设置此 Multipart 对象。
该方法将 MultipartDataSource 的 BodyPart 对象添加到此 Multipart 中。此 Multipart 的 contentType 被设置为 MultipartDataSource 的内容类型。
此方法通常在以下情况下使用:拥有已经预先解析成单独正文部分的 Multipart 数据源(例如 IMAP 数据源),但需要创建表示特定 multipart 子类型的相应 Multipart 子类。
mp | Multipart 数据源 |
setMultipartDataSource
protected void setMultipartDataSource(MultipartDataSource mp) throws MessagingException
- Setup this Multipart object from the given MultipartDataSource.
The method adds the MultipartDataSource's BodyPart objects into this Multipart. This Multipart's contentType is set to that of the MultipartDataSource.
This method is typically used in those cases where one has a multipart data source that has already been pre-parsed into the individual body parts (for example, an IMAP datasource), but needs to create an appropriate Multipart subclass that represents a specific multipart subtype.
- Parameters:
mp
- Multipart datasource- Throws:
MessagingException
public String
getContentType()
返回此 Multipart 的内容类型。
此实现只返回 contentType
字段的值。
return | 内容类型 |
See also | contentType |
getContentType
public String getContentType()
- Return the content-type of this Multipart.
This implementation just returns the value of the
contentType
field. - Returns:
- content-type
- See Also:
contentType
public int
getCount() throws MessagingException
返回封闭的 BodyPart 对象的数量。
return | 部分数 |
See also | parts |
getCount
public int getCount() throws MessagingException
- Return the number of enclosed BodyPart objects.
- Returns:
- number of parts
- Throws:
MessagingException
- See Also:
parts
public BodyPart
getBodyPart(int index) throws MessagingException
获取指定的 Part。Part 是从 0 开始编号的。
index | 所需 Part 的索引 |
return | Part |
Throws | IndexOutOfBoundsException: 如果给定索引超出范围。 |
Throws | MessagingException: |
getBodyPart
public BodyPart getBodyPart(int index) throws MessagingException
- Get the specified Part. Parts are numbered starting at 0.
- Parameters:
index
- the index of the desired Part- Returns:
- the Part
- Throws:
IndexOutOfBoundsException
- if the given index is out of range.MessagingException
public boolean
removeBodyPart(BodyPart part) throws MessagingException
从 multipart 消息中移除指定的部分。将所有部分向移除部分移动一位。
part | 要移除的部分 |
return | 如果移除了 part,则返回 true;否则返回 false |
Throws | MessagingException: 如果不存在此类 Part |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
removeBodyPart
public boolean removeBodyPart(BodyPart part) throws MessagingException
- Remove the specified part from the multipart message.
Shifts all the parts after the removed part down one.
- Parameters:
part
- The part to remove- Returns:
- true if part removed, false otherwise
- Throws:
MessagingException
- if no such Part existsIllegalWriteException
- if the underlying implementation does not support modification of existing values
public void
removeBodyPart(int index) throws MessagingException
移除指定位置(从 0 开始)的部分。将所有部分向移除部分移动一位。
index | 要移除部分的索引 |
Throws | MessagingException: |
Throws | IndexOutOfBoundsException: 如果给定索引超出范围。 |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
removeBodyPart
public void removeBodyPart(int index) throws MessagingException
- Remove the part at specified location (starting from 0).
Shifts all the parts after the removed part down one.
- Parameters:
index
- Index of the part to remove- Throws:
MessagingException
IndexOutOfBoundsException
- if the given index is out of range.IllegalWriteException
- if the underlying implementation does not support modification of existing values
public void
addBodyPart(BodyPart part) throws MessagingException
将 Part 添加到 multipart。BodyPart 将被添加到现有的 Part 列表。
part | 要添加的 Part |
Throws | MessagingException: |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
addBodyPart
public void addBodyPart(BodyPart part) throws MessagingException
- Adds a Part to the multipart. The BodyPart is appended to
the list of existing Parts.
- Parameters:
part
- The Part to be appended- Throws:
MessagingException
IllegalWriteException
- if the underlying implementation does not support modification of existing values
public void
addBodyPart(BodyPart part, int index) throws MessagingException
在 index
处添加 BodyPart。如果 index
不是列表中的最后一个,则后续部分将向上移。如果 index
大于现有的部分数,则将在末尾添加 BodyPart。
part | 要插入的 BodyPart |
index | 插入部分的位置 |
Throws | MessagingException: |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
addBodyPart
public void addBodyPart(BodyPart part, int index) throws MessagingException
- Adds a BodyPart at position
index
. Ifindex
is not the last one in the list, the subsequent parts are shifted up. Ifindex
is larger than the number of parts present, the BodyPart is appended to the end. - Parameters:
part
- The BodyPart to be insertedindex
- Location where to insert the part- Throws:
MessagingException
IllegalWriteException
- if the underlying implementation does not support modification of existing values
abstract public void
writeTo(java.io.OutputStream os) throws java.io.IOException, MessagingException
将相应的已编码字节流输出到给定的 OutputStream。实现子类决定相应的编码算法。字节流通常用于发送。
Throws | java.io.IOException: 如果发生与 IO 相关的异常 |
Throws | MessagingException: |
writeTo
public abstract void writeTo(OutputStream os) throws IOException, MessagingException
- Output an appropriately encoded bytestream to the given
OutputStream. The implementation subclass decides the
appropriate encoding algorithm to be used. The bytestream
is typically used for sending.
- Throws:
IOException
- if an IO related exception occursMessagingException
public Part
getParent()
返回包含此 Multipart
对象的 Part
;如果未知,则返回 null
。
since |
|
getParent
public Part getParent()
- Return the
Part
that contains thisMultipart
object, ornull
if not known. - Since:
- JavaMail 1.1
public void
setParent(Part parent)
将此 Multipart
的父 Multipart 设置为指定的 Part
。通常由 Message
或 BodyPart
setContent(Multipart)
方法调用。如果要从包含 Part
中移除 Multipart
,则 parent
可能为 null
。
since |
|
setParent
public void setParent(Part parent)
- Set the parent of this
Multipart
to be the specifiedPart
. Normally called by theMessage
orBodyPart
setContent(Multipart)
method.parent
may benull
if theMultipart
is being removed from its containingPart
. - Since:
- JavaMail 1.1
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!