All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class netscape.messaging.mime.MIMEBasicPart

java.lang.Object
   |
   +----netscape.messaging.mime.MIMEBodyPart
           |
           +----netscape.messaging.mime.MIMEBasicPart

public class MIMEBasicPart
extends MIMEBodyPart
implements Cloneable
The MIMEBasicPart class is a common class used for all Basic MIME BodyPart types: Text, Image, Audio, Video, and Application. It does not represent structured parts such as MIMEMessagePart and MIMEMultiPart.


Variable Index

 o APPLICATION
Content (primary) type Application.
 o AUDIO
Content (primary) type Audio.
 o IMAGE
Content (primary) type Image.
 o TEXT
Content (primary) type Text.
 o UNINITIALIZED
 o VIDEO
Content (primary) type Video.

Constructor Index

 o MIMEBasicPart()
Default constructor.
 o MIMEBasicPart(int)
Constructs a MIMEBasicPart object with the given content-type.

Method Index

 o addHeader(String, String)
Appends the value to an existing header.
 o clone()
Clones an instance of this MIMEBasicPart object.
 o deleteBodyData()
Deletes BodyData of this MIME Part.
 o deleteHeader(String)
Deletes the requested header from this Part.
 o getAllHeaders()
Returns all the headers in this Part as an array of Header objects.
 o getBodyData()
Returns an InputStream to this Part's Data after decoding any transfer encoding.
 o getContentEncoding()
Returns value of Content-Transfer-Encoding of this MIME Part.
 o getContentMD5()
Returns Content-MD5 of this MIME Part or NULL if Content-MD5 is not present.
 o getContentType()
Returns Content-Type of this MIME Part.
 o getHeader(String)
Returns the value of the requested header.
 o getMessageDataLen()
 o getSize()
Returns the size of this Part's BodyData.
 o putByteStream(OutputStream)
Outputs a byte-stream for this part with its MIME part headers and encoded body data.
 o putByteStream(String)
Outputs a byte-stream for this part with its MIME part headers and encoded body data.
 o setBodyData(byte[])
Sets BodyData of this MIME Part.
 o setBodyData(InputStream)
Sets BodyData of this MIME Part.
 o setBodyData(String)
Sets BodyData of this MIME Part.
 o setContentEncoding(int)
Sets Content-Transfer-Encoding of this MIME Part.
 o setContentMD5(String)
Sets Content-MD5 of this MIME Part.
 o setHeader(String, String)
Sets a header of this body-part given name and value.

Variables

 o TEXT
 public static final int TEXT
Content (primary) type Text.

 o AUDIO
 public static final int AUDIO
Content (primary) type Audio.

 o IMAGE
 public static final int IMAGE
Content (primary) type Image.

 o VIDEO
 public static final int VIDEO
Content (primary) type Video.

 o APPLICATION
 public static final int APPLICATION
Content (primary) type Application.

 o UNINITIALIZED
 public static final int UNINITIALIZED

Constructors

 o MIMEBasicPart
 public MIMEBasicPart(int contentType) throws MIMEException
Constructs a MIMEBasicPart object with the given content-type.

Parameters:
contentType - Content type. Values: TEXT, AUDIO, IMAGE, VIDEO, APPLICATION.
Throws: MIMEException
If ContentType passed is invalid.
See Also:
TEXT, AUDIO, IMAGE, VIDEO, APPLICATION
 o MIMEBasicPart
 public MIMEBasicPart() throws MIMEException
Default constructor. Constructs a MIMEBasicPart object with MIMEBasicPart#TEXT content-type.

Methods

 o getContentType
 public String getContentType()
Returns Content-Type of this MIME Part.

Overrides:
getContentType in class MIMEBodyPart
See Also:
getContentType
 o getContentMD5
 public String getContentMD5()
Returns Content-MD5 of this MIME Part or NULL if Content-MD5 is not present.

See Also:
setContentMD5
 o setContentMD5
 public void setContentMD5(String md5)
Sets Content-MD5 of this MIME Part.

