Movatterモバイル変換


[0]ホーム

URL:


         


Class MimeMultipart

java.lang.Object  |  +--javax.mail.Multipart        |        +--javax.mail.internet.MimeMultipart

public classMimeMultipart
extendsMultipart

The MimeMultipart class is an implementation of the abstract Multipart class that uses MIME conventions for the multipart data.

A MimeMultipart is obtained from a MimePart whose primary type is "multipart" (by invoking the part'sgetContent() method) or it can be created by a client as part of creating a new MimeMessage.

The default multipart subtype is "mixed". The other multipart subtypes, such as "alternative", "related", and so on, can be implemented as subclasses of MimeMultipart with additional methods to implement the additional semantics of that type of multipart content. The intent is that service providers, mail JavaBean writers and mail clients will write many such subclasses and their Command Beans, and will install them into the JavaBeans Activation Framework, so that any JavaMail implementation and its clients can transparently find and use these classes. Thus, a MIME multipart handler is treated just like any other type handler, thereby decoupling the process of providing multipart handlers from the JavaMail API. Lacking these additional MimeMultipart subclasses, all subtypes of MIME multipart data appear as MimeMultipart objects.

An application can directly construct a MIME multipart object of any subtype by using theMimeMultipart(String subtype) constructor.


ds
           
parsed
           
 
Fields inherited from class javax.mail.Multipart
contentType,parent,parts
 
MimeMultipart()
          Default constructor.
MimeMultipart(DataSource ds)
          Constructs a MimeMultipart object and its bodyparts from the given DataSource.
MimeMultipart(java.lang.String subtype)
          Construct a MimeMultipart object of the given subtype.
 
getBodyPart(int index)
          Get the specified BodyPart.
getBodyPart(java.lang.String CID)
          Get the MimeBodyPart referred to by the given ContentID (CID).
getCount()
          Return the number of enclosed BodyPart objects.
setSubType(java.lang.String subtype)
          Set the subtype.
updateHeaders()
          Update headers.
writeTo(java.io.OutputStream os)
          Iterates through all the parts and outputs each Mime part separated by a boundary.
 
Methods inherited from class javax.mail.Multipart
addBodyPart,addBodyPart,getContentType,getParent,removeBodyPart,removeBodyPart,setMultipartDataSource,setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

ds

protectedDataSourceds

parsed

protected booleanparsed

MimeMultipart

publicMimeMultipart()
Default constructor. An empty MimeMultipart object is created. Its content type is set to "multipart/mixed". A unique boundary string is generated and this string is setup as the "boundary" parameter for thecontentType field.

MimeBodyParts may be added later.


MimeMultipart

publicMimeMultipart(java.lang.String subtype)
Construct a MimeMultipart object of the given subtype. A unique boundary string is generated and this string is setup as the "boundary" parameter for thecontentType field.

MimeBodyParts may be added later.


MimeMultipart

publicMimeMultipart(DataSource ds)              throwsMessagingException
Constructs a MimeMultipart object and its bodyparts from the given DataSource.

This constructor handles as a special case the situation where the given DataSource is a MultipartDataSource object. In this case, this method just invokes the superclass (i.e., Multipart) constructor that takes a MultipartDataSource object.

Otherwise, the DataSource is assumed to provide a MIME multipart byte stream. The parser extracts the "boundary" parameter from the content type of this DataSource, skips the 'preamble' and reads bytes till the terminating boundary and creates MimeBodyParts for each part of the stream.

Parameters:
ds - DataSource, can be a MultipartDataSource

setSubType

public voidsetSubType(java.lang.String subtype)                throwsMessagingException
Set the subtype. This method should be invoked only on a new MimeMultipart object created by the client. The default subtype of such a multipart object is "mixed".

Parameters:
subtype - Subtype

getCount

public intgetCount()             throwsMessagingException
Return the number of enclosed BodyPart objects.
Overrides:
getCount in classMultipart
Returns:
number of parts

getBodyPart

publicBodyPartgetBodyPart(int index)                     throwsMessagingException
Get the specified BodyPart. BodyParts are numbered starting at 0.
Overrides:
getBodyPart in classMultipart
Parameters:
index - the index of the desired BodyPart
Returns:
the Part
Throws:
MessagingException - if no such BodyPart exists

getBodyPart

publicBodyPartgetBodyPart(java.lang.String CID)                     throwsMessagingException
Get the MimeBodyPart referred to by the given ContentID (CID). Returns null if the part is not found.
Parameters:
CID - the ContentID of the desired part
Returns:
the Part

updateHeaders

protected voidupdateHeaders()                      throwsMessagingException
Update headers. The default implementation here just calls theupdateHeaders method on each of its children BodyParts.

Note that the boundary parameter is already set up when a new and empty MimeMultipart object is created.

This method is called when thesaveChanges method is invoked on the Message object containing this Multipart. This is typically done as part of the Message send process, however note that a client is free to call it any number of times. So if the header updating process is expensive for a specific MimeMultipart subclass, then it might itself want to track whether its internal state actually did change, and do the header updating only if necessary.


writeTo

public voidwriteTo(java.io.OutputStream os)             throws java.io.IOException,MessagingException
Iterates through all the parts and outputs each Mime part separated by a boundary.
Overrides:
writeTo in classMultipart
Following copied from class:javax.mail.Multipart
Throws:
java.io.IOException - if an IO related exception occurs
MessagingException -  

         


[8]ページ先頭

©2009-2025 Movatter.jp