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.
-
szERROR_BAD_EXTERNAL_MESSAGE_PART
-
-
szERROR_BAD_MIME_MESSAGE
-
-
szERROR_BAD_PARAMETER
-
-
szERROR_EMPTY_MESSAGE
-
-
szERROR_OUT_OF_MEMORY
-
-
szERROR_UNSUPPORTED_PARTIAL_SUBTYPE
-
-
szINVALID_CODE
-
-
MIMEHelper()
-
-
decodeBase64(InputStream, OutputStream)
-
Base64 Decodes data from InputStream and writes to OutputStream
-
decodeHeader(String)
- Decodes a string encoded in RFC2047 format.
-
decodeQP(InputStream, OutputStream)
- QuotedPrintable Decodes data from InputStream and writes to OutputStream
-
encodeBase64(InputStream, OutputStream)
- Base64 Encodes data from InputStream and writes to OutputStream.
-
encodeHeader(String, String, String)
- Encodes a string that typically goes in a header but uses characters other than ASCII
per RFC2047.
-
encodeQP(InputStream, OutputStream)
- QuotedPrintable Encodes data from InputStream and writes to OutputStream.
-
generateBoundary()
- Generates and returns a boundary string that can be used in multi-parts.
-
getFileMIMEType(String)
- Based on file extension, attempts to determine the file MIME content-type
sub-type, params and extension.
-
unicodeToASCII(String)
- Converts the input unicode ASCII printable chars to ASCII bytes.
szERROR_BAD_PARAMETER
public static final String szERROR_BAD_PARAMETER
szERROR_OUT_OF_MEMORY
public static final String szERROR_OUT_OF_MEMORY
szERROR_EMPTY_MESSAGE
public static final String szERROR_EMPTY_MESSAGE
szERROR_BAD_MIME_MESSAGE
public static final String szERROR_BAD_MIME_MESSAGE
szERROR_BAD_EXTERNAL_MESSAGE_PART
public static final String szERROR_BAD_EXTERNAL_MESSAGE_PART
szERROR_UNSUPPORTED_PARTIAL_SUBTYPE
public static final String szERROR_UNSUPPORTED_PARTIAL_SUBTYPE
szINVALID_CODE
public static final String szINVALID_CODE
MIMEHelper
public MIMEHelper()
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.
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.
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.
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.
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.
generateBoundary
public static String generateBoundary()
- Generates and returns a boundary string that can be used in multi-parts.
- Returns:
- The boundary string.
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.
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.
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