All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class netscape.messaging.mime.MIMEHelper

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

public class MIMEHelper
extends Object
The MIMEHelper class defines a set of utility functions.


Variable Index

 o szERROR_BAD_EXTERNAL_MESSAGE_PART
 o szERROR_BAD_MIME_MESSAGE
 o szERROR_BAD_PARAMETER
 o szERROR_EMPTY_MESSAGE
 o szERROR_OUT_OF_MEMORY
 o szERROR_UNSUPPORTED_PARTIAL_SUBTYPE
 o szINVALID_CODE

Constructor Index

 o MIMEHelper()

Method Index

 o decodeBase64(InputStream, OutputStream)
Base64 Decodes data from InputStream and writes to OutputStream
 o decodeHeader(String)
Decodes a string encoded in RFC2047 format.
 o decodeQP(InputStream, OutputStream)
QuotedPrintable Decodes data from InputStream and writes to OutputStream
 o encodeBase64(InputStream, OutputStream)
Base64 Encodes data from InputStream and writes to OutputStream.
 o encodeHeader(String, String, String)
Encodes a string that typically goes in a header but uses characters other than ASCII per RFC2047.
 o encodeQP(InputStream, OutputStream)
QuotedPrintable Encodes data from InputStream and writes to OutputStream.
 o generateBoundary()
Generates and returns a boundary string that can be used in multi-parts.
 o getFileMIMEType(String)
Based on file extension, attempts to determine the file MIME content-type sub-type, params and extension.
 o unicodeToASCII(String)
Converts the input unicode ASCII printable chars to ASCII bytes.

Variables

 o szERROR_BAD_PARAMETER
 public static final String szERROR_BAD_PARAMETER
 o szERROR_OUT_OF_MEMORY
 public static final String szERROR_OUT_OF_MEMORY
 o szERROR_EMPTY_MESSAGE
 public static final String szERROR_EMPTY_MESSAGE
 o szERROR_BAD_MIME_MESSAGE
 public static final String szERROR_BAD_MIME_MESSAGE
 o szERROR_BAD_EXTERNAL_MESSAGE_PART
 public static final String szERROR_BAD_EXTERNAL_MESSAGE_PART
 o szERROR_UNSUPPORTED_PARTIAL_SUBTYPE
 public static final String szERROR_UNSUPPORTED_PARTIAL_SUBTYPE
 o szINVALID_CODE
 public static final String szINVALID_CODE

Constructors

 o MIMEHelper
 public MIMEHelper()

Methods

 o encodeBase64
 public static long encodeBase64(InputStream input,
                                 OutputStream output) throws MIMEException, IOException
Base64 Encodes data from InputStream and writes to OutputStream.

Parameters:
input - InputStream that supplies the data to be encoded.
output - OutputStream that accepts the encoded data.
Returns:
Number of bytes written.
Throws: MIMEException
If an encoding error occurs.
Throws: IOException
If an I/O error occurs.
 o encodeQP
 public static long encodeQP(InputStream input,
                             OutputStream output) throws MIMEException, IOException
QuotedPrintable Encodes data from InputStream and writes to OutputStream.

Parameters:
input - InputStream that supplies the data to be encoded.
output - OutputStream that accepts the encoded data.
Returns:
Number of bytes written.
Throws: MIMEException
If an encoding error occurs.
Throws: IOException
If an I/O error occurs.
 o decodeQP
 public static void decodeQP(InputStream input,
                             OutputStream output) throws MIMEException
QuotedPrintable Decodes data from InputStream and writes to OutputStream

Parameters:
input - InputStream that supplies the data to be decoded.
output - OutputStream that accepts the decoded data.
Throws: MIMEException
if a decoding error occurs.
Throws: IOException
if io error occurs.
 o encodeHeader
 public static String encodeHeader(String inputString,
                                   String charsetName,
                                   String encoding_type) throws MIMEException, UnsupportedEncodingException
Encodes a string that typically goes in a header but uses characters other than ASCII per RFC2047. Can be used on unstructured rfc822 headers or comments of structured ones. The returned string can be passed to setHeader() method in MIMEMessage class.

Parameters:
inputString - The string to encode.
charsetName - Name of the charset the input string is in. If null uses iso-8859-1.
encoding_type - Must "B" or "Q".
Returns:
The encoded header string.
Throws: MIMEException
if an encoding error occurs.
 o decodeHeader
 public static String decodeHeader(String inputString) throws MIMEException
Decodes a string encoded in RFC2047 format. If the string is not encoded returns the original string. Can be used on the header value returned by getHeader() and getAllHeaders() methods in MIMEMessage class.

Parameters:
inputString - The string to decode.
Returns:
The decoded header string.
Throws: MIMEException
If an decoding error occurs.
 o generateBoundary
 public static String generateBoundary()
Generates and returns a boundary string that can be used in multi-parts.

Returns:
The boundary string.
 o unicodeToASCII
 public static byte[] unicodeToASCII(String inputString) throws UnsupportedEncodingException, MIMEException
Converts the input unicode ASCII printable chars to ASCII bytes.

Parameters:
inputString - The string to convert.
Throws: MIMEException
If the input contains non-printable ASCII or non-ASCII chars.
 o getFileMIMEType
 public static fileMIMEType getFileMIMEType(String filename)
Based on file extension, attempts to determine the file MIME content-type sub-type, params and extension. By default returns application/octet-stream.

Parameters:
filename - Filename in the form name.ext. If no extension returns application/octet-stream.
Returns:
Object of class fileMIMEType that has the MIME content-type* info set.
 o decodeBase64
 public static void decodeBase64(InputStream input,
                                 OutputStream output) throws MIMEException
Base64 Decodes data from InputStream and writes to OutputStream

Parameters:
input - InputStream that supplies the data to be decoded.
output - OutputStream that accepts the decoded data.
Throws: MIMEException
if a decoding error occurs. return number of decoded bytes

All Packages  Class Hierarchy  This Package  Previous  Next  Index