Home » apache-tomcat-6.0.26-src » javax » mail » [javadoc | source]
javax.mail
abstract public class: Multipart [javadoc | source]
java.lang.Object
   javax.mail.Multipart

Direct Known Subclasses:
    MimeMultipart

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.

Field Summary
protected  Vector parts    Vector of BodyPart objects. 
protected  String contentType    This field specifies the content-type of this multipart object. It defaults to "multipart/mixed". 
protected  Part parent    The Part containing this Multipart, if known.
    since: JavaMail - 1.1
 
Constructor:
 protected Multipart() 
Method from javax.mail.Multipart Summary:
addBodyPart,   addBodyPart,   getBodyPart,   getContentType,   getCount,   getParent,   removeBodyPart,   removeBodyPart,   setMultipartDataSource,   setParent,   writeTo
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.mail.Multipart Detail:
 public synchronized  void addBodyPart(BodyPart part) throws MessagingException 
    Adds a Part to the multipart. The BodyPart is appended to the list of existing Parts.
 public synchronized  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.
 public synchronized BodyPart getBodyPart(int index) throws MessagingException 
    Get the specified Part. Parts are numbered starting at 0.
 public String getContentType() 
    Return the content-type of this Multipart.

    This implementation just returns the value of the contentType field.

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

 public synchronized Part getParent() 
    Return the Part that contains this Multipart object, or null if not known.
 public synchronized boolean removeBodyPart(BodyPart part) throws MessagingException 
    Remove the specified part from the multipart message. Shifts all the parts after the removed part down one.
 public synchronized  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.
 protected synchronized  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.

 public synchronized  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.
 abstract public  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.