|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.hunnysoft.jmime.BinHex
Class for converting files to or from BinHex format.
BinHex converts data to or from BinHex format. BinHex
is a format used almost exclusively on Macintosh computers for encoding
files into text characters for transmission through the mail transport
system or for archiving on non-Macintosh systems. The format includes
the file name, file type, file creator, Macintosh Finder flags, data
fork, resource fork, and checksums. In MIME, the use of BinHex is
deprecated; applesingle and appledouble are the preferred format for
encoding Macintosh files. The BinHex format is described in RFC 1741.
BinHex is a widely used, de facto standard, but it is not an
official Internet standard.
To use BinHex for converting a Macintosh file
to BinHex format, call the methods setFileName(com.hunnysoft.jmime.ByteString), setFileType(java.lang.String), setFileCreator(java.lang.String), setFlag1(byte), setFlag2(byte), setDataFork(com.hunnysoft.jmime.ByteString), and setResourceFork(com.hunnysoft.jmime.ByteString) to set
the elements to be encoded. (The library sets reasonable default values
for any elements that you do not set.) Then call the encode()
method to actually perform the conversion to BinHex. Finally, call
binHexChars() to get the characters of the BinHex file.
To use BinHex for converting a Macintosh file
from BinHex format, call the method setBinHexChars(com.hunnysoft.jmime.ByteString) to
set the characters of the BinHex file to be converted. Then call decode() to actually perform the conversion. Finally, call fileName(), fileType(), fileCreator(), flag1(),
flag2(), dataFork(), and resourceFork() to get the
decoded elements.
Note: BinHex does not change the file name in any
way. When you deal with file names, you should be aware of the fact that
some filenames that are valid on a Macintosh may cause problems or
unexpected results on a non-Macintosh system, and vice versa. Such
problem characters include slash ('/'), colon (':'), space and possibly
other characters.
| Constructor Summary | |
BinHex()
Default constructor. |
|
| Method Summary | |
ByteString |
binHexChars()
Gets the characters of the BinHex encoded file. |
ByteString |
dataFork()
Gets the data fork for the file. |
int |
decode()
Converts the Macintosh file information from BinHex format. |
void |
encode()
Converts the Macintosh file information to BinHex format. |
java.lang.String |
fileCreator()
Gets the file creator. |
ByteString |
fileName()
Gets the file name. |
java.lang.String |
fileType()
Gets the file type. |
byte |
flag1()
Gets the first byte of the Macintosh Finder flags. |
byte |
flag2()
Gets the second byte of the Macintosh Finder flags. |
void |
initialize()
Resets the object's internal state to its initial state. |
ByteString |
resourceFork()
Gets the resource fork for the file. |
void |
setBinHexChars(ByteString chars)
Sets the characters of the BinHex encoded file. |
void |
setDataFork(ByteString bytes)
Sets the data fork for the file. |
void |
setFileCreator(java.lang.String creator)
Sets the file creator. |
void |
setFileName(ByteString name)
Sets the file name. |
void |
setFileType(java.lang.String type)
Sets the file type. |
void |
setFlag1(byte flag)
Sets the first byte of the Macintosh Finder flags. |
void |
setFlag2(byte flag)
Sets the second byte of the Macintosh Finder flags. |
void |
setResourceFork(ByteString bytes)
Sets the resource fork for the file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public BinHex()
| Method Detail |
public void initialize()
You may call this method to reuse the object for more than one encode or decode operation.
public ByteString fileName()
The file name is restricted to a maximum length of 63 characters.
public void setFileName(ByteString name)
The file name is restricted to a maximum length of 63 characters.
name - the file namepublic java.lang.String fileType()
All Macintosh files have a file type, which is represented by four bytes. Some examples include "TEXT" for a text file, or "APPL" for an application.
public void setFileType(java.lang.String type)
All Macintosh files have a file type, which is represented by four bytes. Some examples include "TEXT" for a text file, or "APPL" for an application.
type - the file typepublic java.lang.String fileCreator()
Most Macintosh files have a creator, which is represented by a signature of four bytes. The creator specifies which application to launch when a file's icon is double clicked.
public void setFileCreator(java.lang.String creator)
Most Macintosh files have a creator, which is represented by a signature of four bytes. The creator specifies which application to launch when a file's icon is double clicked.
creator - the file creatorpublic byte flag1()
For files that originate on non-Macintosh systems, this byte should be set to zero (the default).
public void setFlag1(byte flag)
For files that originate on non-Macintosh systems, this byte should be set to zero (the default).
flag - the first byte of the Finder flagspublic byte flag2()
For files that originate on non-Macintosh systems, this byte should be set to zero (the default).
public void setFlag2(byte flag)
For files that originate on non-Macintosh systems, this byte should be set to zero (the default).
flag - the second byte of the Finder flagspublic ByteString dataFork()
For files that originate on non-Macintosh systems, such as GIF or JPEG files, the file data should be set as the data fork.
public void setDataFork(ByteString bytes)
For files that originate on non-Macintosh systems, such as GIF or JPEG files, the file data should be set as the data fork.
bytes - the bytes of the data forkpublic ByteString resourceFork()
For files that originate on non-Macintosh systems, such as GIF or JPEG files, the resource fork should normally be empty.
public void setResourceFork(ByteString bytes)
For files that originate on non-Macintosh systems, such as GIF or JPEG files, the resource fork should normally be empty.
bytes - the bytes of the resource forkpublic ByteString binHexChars()
public void setBinHexChars(ByteString chars)
chars - the encoded characters of the BinHex filepublic void encode()
public int decode()
Returns zero if the decode operation completes successufully; otherwise, the function returns -1.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||