All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class netscape.messaging.mime.MIMEMessage

java.lang.Object
   |
   +----netscape.messaging.mime.MIMEMessage

public class MIMEMessage
extends Object
implements Cloneable
The MIMEMessage class represents the MIME message. A MIME Message is made up of a set of headers and message content. The message content itself comprises one of the MIMEBody types: MIMEBasicPart, MIMEMultiPart, and MIMEMessagePart.


Variable Index

 o BASICPART
BodyPart is a MIMEBasicPart object.
 o MESSAGEPART
BodyPart is a MIMEMessagePart object.
 o MULTIPART
BodyPart is a MIMEMultiPart object.

Constructor Index

 o MIMEMessage()
Default constructor for the MIMEMessage class.
 o MIMEMessage(Header[])
Constructs a MIMEMessage object given a set of RFC822 headers.
 o MIMEMessage(InputStream, String, int)
Constructs a (multi-part) MIMEMessage with given text and file.

Method Index

 o addHeader(String, String)
Appends the value to an existing RFC822 header.
 o clone()
Clones an instance of this MIMEMessage object.
 o deleteBody()
Deletes the body of the Message.
 o deleteHeader(String)
Deletes the requested header.
 o getAllHeaders()
Returns all the RFC-822 headers in the Message as an array of Header objects.
 o getBody(boolean)
Returns an Object of corresponding MIMEBodyPart type that is the body of this Message.
 o getBodyType()
Returns the type of the body of the Message.
 o getContentSubType()
Returns the content subtype of the Message.
 o getContentType()
Returns the content-type of the Message.
 o getContentTypeParams()
Returns the content-type params of the Message.
 o getHeader(String)
Returns the value of the requested header.
 o putByteStream(OutputStream)
Outputs a byte stream for this Message in MIME format with transfer encoding applied to all bodyParts as applicable.
 o putByteStream(String)
Outputs a byte-stream for this Message in MIME format with transfer encoding applied to all bodyParts as applicable.
 o setBody(MIMEBodyPart, boolean)
Sets the MIMEBodyPart as Body of this Message.
 o setHeader(String, String)
Sets any RFC-822 headers including X-headers.

Variables

 o BASICPART
 public static final int BASICPART
BodyPart is a MIMEBasicPart object.

 o MULTIPART
 public static final int MULTIPART
BodyPart is a MIMEMultiPart object.

 o MESSAGEPART
 public static final int MESSAGEPART
BodyPart is a MIMEMessagePart object.

Constructors

 o MIMEMessage
 public MIMEMessage()
Default constructor for the MIMEMessage class.

 o MIMEMessage
 public MIMEMessage(Header headers[]) throws MIMEException
Constructs a MIMEMessage object given a set of RFC822 headers.

Parameters:
headers - List of rfc822 headers to set in the message.
Throws: MIMEException
If the headers are malformed.
 o MIMEMessage
 public MIMEMessage(InputStream textIS,
                    String filename,
                    int encoding) throws MIMEException, FileNotFoundException, SecurityException, IOException
Constructs a (multi-part) MIMEMessage with given text and file. If filename parameter is null, builds a text message with textIS. Encoding will be E7BIT. If textIS parameter is null, builds a message with only the filename file as an attachment. If both textIS and filename parameters are null, an exception is thrown.

Parameters:
textIS - InputStream to text that becomes text part of the message. Can be null.
filename - Full name of file that becomes a part of the message. Can be null.
encoding - Encoding for the file attachment. To pick default value, pass -1.
Throws: MIMEException
If both textIS and filename are null or encoding is invalid
Throws: FileNotFoundException
If filename file does not exist
Throws: SecurityException
If filename file can not be accessed
Throws: IOExcepton
On IO Errors on filename or textIS.
See Also:
BASE64, QP, BINARY, E7BIT, E8BIT

Methods

 o setHeader
 public void setHeader(String name,
                       String value) throws MIMEException
Sets any RFC-822 headers including X-headers. Overwrites the existing value if header exists already.

Parameters:
name - Name of the header field.
value - Value of the header field to be added.
Throws: MIMEException
If either name or value are NULL
See Also:
encodeHeader
 o addHeader
 public void addHeader(String name,
                       String value) throws MIMEException
