|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.harvard.deas.hyperenc.util.UUCoder
public class UUCoder
Encodes and decodes binary data into ASCII using a similar, but not identical, format to UUEncoding.
Bytes are translated into ASCII characters in the same way as UUEncoding:
groups of three 8-bit bytes are realigned into sets of four 6-bit groups.
Each 6-bit group is then converted to an ASCII character by adding 32, with
the exception of 00: a zero is represented by the backtick (`, ASCII 96).
Thus the valid characters, spanning from ASCII 33 to ASCII 96, are:
If the message to be encoded is not a multiple of 3 bytes, it is padded with zeros so that it is.!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`
Messages are not delineated as in standard UUEncoding. The first line of a
message is a decimal number indicating how many bytes are encoded by the
message. This is followed by the encoded data on as many lines as needed.
Unlike standard UUEncoding, the length of each line is not indicated in any
way. The only requirement is that each line contain a multiple of 4
characters, not including the trailing newline character(s). Finally, the
message ends with a line consisting of only the token "TERMEND
".
Field Summary | |
---|---|
static String |
TERMINATOR
Token that indicates the end of a message. |
Constructor Summary | |
---|---|
UUCoder()
|
Method Summary | |
---|---|
static byte[] |
decode(String data)
Decodes the given string. |
static String |
encode(byte[] data)
Encodes the given data. |
static String |
getLegalChars()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String TERMINATOR
Constructor Detail |
---|
public UUCoder()
Method Detail |
---|
public static String getLegalChars()
public static String encode(byte[] data)
data
- the data to be encoded
data
. The string
contains only ASCII characters from 33 to 96.public static byte[] decode(String data)
data
- the data to be decoded
data
IllegalArgumentException
- if data
is not a valid encoding
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |