SilverStream
Application Server 3.5

com.sssw.srv.mail
Class AgoMIMEPartMultipart

java.lang.Object
 |
 +--com.sssw.srv.mail.AgoMIMEPart
       |
       +--com.sssw.srv.mail.AgoMIMEPartMultipart

public class AgoMIMEPartMultipart
extends AgoMIMEPart

Class that stores MIME parts of type multipart. When a message consists of multiple parts (e.g., text, a file attachment, and an image), it is represented as a multipart MIME message. The AgoMIMEPartMultipart class is a subclass of AgoMIMEPart. For example multipart/mixed represents a message with multiple, independent parts. Another example is multipart/alternative which represents a message with multiple parts (each of which is considered an alternative representation of the same data, e.g., an html version and a plain text version).


Constructor Summary
AgoMIMEPartMultipart(String subtype)
          A constructor for the AgoMIMEPartMultipart class.
AgoMIMEPartMultipart(String subtype, AgoRFC822HeaderFieldSet headerfieldset)
          A constructor for the AgoMIMEPartMultipart class.
 
Method Summary
 void addPart(AgoMIMEPart part)
          Adds a MIME part to this multipart part.
 AgoMIMEHeaderField contentTypeHeaderField()
          Returns an AgoMIMEHeaderField for the content type of this multipart MIME part.
 String getBoundary()
          Returns the boundary used to separate parts of this multipart MIME part.
 Enumeration parts()
          Returns an Enumeration of all parts in this part.
 void removePart(AgoMIMEPart part)
          Removes the specified part from this part.
 void setBoundary(String boundary)
          Sets a boundary to be used by this part.
 void writeBoundary(OutputStream outputstream, boolean end)
          Writes a boundary to the specified outputstream.
 
Methods inherited from class com.sssw.srv.mail.AgoMIMEPart
contentDispositionHeaderField, contentTransferEncodingHeaderField, deleteHeaderField, getHeaderField, getHeaderFieldSet, getNameParameterOnContentType, setHeaderField, setHeaderField, setHeaderFieldSet, setNameParameterOnContentType, subtype, type, write, writeHeaderFields
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgoMIMEPartMultipart

public AgoMIMEPartMultipart(String subtype)
A constructor for the AgoMIMEPartMultipart class.
Parameters:
subtype - the subtype of this part (e.g. AgoMIME.SUBTYPE_HTML). For a list of supported subtypes see supported types and subtypes.
Example:

The following example adds two parts to this multipart/alternative MIME part. Each represents the same text but one supplies plain ASCII and the other the HTML version. A mail agent should show one or the other of these parts, preferably the "highest quality" one it is capable of. In such a case the MIME specification requires the "lowest quality" part first so that it will be top-most in the message and so a non-MIME mail reader will show it first to user.

In the first example we use the constants defined in AgoMIME to specify the subtype, character set and encoding and in the second example we use the strings that those constants represent.

     AgoMIMEPartMultipart part = new AgoMIMEPartMultipart(AgoMIME.SUBTYPE_ALTERNATIVE);
 
     AgoCharStoreDyna store1 = new AgoCharStortDyna();
     store1.append("Hello World!");
     AgoMIMEPartText text1 = new AgoMIMEPartText(AgoMIME.SUBTYPE_PLAIN,
                                                 null,
                                                 AgoMIME.CHARSET_US_ASCII,
                                                 AgoMIME.MECHANISM_7BIT,
                                                 store1);
     part.addPart(text1);
 
     AgoCharStoreDyna store2 = new AgoCharStortDyna();
     store2.append("Hello World!");
     AgoMIMEPartText text2 = new AgoMIMEPartText("html",
                                                 null,
                                                 "us-ascii",
                                                 "7bit",
                                                 store2);
     part.addPart(text2);
 

AgoMIMEPartMultipart

public AgoMIMEPartMultipart(String subtype,
                            AgoRFC822HeaderFieldSet headerfieldset)
