Class netscape.messaging.mime.MIMEMultiPart
All Packages Class Hierarchy This Package Previous Next Index
Class netscape.messaging.mime.MIMEMultiPart
java.lang.Object
|
+----netscape.messaging.mime.MIMEBodyPart
|
+----netscape.messaging.mime.MIMEMultiPart
-
public class MIMEMultiPart
-
extends MIMEBodyPart
-
implements Cloneable
The MIMEMultiPart class implements the MIME multipart Content Type.
The multipart content type represents messages with multiple attachments
of potentially different media. This content type describes a message that
is made up of one or more sub-body parts. The Multipart type has several
subtypes that describe how the sub-parts relate to each other. These include
mixed, alternative, digest, and parallel.
-
MIMEMultiPart()
-
Constructs a MIMEMultiPart object.
-
MIMEMultiPart(InputStream,
String, int)
-
Constructs a MIMEMultiPart object with the specified text and filename.
-
addBodyPart(MIMEBodyPart,
boolean)
-
Adds a MIMEBodyPart to this MultiPart.
-
addBodyPart(String,
int)
-
Adds the specified filename file as a (MIMEBasicPart) BodyPart to this
MultiPart.
-
clone()
-
Clones an instance of this MIMEMultiPart object.
-
deleteBodyPart(int)
-
Deletes bodyPart at the requested index from this Multipart.
-
getBodyPart(int,
boolean)
-
Returns an Object of corresponding MIME BodyPart type at the specified
index of this MultiPart.
-
getBodyPartCount()
-
Returns the count of BodyParts in this MultiPart or Zero (0) if no parts
exist.
-
getContentType()
-
Returns Content-Type of this MIME Part.
-
getPreamble()
-
Returns the preamble for this multipart if present.
-
putByteStream(OutputStream)
-
Outputs a byte stream for this Message in MIME format.
-
setPreamble(String)
-
Sets the preamble for this multipart.
MIMEMultiPart
public MIMEMultiPart()
-
Constructs a MIMEMultiPart object. Default constructor for the MIMEMultiPart
MIMEMultiPart
public MIMEMultiPart(InputStream textIS,
String filename,
int encoding) throws MIMEException, FileNotFoundException, SecurityException, IOException
-
Constructs a MIMEMultiPart object with the specified text and filename.
Both textIS and filename cannot be null or an exception is thrown. (See
MIMEMessage() if you need to do this.)
-
Parameters:
-
textIS - InputStream to text that becomes (first) text part of the multipart.
-
filename - Name of the file that becomes second part of the multipart.
-
encoding - Encoding for the file attachment. To select a default encoding,
use -1.
-
Throws: MIMEException
-
If filename is null or textIS null.
-
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:
-
MIMEMessage, BASE64,
QP, BINARY,
E7BIT, E8BIT
getContentType
public String getContentType()
-
Returns Content-Type of this MIME Part. Always returns the String "MultiPart".
-
Overrides:
-
getContentType
in class MIMEBodyPart
getBodyPartCount
public int getBodyPartCount()
-
Returns the count of BodyParts in this MultiPart or Zero (0) if no parts
exist.
getBodyPart
public Object getBodyPart(int index,
boolean clone) throws MIMEException
-
Returns an Object of corresponding MIME BodyPart type at the specified
index of this MultiPart.
-
Parameters:
-
index - Index for the BodyPart to return. Index ranges from 0 to (count_of_parts
-1).
-
clone - Whether to return a reference to the internal BodyPart object or
a cloned copy; if true: cloned copy; if false: reference to the BodyPart
object.
-
Throws: MIMEException
-
If invalid index.
-
See Also:
-
MIMEBasicPart,
MIMEMessagePart,
MIMEMultiPart, getBodyPartCount
putByteStream
public void putByteStream(OutputStream os) throws IOException, MIMEException
-
Outputs a byte stream for this Message in MIME format. Applies transfer
encoding all bodyParts as applicable.
-
Parameters:
-
os - OutputStream to be written to.
-
Throws: IOException
-
If an IO error occurs.
-
Throws: MIMEException
-
If detects an error during encoding.
deleteBodyPart
public void deleteBodyPart(int index) throws MIMEException
-
Deletes bodyPart at the requested index from this Multipart. Adjusts indices
of any parts after the deleted part upwards as needed.
-
Parameters:
-
index - of the bodyPart to remove.
-
Throws: MIMEException
-
if invalid index.
addBodyPart
public int addBodyPart(String filename,
int encoding) throws MIMEException, FileNotFoundException, SecurityException, IOException
-
Adds the specified filename file as a (MIMEBasicPart) BodyPart to this
MultiPart.
-
Parameters:
-
filename - Name of file to add as bodyPart.
-
encoding - Preferred MIME encoding for this part. To select a default,
use -1.
-
Returns:
-
The index at which this bodyPart is added.
-
Throws: MIMEException
-
If filename file is inaccessible or I/O errors.
-
Throws: FileNotFoundException
-
If filename file does not exist
-
Throws: SecurityException
-
If filename file cannot be accessed
-
Throws: IOExcepton
-
On IO Errors on filename
-
See Also:
-
BASE64,
QP, BINARY,
E7BIT, E8BIT
addBodyPart
public int addBodyPart(MIMEBodyPart part,
boolean clone) throws MIMEException
-
Adds a MIMEBodyPart to this MultiPart. This part must already be constructed
and fully set-up. As MIMEBodyPart is an abstract class, the object passed
in the part parameter must be one of three concrete classes: MIMEBasicPart,
MIMEMultiPart, or MIMEMessagePart. If not, a MIMEException is thrown.
-
Parameters:
-
part - bodyPart to add.
-
clone - Whether to store a reference to the passed object instead of cloning
a copy; if true: clones a copy; if false: stores reference to the passed
part object.
-
Returns:
-
The index at which to add this bodyPart.
-
Throws: MIMEException
-
If part is malformed or is not an object of one of three classes: MIMEBasicPart,
MIMEMultiPart, or MIMEMessagePart.
-
See Also:
-
MIMEBasicPart,
MIMEMultiPart, MIMEMessagePart
getPreamble
public String getPreamble()
-
Returns the preamble for this multipart if present. Returns null if preamble
does not exist for this part.
-
Returns:
-
Preamble for the multipart if present, null otherwise.
setPreamble
public void setPreamble(String preamble)
-
Sets the preamble for this multipart.
-
Parameters:
-
preamble - Preamble string.
clone
public Object clone() throws CloneNotSupportedException
-
Clones an instance of this MIMEMultiPart object.
-
Throws: CloneNotSupportedException
-
If thrown by constituent components.
-
Overrides:
-
clone in
class MIMEBodyPart
All Packages Class Hierarchy This Package Previous Next Index