Class Overview
This class implements a Berkeley uu character encoder. This encoder
was made famous by uuencode program.
The basic character coding is algorithmic, taking 6 bits of binary
data and adding it to an ASCII ' ' (space) character. This converts
these six bits into a printable representation. Note that it depends
on the ASCII character encoding standard for english. Groups of three
bytes are converted into 4 characters by treating the three bytes
a four 6 bit groups, group 1 is byte 1's most significant six bits,
group 2 is byte 1's least significant two bits plus byte 2's four
most significant bits. etc.
In this encoding, the buffer prefix is:
begin [mode] [filename]
This is followed by one or more lines of the form:
(len)(data)(data)(data) ...
where (len) is the number of bytes on this line. Note that groupings
are always four characters, even if length is not a multiple of three
bytes. When less than three characters are encoded, the values of the
last remaining bytes is undefined and should be ignored.
The last line of data in a uuencoded file is represented by a single
space character. This is translated by the decoding engine to a line
length of zero. This is immediately followed by a line which contains
the word 'end[newline]'
Summary
Public Constructors |
|
UUEncoder()
Default - buffer begin line will be:
begin 644 encoder.buf
|
|
UUEncoder(String fname)
Specifies a name for the encoded buffer, begin line will be:
begin 644 [FNAME]
|
|
UUEncoder(String fname, int newMode)
Specifies a name and mode for the encoded buffer, begin line will be:
begin [MODE] [FNAME]
|
Protected Methods |
int
|
bytesPerAtom()
number of bytes per atom in uuencoding is 3
|
int
|
bytesPerLine()
number of bytes per line in uuencoding is 45
|
void
|
encodeAtom(OutputStream outStream, byte[] data, int offset, int len)
encodeAtom - take three bytes and encodes them into 4 characters
If len is less than 3 then remaining bytes are filled with '1'.
|
void
|
encodeBufferPrefix(OutputStream a)
encodeBufferPrefix writes the begin line to the output stream.
|
void
|
encodeBufferSuffix(OutputStream a)
encodeBufferSuffix writes the single line containing space (' ') and
the line containing the word 'end' to the output stream.
|
void
|
encodeLinePrefix(OutputStream outStream, int length)
Encode the line prefix which consists of the single character.
|
void
|
encodeLineSuffix(OutputStream outStream)
The line suffix for uuencoded files is simply a new line.
|
[Expand]
Inherited Methods |
From class
sun.misc.CharacterEncoder
abstract
int
|
bytesPerAtom()
Return the number of bytes per atom of encoding
|
abstract
int
|
bytesPerLine()
Return the number of bytes that can be encoded per line
|
void
|
encode(byte[] aBuffer, OutputStream aStream)
Encode the buffer in aBuffer and write the encoded
result to the OutputStream aStream.
|
String
|
encode(ByteBuffer aBuffer)
A 'streamless' version of encode that simply takes a ByteBuffer
and returns a string containing the encoded buffer.
|
void
|
encode(InputStream inStream, OutputStream outStream)
Encode bytes from the input stream, and write them as text characters
to the output stream.
|
String
|
encode(byte[] aBuffer)
A 'streamless' version of encode that simply takes a buffer of
bytes and returns a string containing the encoded buffer.
|
void
|
encode(ByteBuffer aBuffer, OutputStream aStream)
Encode the aBuffer ByteBuffer and write the encoded
result to the OutputStream aStream.
|
abstract
void
|
encodeAtom(OutputStream aStream, byte[] someBytes, int anOffset, int aLength)
Encode one "atom" of information into characters.
|
void
|
encodeBuffer(byte[] aBuffer, OutputStream aStream)
Encode the buffer in aBuffer and write the encoded
result to the OutputStream aStream.
|
String
|
encodeBuffer(ByteBuffer aBuffer)
A 'streamless' version of encode that simply takes a ByteBuffer
and returns a string containing the encoded buffer.
|
void
|
encodeBuffer(InputStream inStream, OutputStream outStream)
Encode bytes from the input stream, and write them as text characters
to the output stream.
|
void
|
encodeBuffer(ByteBuffer aBuffer, OutputStream aStream)
Encode the aBuffer ByteBuffer and write the encoded
result to the OutputStream aStream.
|
String
|
encodeBuffer(byte[] aBuffer)
A 'streamless' version of encode that simply takes a buffer of
bytes and returns a string containing the encoded buffer.
|
void
|
encodeBufferPrefix(OutputStream aStream)
Encode the prefix for the entire buffer.
|
void
|
encodeBufferSuffix(OutputStream aStream)
Encode the suffix for the entire buffer.
|
void
|
encodeLinePrefix(OutputStream aStream, int aLength)
Encode the prefix that starts every output line.
|
void
|
encodeLineSuffix(OutputStream aStream)
Encode the suffix that ends every output line.
|
int
|
readFully(InputStream in, byte[] buffer)
This method works around the bizarre semantics of BufferedInputStream's
read method.
|
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
final
void
|
wait(long timeout, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
|
final
void
|
wait(long timeout)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.
|
|
Public Constructors
public
UUEncoder
()
Default - buffer begin line will be:
begin 644 encoder.buf
public
UUEncoder
(String fname)
Specifies a name for the encoded buffer, begin line will be:
begin 644 [FNAME]
public
UUEncoder
(String fname, int newMode)
Specifies a name and mode for the encoded buffer, begin line will be:
begin [MODE] [FNAME]
Protected Methods
protected
int
bytesPerAtom
()
number of bytes per atom in uuencoding is 3
protected
int
bytesPerLine
()
number of bytes per line in uuencoding is 45
protected
void
encodeAtom
(OutputStream outStream, byte[] data, int offset, int len)
encodeAtom - take three bytes and encodes them into 4 characters
If len is less than 3 then remaining bytes are filled with '1'.
This insures that the last line won't end in spaces and potentiallly
be truncated.
protected
void
encodeBufferPrefix
(OutputStream a)
encodeBufferPrefix writes the begin line to the output stream.
protected
void
encodeBufferSuffix
(OutputStream a)
encodeBufferSuffix writes the single line containing space (' ') and
the line containing the word 'end' to the output stream.
protected
void
encodeLinePrefix
(OutputStream outStream, int length)
Encode the line prefix which consists of the single character. The
lenght is added to the value of ' ' (32 decimal) and printed.
protected
void
encodeLineSuffix
(OutputStream outStream)
The line suffix for uuencoded files is simply a new line.