Multipart (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.mail Class Multipart

java.lang.Object
  extended by javax.mail.Multipart
直接已知子类:
MimeMultipart

public abstract class Multipart
extends Object

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.

版本:
1.16, 07/05/04
作者:
John Mani

字段摘要
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.
 
构造器摘要
protected Multipart()
          Default constructor.
 
方法摘要
 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.
 
类方法继承 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

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 this Multipart, if known.

从以下版本开始:
JavaMail 1.1

构造器详细信息

Multipart

protected Multipart()
Default constructor. An empty Multipart object is created.

方法详细信息

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.

参数:
mp - Multipart datasource
抛出异常:
MessagingException

getContentType

public String getContentType()
Return the content-type of this Multipart.

This implementation just returns the value of the contentType field.

返回:
content-type
另请参见:
contentType

getCount

public int getCount()
             throws MessagingException
Return the number of enclosed BodyPart objects.

返回:
number of parts
抛出异常:
MessagingException
另请参见:
parts

getBodyPart

public BodyPart getBodyPart(int index)
                     throws MessagingException
Get the specified Part. Parts are numbered starting at 0.

参数:
index - the index of the desired Part
返回:
the Part
抛出异常:
IndexOutOfBoundsException - if the given index is out of range.
MessagingException

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.

参数:
part - The part to remove
返回:
true if part removed, false otherwise
抛出异常:
MessagingException - if no such Part exists
IllegalWriteException - if the underlying implementation does not support modification of existing values

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.

参数:
index - Index of the part to remove
抛出异常:
MessagingException
IndexOutOfBoundsException - if the given index is out of range.
IllegalWriteException - if the underlying implementation does not support modification of existing values

addBodyPart

public void addBodyPart(BodyPart part)
                 throws MessagingException
Adds a Part to the multipart. The BodyPart is appended to the list of existing Parts.

参数:
part - The Part to be appended
抛出异常:
MessagingException
IllegalWriteException - if the underlying implementation does not support modification of existing values

addBodyPart

public void addBodyPart(BodyPart part,
                        int index)
                 throws MessagingException
Adds a BodyPart at position index. If index is not the last one in the list, the subsequent parts are shifted up. If index is larger than the number of parts present, the BodyPart is appended to the end.

参数:
part - The BodyPart to be inserted
index - Location where to insert the part
抛出异常:
MessagingException
IllegalWriteException - if the underlying implementation does not support modification of existing values

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.

抛出异常:
IOException - if an IO related exception occurs
MessagingException

getParent

public Part getParent()
Return the Part that contains this Multipart object, or null if not known.

从以下版本开始:
JavaMail 1.1

setParent

public void setParent(Part parent)
Set the parent of this Multipart to be the specified Part. Normally called by the Message or BodyPart setContent(Multipart) method. parent may be null if the Multipart is being removed from its containing Part.

从以下版本开始:
JavaMail 1.1

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.