Parameters:
cid - String to use as Content-ID.
See Also:
getContentMD5
 o getBodyData
 public InputStream getBodyData() throws IOException, MIMEException
Returns an InputStream to this Part's Data after decoding any transfer encoding.

Throws: IOException
If an IO error occurs.
Throws: MIMEException
If the BodyData is not present. or an error is detected during decoding.
See Also:
setBodyData
 o setBodyData
 public void setBodyData(InputStream is) throws MIMEException, IOException
Sets BodyData of this MIME Part.

Parameters:
is - Stream to read input data from. This data must be un-encoded raw data.
Throws: MIMEException
If already set (or) if is parameter is null.
Throws: IOException
If an IO error occurs.
See Also:
getDataBuf
 o setBodyData
 public void setBodyData(String s) throws MIMEException
Sets BodyData of this MIME Part.

Parameters:
s - Source string for input data. Must be un-encoded raw data.
Throws: MIMEException
If already set or if is parameter is null.
 o setBodyData
 public void setBodyData(byte s[]) throws MIMEException
Sets BodyData of this MIME Part. Saves a reference to the passed byte buffer. Does not copy the data.

Parameters:
s - un-encoded raw data.
Throws: MIMEException
If already set or if s parameter is null.
 o deleteBodyData
 public void deleteBodyData()
Deletes BodyData of this MIME Part. If no BodyData is present, this method has no effect.

 o putByteStream
 public void putByteStream(String fullfilename) throws IOException, MIMEException
Outputs a byte-stream for this part with its MIME part headers and encoded body data.

Parameters:
fullfilename - Filename including full path of where to write the byte-stream.
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 part with its MIME part headers and encoded body data.

Parameters:
os - OutputStream to write to.
Throws: IOException
If an IO error occurs.
Throws: MIMEException
If any required fields in the bodyPart are not set-up.
 o getSize
 public int getSize()
Returns the size of this Part's BodyData.

Returns:
Size of BodyData or -1 if this part does not have bodyData.
 o setContentEncoding
 public void setContentEncoding(int encoding) throws MIMEException
Sets Content-Transfer-Encoding of this MIME Part.

Parameters:
encoding - Value that represents the encoding.
Throws: MIMEException
If encoding is invalid.
See Also:
BASE64, QP, BINARY, E7BIT, E8BIT
 o getContentEncoding
 public int getContentEncoding()
Returns value of Content-Transfer-Encoding of this MIME Part. -1 if none present.

See Also:
BASE64, QP, BINARY, E7BIT, E8BIT
 o setHeader
 public void setHeader(String name,
                       String value) throws MIMEException
Sets a header of this body-part given name and value. To be used to set any header that is not explicitly supported with a set method, such as X-headers. Multiple invocations on the same header replace the old value.

Parameters:
name - Name of the header field. Should not include ':'
value - Value of the header field to be added.
Throws: MIMEException
If either of name or value is NULL.
 o addHeader
 public void addHeader(String name,
                       String value) throws MIMEException
Appends the value to an existing 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
 o getHeader
 public String getHeader(String name) throws MIMEException
Returns the value of the requested header. Returns NULL if the header is not present.

Parameters:
name - Name of the header field.
Throws: MIMEException
If name passed is a NULL.
 o deleteHeader
 public void deleteHeader(String name) throws MIMEException
Deletes the requested header from this Part.

Parameters:
name - Name of the header field.
Throws: MIMEException
if name is NULL.
 o getAllHeaders
 public Header[] getAllHeaders() throws MIMEException
Returns all the headers in this Part as an array of Header objects.

Throws: MIMEException
If no headers exist.
 o clone
 public Object clone() throws CloneNotSupportedException
Clones an instance of this MIMEBasicPart object.

Throws: CloneNotSupportedException
If thrown by constituent components.
Overrides:
clone in class MIMEBodyPart
 o getMessageDataLen
 public int getMessageDataLen()

All Packages  Class Hierarchy  This Package  Previous  Next  Index