cryptix.util.mime
Class TransferEncoding

java.lang.Object
  extended bycryptix.util.mime.TransferEncoding
Direct Known Subclasses:
QuotedPrintable

public abstract class TransferEncoding
extends java.lang.Object

This abstract class provides an API for encoding and decoding data according to a MIME Content-Transfer-Encoding.

Note: The input to the encoding is always a sequence of bytes. Strictly speaking the output is a sequence of characters, but since for all MIME transfer encodings, these characters are from a subset of both the Unicode and ASCII character repertoires, it is possible to represent the output either as a String or as a byte array.

References:

  1. RFC 2045, Multipurpose Internet Mail Extensions (MIME) Part One, Format of Internet Message Bodies, http://www.imc.org/rfc2045

Copyright © 1995-1997 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.1.1.1 $

Since:
Cryptix 3.0.2
Author:
Jill Baker, David Hopwood

Constructor Summary
TransferEncoding()
           
 
Method Summary
 byte[] decode(byte[] data)
          Decodes a byte array containing encoded ASCII.
abstract  byte[] decode(java.lang.String msg)
          Decodes a encoded String.
abstract  java.lang.String encode(byte[] data)
          Encodes data as a String using this Content-Transfer-Encoding.
 byte[] encodeAsByteArray(byte[] data)
          Encodes data as a byte array using this Content-Transfer-Encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransferEncoding

public TransferEncoding()
Method Detail

encode

public abstract java.lang.String encode(byte[] data)
Encodes data as a String using this Content-Transfer-Encoding. Line breaks in the output are represented as CR LF.

Returns:
the encoded string.

encodeAsByteArray

public byte[] encodeAsByteArray(byte[] data)
Encodes data as a byte array using this Content-Transfer-Encoding. Each character of the output is mapped to its ASCII code point. Line breaks in the output are represented as CR LF (codes 13 and 10).

Returns:
the encoded byte array.

decode

public byte[] decode(byte[] data)
              throws MIMEFormatException
Decodes a byte array containing encoded ASCII. Characters with ASCII code points <= 32 (this includes whitespace and newlines) are ignored.

Returns:
the decoded data.
Throws:
MIMEFormatException - if data contains invalid characters, i.e. not codes 0-32 and the other codes allowed for this encoding, or is otherwise formatted incorrectly.

decode

public abstract byte[] decode(java.lang.String msg)
                       throws MIMEFormatException
Decodes a encoded String. Characters with ASCII code points <= 32 (this includes whitespace and newlines) are ignored.

Returns:
the decoded data.
Throws:
MIMEFormatException - if data contains invalid characters, i.e. not codes 0-32 and the other codes allowed for this encoding, or is otherwise formatted incorrectly.