Oracle® Globalization Development Kit Java API Reference
10g Release 1(10.1)

B10971-01

oracle.i18n.net
Class MimeUtility

java.lang.Object
  |
  +--oracle.i18n.net.MimeUtility

public class MimeUtility
extends Object

MimeUtility is the MIME utility class that contains encoder and decoder for MIME header and body text. This is an alternative of javax.mail.internet.MimeUtility but this allows you to use Oracle or IANA character set names.

RFC 2047 specifies the MIME-safe header and body format. The mail header must be in the following US-ASCII character set encoding:

=? <charset> ? <encoding> ? <encoded-text> ?=

This output can be generated using encodeHeader(String, String, String) method. The receiver of the data is able to decode it based on the included character set (e.g., iso-8859-1) and encoding ("B" or "Q") information using decodeHeader(String).

Meanwhile, based on RFC 2045, MIME body will not include the character set and encoding information that is generated by #encodeBody(String, String, String) method. Hence, those information must be provided to the receiver by higher level of protocol when it uses #decodeBody(String, String, String).

Since:
10.1.1
See Also:
RFC 2045, RFC 2047

Method Summary
static String decodeHeader(String srcstr)
          Decodes a MIME-safe form into a String for MIME header as per RFC 2047.
static String encodeHeader(String srcstr, String charset, String encoding)
          Encodes a String into a MIME-safe form for MIME header as per RFC 2047.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodeHeader

public static String encodeHeader(String srcstr,
                                  String charset,
                                  String encoding)
                           throws UnsupportedEncodingException
Encodes a String into a MIME-safe form for MIME header as per RFC 2047.

Currently AL16UTF16(aka. UTF-16BE) is not supported.

The output includes the character set and encoding (e.g., Base64 or Quoted-Printable) information in the following form:

=? <charset> ? <encoding> ? <encoded-text> ?=

Parameters:
srcstr - a String to be encoded.
charset - an Oracle or IANA character set name.
encoding - base64 ("B") or quoted-printable ("Q")
Returns:
an encoded String
Throws:
UnsupportedEncodingException - if the character set name is invalid or not supported.

decodeHeader

public static String decodeHeader(String srcstr)
                           throws UnsupportedEncodingException
Decodes a MIME-safe form into a String for MIME header as per RFC 2047.

The input is expected to include the character set and encoding (e.g., Base64 or Quoted-Printable) information in the following form:

=? <charset> ? <encoding> ? <encoded-text> ?=

Parameters:
srcstr - a String to be decoded.
Returns:
a decoded String
Throws:
UnsupportedEncodingException - - if the character set name is invalid or not supported
IllegalArgumentException - if invalid MIME header is detected.

Oracle® Globalization Development Kit Java API Reference
10g Release 1(10.1)

B10971-01

Copyright © 2003 Oracle Corporation. All Rights Reserved.