Appends the value to an existing RFC822 header. Creates new header if one does not exist already.

Parameters:
name - Name of the header field.
value - Value of the header field to be added.
Throws: MIMEException
If either name or value are NULL
See Also:
encodeHeader
 o getHeader
 public String getHeader(String name) throws MIMEException
Returns the value of the requested header. NULL if the header is not present.

Parameters:
name - Name of the header field.
Throws: MIMEException
If name is NULL
See Also:
decodeHeader
 o deleteHeader
 public void deleteHeader(String name) throws MIMEException
Deletes the requested header. Ignores if the header specified does not exist.

Parameters:
name - Name of the header field to delete.
Throws: MIMEException
if name is null
 o getAllHeaders
 public Header[] getAllHeaders() throws MIMEException
Returns all the RFC-822 headers in the Message as an array of Header objects. Content-Type is not returned by this Method, as separate methods to get Content primary type, sub-type and parameters exist.

Throws: MIMEException
If no headers exist.
See Also:
decodeHeader, getContentType, getContentSubType, getContentTypeParams
 o getBodyType
 public int getBodyType() throws MIMEException
Returns the type of the body of the Message.

Throws: MIMEException
If no Body exists for the message.
See Also:
BASICPART, MULTIPART, MESSAGEPART
 o getContentType
 public String getContentType() throws MIMEException
Returns the content-type of the Message. The content-type returned is the MIME content-type.

Throws: MIMEException
If no Body exists.
 o getContentSubType
 public String getContentSubType() throws MIMEException
Returns the content subtype of the Message. NULL if none exists.

Throws: MIMEException
If no Body exists.
 o getContentTypeParams
 public String getContentTypeParams() throws MIMEException
Returns the content-type params of the Message. NULL if none exist.

Throws: MIMEException
If no Body exists.
 o getBody
 public Object getBody(boolean clone) throws MIMEException
Returns an Object of corresponding MIMEBodyPart type that is the body of this Message.

Parameters:
clone - Whether to return a reference to the internal object or a cloned copy; if true: cloned copy; if false: reference to the object.
Throws: MIMEException
If no Body exists.
See Also:
MIMEBasicPart, MIMEMultiPart, MIMEMessagePart
 o deleteBody
 public void deleteBody()
Deletes the body of the Message. Has no effect if no body is present.

 o setBody
 public void setBody(MIMEBodyPart part,
                     boolean clone) throws MIMEException
Sets the MIMEBodyPart as Body of this Message. This part must already be constructed and fully set-up. Sets the content-type of the message based on the type of the part being added. This MIMEBodyPart must be an object of one of the three concrete classes: MIMEBasicPart, MIMEMultiPart and MIMEMessagePart.

Parameters:
part - BodyPart to add.
clone - Whether to store a reference to the object or a cloned copy; if true: clones a copy; if false: stores a reference to the object.
Throws: MIMEException
If body is already set, or if part is null, or if part is not an object of one of the three concrete classes: MIMEBasicPart, MIMEMultiPart, or MIMEMessagePart.
See Also:
MIMEBasicPart, MIMEMultiPart, MIMEMessagePart
 o putByteStream
 public void putByteStream(String fullfilename) throws IOException, MIMEException
Outputs a byte-stream for this Message in MIME format with transfer encoding applied to all bodyParts as applicable.

Parameters:
fullfilename - Filename, including full path to write the byte-stream to.
Throws: IOException
If an IO error occurs.
Throws: MIMEException
If any required fields in the bodyPart are not set-up.
 o putByteStream
 public void putByteStream(OutputStream os) throws IOException, MIMEException
Outputs a byte stream for this Message in MIME format with transfer encoding applied to all bodyParts as applicable.

Parameters:
os - OutputStream to write to.
Throws: IOException
If an IO error occurs.
Throws: MIMEException
If detects an error during encoding.
 o clone
 public Object clone() throws CloneNotSupportedException
Clones an instance of this MIMEMessage object.

Throws: CloneNotSupportedException
If thrown by constituent components.
Overrides:
clone in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index