A constructor for the AgoMIMEPartMultipart class.
Parameters:
subtype - the subtype of this part (e.g. AgoMIME.SUBTYPE_HTML). For a list of supported subtypes see supported types and subtypes.
headerfieldset - a set of headers for this part.
Example:
     AgoMIMEPartMultipart mPart = new AgoMIMEPartMultipart(subtypeString,
                                                           someAgoRFC822HeaderFieldset);
 
See Also:
AgoRFC822HeaderFieldSet
Method Detail

writeBoundary

public void writeBoundary(OutputStream outputstream,
                          boolean end)
                   throws IOException
Writes a boundary to the specified outputstream.
Parameters:
outputstream - specifies the output stream to write to.
end - specify true if writeBoundary() should include a trailing "--" for the final boundary of a part.
Usage:

The writeBoundary() method outputs an initial CRLF and "--" followed by the boundary set for this multipart part. If end is true, it includes a trailing "--" needed for the last part in a message. In all cases a trailing CRLF is output.

Example:
     part.writeBoundary(someOutputStream, true);
 
See Also:
AgoMIMEPartMultipart.getBoundary(), AgoMIMEPartMultipart.setBoundary( String boundary )

contentTypeHeaderField

public AgoMIMEHeaderField contentTypeHeaderField()
Returns an AgoMIMEHeaderField for the content type of this multipart MIME part.
Overrides:
contentTypeHeaderField in class AgoMIMEPart
Example:
     AgoMIMEHeaderField cType = part.contentTypeHeaderField();
 
See Also:
AgoMIMEHeaderField

addPart

public void addPart(AgoMIMEPart part)
Adds a MIME part to this multipart part.
Parameters:
part - the part to be added.
Example:

The following example adds two parts to this multipart MIME part. Each is a simple text/plain part created from a hard-coded String. In the first example we use the constants defined in AgoMIME to specify the subtype, character set and encoding and in the second example we use the strings that those constants represent.

     AgoCharStoreDyna store1 = new AgoCharStortDyna();
     store1.append("Hello ");
     AgoMIMEPartText text1 = new AgoMIMEPartText(AgoMIME.SUBTYPE_PLAIN,
                                                 null,
                                                 AgoMIME.CHARSET_US_ASCII,
                                                 AgoMIME.MECHANISM_7BIT,
                                                 store1);
     part.addPart(text1);
 
     AgoCharStoreDyna store2 = new AgoCharStortDyna();
     store2.append("World!");
     AgoMIMEPartText text2 = new AgoMIMEPartText("plain",
                                                 null,
                                                 "iso-8859-1",
                                                 "7bit",
                                                 store2);
     part.addPart(text2);
 
See Also:
AgoMIMEPart

removePart

public void removePart(AgoMIMEPart part)
Removes the specified part from this part.
Parameters:
part - the part to be removed.
Example:
     part.removePart(somePart);
 
See Also:
AgoMIMEPart, AgoMIMEPartMultipart.addPart( AgoMIMEPart part ), AgoMIMEPartMultipart.parts()

getBoundary

public String getBoundary()
Returns the boundary used to separate parts of this multipart MIME part.
Example:
     String boundary = part.getBoundary();
 
See Also:
AgoMIMEPartMultipart.setBoundary( String boundary ), AgoMIMEPartMultipart.writeBoundary( OutputStream outputstream, boolean end )

setBoundary

public void setBoundary(String boundary)
Sets a boundary to be used by this part.
Parameters:
boundary - specifies the boundary to set.
Usage:

If this method is not called, a randomly generated boundary will be used when needed. Boundaries must be unique strings not found in the bodies of any of the subparts of the message.

Example:
     String boundary = "SomeVeryUniqueStringNotInTheMessage";
     part.setBoundary(boundary);
 
See Also:
AgoBufferingInputStream.clearBoundary(), AgoBufferingInputStream.clearMark(), AgoBufferingInputStream.setMark()

parts

public Enumeration parts()
Returns an Enumeration of all parts in this part. The elements are of type AgoMIMEPart.
Example:
     Enumeration parts = part.parts();
 
See Also:
AgoMIMEPartMultipart.removePart( AgoMIMEPart part), AgoMIMEPartMultipart.addPart( AgoMIMEPart part ), AgoMIMEPart

SilverStream
Application Server 3.5