public class

UCEncoder

extends CharacterEncoder
java.lang.Object
   ↳ sun.misc.CharacterEncoder
     ↳ sun.misc.UCEncoder

Class Overview

This class implements a robust character encoder. The encoder is designed to convert binary data into printable characters. The characters are assumed to exist but they are not assumed to be ASCII, the complete set is 0-9, A-Z, a-z, "(", and ")". The basic encoding unit is a 3 character atom. It encodes two bytes of data. Bytes are encoded into a 64 character set, the characters were chosen specifically because they appear in all codesets. We don't care what their numerical equivalent is because we use a character array to map them. This is like UUencoding with the dependency on ASCII removed. The three chars that make up an atom are encoded as follows:

      00xxxyyy 00axxxxx 00byyyyy
      00 = leading zeros, all values are 0 - 63
      xxxyyy - Top 3 bits of X, Top 3 bits of Y
      axxxxx - a = X parity bit, xxxxx lower 5 bits of X
      byyyyy - b = Y parity bit, yyyyy lower 5 bits of Y
 
The atoms are arranged into lines suitable for inclusion into an email message or text file. The number of bytes that are encoded per line is 48 which keeps the total line length under 80 chars) Each line has the form(
  *(LLSS)(DDDD)(DDDD)(DDDD)...(CRC)
  Where each (xxx) represents a three character atom.
  (LLSS) - 8 bit length (high byte), and sequence number
           modulo 256;
  (DDDD) - Data byte atoms, if length is odd, last data
           atom has (DD00) (high byte data, low byte 0)
  (CRC)  - 16 bit CRC for the line, includes length,
           sequence, and all data bytes. If there is a
           zero pad byte (odd length) it is _NOT_
           included in the CRC.
 

Summary

[Expand]
Inherited Fields
From class sun.misc.CharacterEncoder
Public Constructors
UCEncoder()
Protected Methods
int bytesPerAtom()
this clase encodes two bytes per atom
int bytesPerLine()
this class encodes 48 bytes per line
void encodeAtom(OutputStream outStream, byte[] data, int offset, int len)
encodeAtom - take two bytes and encode them into the correct three characters.
void encodeBufferPrefix(OutputStream a)
The buffer prefix code is used to initialize the sequence number to zero.
void encodeLinePrefix(OutputStream outStream, int length)
Each UCE encoded line starts with a prefix of '*[XXX]', where the sequence number and the length are encoded in the first atom.
void encodeLineSuffix(OutputStream outStream)
each UCE encoded line ends with YYY and encoded version of the 16 bit checksum.
[Expand]
Inherited Methods
From class sun.misc.CharacterEncoder
From class java.lang.Object

Public Constructors

public UCEncoder ()

Protected Methods

protected int bytesPerAtom ()

this clase encodes two bytes per atom

protected int bytesPerLine ()

this class encodes 48 bytes per line

protected void encodeAtom (OutputStream outStream, byte[] data, int offset, int len)

encodeAtom - take two bytes and encode them into the correct three characters. If only one byte is to be encoded, the other must be zero. The padding byte is not included in the CRC computation.

Throws
IOException

protected void encodeBufferPrefix (OutputStream a)

The buffer prefix code is used to initialize the sequence number to zero.

Throws
IOException

protected void encodeLinePrefix (OutputStream outStream, int length)

Each UCE encoded line starts with a prefix of '*[XXX]', where the sequence number and the length are encoded in the first atom.

Throws
IOException

protected void encodeLineSuffix (OutputStream outStream)

each UCE encoded line ends with YYY and encoded version of the 16 bit checksum. The most significant byte of the check sum is always encoded FIRST.

Throws
IOException