com.sun.xml.messaging.saaj.packaging.mime.internet
Class BMMimeMultipart

java.lang.Object
  extended by com.sun.xml.messaging.saaj.packaging.mime.internet.MimeMultipart
      extended by com.sun.xml.messaging.saaj.packaging.mime.internet.BMMimeMultipart

public class BMMimeMultipart
extends MimeMultipart

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's getContent() 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 the MimeMultipart(String subtype) constructor. For example, to create a "multipart/alternative" object, use new MimeMultipart("alternative").


Field Summary
 
Fields inherited from class com.sun.xml.messaging.saaj.packaging.mime.internet.MimeMultipart
contentType, ds, parent, parsed, parts
 
Constructor Summary
BMMimeMultipart()
          Default constructor.
BMMimeMultipart(javax.activation.DataSource ds, ContentType ct)
          Constructs a MimeMultipart object and its bodyparts from the given DataSource.
BMMimeMultipart(java.lang.String subtype)
          Construct a MimeMultipart object of the given subtype.
 
Method Summary
 boolean find(java.io.InputStream is, byte[] pattern, long[] posVector, ByteOutputStream out, SharedInputStream sin)
           
 boolean find(java.io.InputStream is, byte[] pattern, SharedInputStream sin)
           
 java.lang.String getBoundary()
           
 java.io.InputStream getInputStream()
           
 MimeBodyPart getNextPart(java.io.InputStream stream, byte[] pattern, SharedInputStream sin)
           
 java.io.InputStream initStream()
           
 boolean isEndOfStream()
           
 boolean lastBodyPartFound()
           
protected  void parse()
          Parse the InputStream from our DataSource, constructing the appropriate MimeBodyParts.
 boolean parse(java.io.InputStream stream, byte[] pattern, SharedInputStream sin)
           
 int readNext(java.io.InputStream is, byte[] buff, int patternLength, java.util.BitSet eof, long[] posVector, SharedInputStream sin)
           
 void setBoundary(java.lang.String bnd)
           
 void setInputStream(java.io.InputStream is)
           
 void setLazyAttachments(boolean flag)
           
 void writeTo(java.io.OutputStream os)
          Iterates through all the parts and outputs each Mime part separated by a boundary.
 
Methods inherited from class com.sun.xml.messaging.saaj.packaging.mime.internet.MimeMultipart
addBodyPart, addBodyPart, createInternetHeaders, createMimeBodyPart, createMimeBodyPart, getBodyPart, getBodyPart, getContentType, getCount, removeBodyPart, removeBodyPart, setMultipartDataSource, setSubType, updateHeaders
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BMMimeMultipart

public BMMimeMultipart()
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 the contentType field.

MimeBodyParts may be added later.


BMMimeMultipart

public BMMimeMultipart(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 the contentType field.

MimeBodyParts may be added later.


BMMimeMultipart

public BMMimeMultipart(javax.activation.DataSource ds,
                       ContentType ct)
                throws MessagingException
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 parsed flag is set to false. When the data for the body parts are needed, 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
Throws:
MessagingException
Method Detail

initStream

public java.io.InputStream initStream()
                               throws MessagingException
Throws:
MessagingException

parse

protected void parse()
              throws MessagingException
Parse the InputStream from our DataSource, constructing the appropriate MimeBodyParts. The parsed flag is set to true, and if true on entry nothing is done. This method is called by all other methods that need data for the body parts, to make sure the data has been parsed.

Overrides:
parse in class MimeMultipart
Throws:
MessagingException
Since:
JavaMail 1.2

lastBodyPartFound

public boolean lastBodyPartFound()

getNextPart

public MimeBodyPart getNextPart(java.io.InputStream stream,
                                byte[] pattern,
                                SharedInputStream sin)
                         throws java.lang.Exception
Throws:
java.lang.Exception

parse

public boolean parse(java.io.InputStream stream,
                     byte[] pattern,
                     SharedInputStream sin)
              throws java.lang.Exception
Throws:
java.lang.Exception

readNext

public int readNext(java.io.InputStream is,
                    byte[] buff,
                    int patternLength,
                    java.util.BitSet eof,
                    long[] posVector,
                    SharedInputStream sin)
             throws java.lang.Exception
Throws:
java.lang.Exception

find

public boolean find(java.io.InputStream is,
                    byte[] pattern,
                    SharedInputStream sin)
             throws java.lang.Exception
Throws:
java.lang.Exception

find

public boolean find(java.io.InputStream is,
                    byte[] pattern,
                    long[] posVector,
                    ByteOutputStream out,
                    SharedInputStream sin)
             throws java.lang.Exception
Throws:
java.lang.Exception

writeTo

public void writeTo(java.io.OutputStream os)
             throws java.io.IOException,
                    MessagingException
Description copied from class: MimeMultipart
Iterates through all the parts and outputs each Mime part separated by a boundary.

Overrides:
writeTo in class MimeMultipart
Throws:
java.io.IOException
MessagingException

setInputStream

public void setInputStream(java.io.InputStream is)

getInputStream

public java.io.InputStream getInputStream()

setBoundary

public void setBoundary(java.lang.String bnd)

getBoundary

public java.lang.String getBoundary()

isEndOfStream

public boolean isEndOfStream()

setLazyAttachments

public void setLazyAttachments(boolean flag)