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.
-
BASICPART
- BodyPart is a MIMEBasicPart object.
-
MESSAGEPART
- BodyPart is a MIMEMessagePart object.
-
MULTIPART
- BodyPart is a MIMEMultiPart object.
-
MIMEMessage()
- Default constructor for the MIMEMessage class.
-
MIMEMessage(Header[])
- Constructs a MIMEMessage object given a set of RFC822 headers.
-
MIMEMessage(InputStream, String, int)
- Constructs a (multi-part) MIMEMessage with given text and file.
-
addHeader(String, String)
- Appends the value to an existing RFC822 header.
-
clone()
- Clones an instance of this MIMEMessage object.
-
deleteBody()
- Deletes the body of the Message.
-
deleteHeader(String)
- Deletes the requested header.
-
getAllHeaders()
- Returns all the RFC-822 headers in the Message as an array of Header objects.
-
getBody(boolean)
- Returns an Object of corresponding MIMEBodyPart type that is
the body of this Message.
-
getBodyType()
- Returns the type of the body of the Message.
-
getContentSubType()
- Returns the content subtype of the Message.
-
getContentType()
- Returns the content-type of the Message.
-
getContentTypeParams()
- Returns the content-type params of the Message.
-
getHeader(String)
- Returns the value of the requested header.
-
putByteStream(OutputStream)
- Outputs a byte stream for this Message in MIME format with transfer encoding
applied to all bodyParts as applicable.
-
putByteStream(String)
- Outputs a byte-stream for this Message in MIME format with transfer encoding
applied to all bodyParts as applicable.
-
setBody(MIMEBodyPart, boolean)
- Sets the MIMEBodyPart as Body of this Message.
-
setHeader(String, String)
- Sets any RFC-822 headers including X-headers.
BASICPART
public static final int BASICPART
- BodyPart is a MIMEBasicPart object.
MULTIPART
public static final int MULTIPART
- BodyPart is a MIMEMultiPart object.
MESSAGEPART
public static final int MESSAGEPART
- BodyPart is a MIMEMessagePart object.
MIMEMessage
public MIMEMessage()
- Default constructor for the MIMEMessage class.
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.
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
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
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
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
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
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
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
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.
getContentSubType
public String getContentSubType() throws MIMEException
- Returns the content subtype of the Message. NULL if none exists.
- Throws: MIMEException
- If no Body exists.
getContentTypeParams
public String getContentTypeParams() throws MIMEException
- Returns the content-type params of the Message. NULL if none exist.
- Throws: MIMEException
- If no Body exists.
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
deleteBody
public void deleteBody()
- Deletes the body of the Message. Has no effect if no body is present.
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
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.
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.
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