com.hunnysoft.jmime
Class Uuencode

java.lang.Object
  extended bycom.hunnysoft.jmime.Uuencode

public class Uuencode
extends java.lang.Object

Class for performing uuencode or uudecode operations.

%Uuencode performs uuencode or uudecode operations. %Uuencode is a format for encoding binary data into text characters for transmission through the mail system. The format also includes the file name and the file mode. (Note: The file mode is significant only on UNIX-like systems.) In MIME, the use of uuencode is deprecated; base64 is the preferred encoding for sending binary data. Uuencode is still widely used to post binary content to Usenet newsgroups.

To use %Uuencode for encoding binary data into uuencode format, call setFileName() and setBinaryChars() to set the file name and binary data string. Then call the encode() method. Finally, call asciiChars() to retrieve the uuencoded text characters.

To use %Uuencode to decode uuencoded data, call setAsciiChars() to set the ASCII characters. Then call the decode() method. Finally, call fileName() and binaryChars() to get the file name and binary characters.


Constructor Summary
Uuencode()
          Default constructor.
 
Method Summary
 ByteString asciiChars()
          Gets the encoded characters.
 ByteString bytes()
          Gets the binary file content.
 int decode()
          Performs the decode operation.
 void encode()
          Performs the encode operation.
 short fileMode()
          Gets the file mode.
 ByteString fileName()
          Gets the file name.
 void setAsciiChars(ByteString chars)
          Sets the encoded characters.
 void setBytes(ByteString bytes)
          Sets the binary file content.
 void setFileMode(short mode)
          Sets the file mode.
 void setFileName(ByteString name)
          Sets the file name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Uuencode

public Uuencode()
Default constructor.

Method Detail

setFileName

public void setFileName(ByteString name)
Sets the file name.

The implementation limits the file name to 255 characters.

Parameters:
name - the file name

fileName

public ByteString fileName()
Gets the file name.

The implementation limits the file name to 255 characters.

Returns:
the file name

setFileMode

public void setFileMode(short mode)
Sets the file mode.

The file mode is a bit mask that indicates file permissions in the standard Unix file system. Most implementations of uuencode ignore the file mode because it is unsafe to allow an untrusted source to set file permissions on local files. Hunny JMIME allows you to set the file mode explicitly in the uuencoded file. Unless you have a specific need, you should either set the file mode to 0644 (octal) or let Hunny JMIME set the default value of 0644.

If the file mode is not explicitly set using this member function, a default value of 0644 (octal) is assumed.

Parameters:
mode - the file mode

fileMode

public short fileMode()
Gets the file mode.

The file mode is a bit mask that indicates file permissions in the standard Unix file system. You should ignore the file mode because it is unsafe to allow an untrusted source to set file permissions on local files.

Returns:
the file mode

setBytes

public void setBytes(ByteString bytes)
Sets the binary file content.

Parameters:
bytes - the bytes of the file content

bytes

public ByteString bytes()
Gets the binary file content.

Returns:
the bytes of the file content

setAsciiChars

public void setAsciiChars(ByteString chars)
Sets the encoded characters.

Parameters:
chars - the encoded characters

asciiChars

public ByteString asciiChars()
Gets the encoded characters.

Returns:
the encoded characters

encode

public void encode()
Performs the encode operation.


decode

public int decode()
Performs the decode operation.

Returns:
0 on success; -1 on failure