|
IP*Works! V6 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--ipworks.Netcode
The NetCode bean can be used to encode or decode files or strings. UUEncode , MIME's Base64 Quoted-Printable , URL encoding formats, as well as secure hash functions such as MD5 and SHA1, are currently supported.
The encoding format
is specified by the Format property. The binary data, or the name of the
file containing binary data, is specified by the DecodedData property and
the encoded data or filename is specified by the EncodedData property. The FileName property may be used to override the default file names or to
specify a directory during uuencoding. After uudecoding, the FileName property contains the fully specified file name of the decoded file.
Understanding Encoding/Decoding
Most of mail systems use only 7 bits to transmit messages. A binary file such as an archive or a non-plain text formatted file produced from a text processor should be first encoded in 7 bit code before email transfer.
Decoding is the inverse process: creation of the original file from the encoded data. Encoded data is often split over several files because of the size limit placed on the email message. Each message is preceded by information about this splitting, as well as the mail header. NetCode supports this case in both directions:
- During encoding setting theMaxFileSizeconfig setting to the maximum size of a message
body instructs NetCode to split the encoded data over several files. Multiple filenames
can be specified by using question marks "?" (See the EncodedData property for more information).
- During decoding , the body messages can be saved in separate files named namexxx.ext
where xxx is a numeral starting at 000 and ext is ".uue", ".b16", or ".q_p" according to Format . These multiple filenames should be given to EncodedData . While uudecoding,
if the IntelliCode property is set to True, NetCode tries to filter the data that
doesn't belong to the pure uuencoded data (This may include mail headers).
| Field Summary | |
static int |
fmtBase64
|
static int |
fmtHex
|
static int |
fmtJIS
|
static int |
fmtMD5Hash
|
static int |
fmtQP
|
static int |
fmtSHA1Hash
|
static int |
fmtURL
|
static int |
fmtUUEncode
|
static int |
fmtYEncode
|
| Constructor Summary | |
Netcode()
|
|
| Method Summary | |
void |
addNetcodeEventListener(NetcodeEventListener l)
|
java.lang.String |
config(java.lang.String configurationString)
Sets or retrieves a beanconfiguration setting. |
void |
decodeToFile()
Decode to file. |
void |
decodeToString()
Decode to string. |
void |
encodeToFile()
Encode to file. |
void |
encodeToString()
Encode to string. |
byte[] |
getDecodedData()
Filename of the decoded data or the decoded data itself. |
byte[] |
getEncodedData()
Filename of the encoded data or the encoded data itself. |
int |
getFileCnt()
Shows the number of encoded files the bean has read from or written into. |
java.lang.String |
getFileName()
The destination filename for the encoded data. |
int |
getFormat()
The type of encoding to be used. |
java.lang.String |
getMode()
The UNIX-style filemode when uuencoding / uudecoding. |
int |
getProgressStep()
Controls the granularity at which the Progress event is fired. |
boolean |
isIntelliCode()
Controls whether NetCode should try to interpret several concatenated messages while uudecoding. |
boolean |
isOverwrite()
Controls whether created file(s) should overwrite already existing file(s). |
void |
removeNetcodeEventListener(NetcodeEventListener l)
|
void |
setDecodedData(byte[] decodedData)
Filename of the decoded data or the decoded data itself. |
void |
setEncodedData(byte[] encodedData)
Filename of the encoded data or the encoded data itself. |
void |
setFileName(java.lang.String fileName)
The destination filename for the encoded data. |
void |
setFormat(int format)
The type of encoding to be used. |
void |
setIntelliCode(boolean intelliCode)
Controls whether NetCode should try to interpret several concatenated messages while uudecoding. |
void |
setMode(java.lang.String mode)
The UNIX-style filemode when uuencoding / uudecoding. |
void |
setOverwrite(boolean overwrite)
Controls whether created file(s) should overwrite already existing file(s). |
void |
setProgressStep(int progressStep)
Controls the granularity at which the Progress event is fired. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int fmtUUEncode
public static final int fmtBase64
public static final int fmtQP
public static final int fmtURL
public static final int fmtJIS
public static final int fmtYEncode
public static final int fmtMD5Hash
public static final int fmtSHA1Hash
public static final int fmtHex
| Constructor Detail |
public Netcode()
| Method Detail |
public byte[] getDecodedData()
When uuencoding, the value of FileName is the filename that will
be written in EncodedData . If FileName is empty, the value of
the DecodedData property is taken. It is recommended that EncodedData contains the full path and FileName contains only the file name so that no problems occur while uudecoding in a foreign system.
When decoding, the bean tries to generate the name for the created
file in the following order: DecodedData , FileName , or when the
format is UUEncode, the specified filename in the uuencoded data itself.
If DecodedData or FileName end with a backslash "\\" they are
interpreted as directories and the bean tries to create the given
filename in this directory. If this is the case, FileName shows the
name of the created file.
public void setDecodedData(byte[] decodedData)
throws IPWorksException
When uuencoding, the value of FileName is the filename that will
be written in EncodedData . If FileName is empty, the value of
the DecodedData property is taken. It is recommended that EncodedData contains the full path and FileName contains only the file name so that no problems occur while uudecoding in a foreign system.
When decoding, the bean tries to generate the name for the created
file in the following order: DecodedData , FileName , or when the
format is UUEncode, the specified filename in the uuencoded data itself.
If DecodedData or FileName end with a backslash "\\" they are
interpreted as directories and the bean tries to create the given
filename in this directory. If this is the case, FileName shows the
name of the created file.
IPWorksExceptionpublic byte[] getEncodedData()
If the encoded data is spread over several files, the filenames
are passed to EncodedData in the form name? .
Question marks "?" are expanded to numerals starting with 0.
The filenames should exist as path\\file000.ext and passed to EncodedData in the form name??? .
Question marks "?" are expanded to numerals starting with
000 (the number of zeros "0" equals that of question
marks "?").
The bean appends the extension ".uue",
".b16", or ".q_p"
depending on Format immediately after the generated numbers. FileCnt contains the number of encoded files.
See also the Format and IntelliCode properties, and theMaxFileSizeconfig setting when working with multiple files.
public void setEncodedData(byte[] encodedData)
throws IPWorksException
If the encoded data is spread over several files, the filenames
are passed to EncodedData in the form name? .
Question marks "?" are expanded to numerals starting with 0.
The filenames should exist as path\\file000.ext and passed to EncodedData in the form name??? .
Question marks "?" are expanded to numerals starting with
000 (the number of zeros "0" equals that of question
marks "?").
The bean appends the extension ".uue",
".b16", or ".q_p"
depending on Format immediately after the generated numbers. FileCnt contains the number of encoded files.
See also the Format and IntelliCode properties, and theMaxFileSizeconfig setting when working with multiple files.
IPWorksExceptionpublic int getFileCnt()
If the user specifies one or more questions marks "?" in EncodedData they will be expanded from 000 to FileCnt - 1 (the number of question
marks "?" specifies the number of figures).
Please refer to EncodedData for filename conventions.
public java.lang.String getFileName()
When uuencoding, the FileName property contains the filename that
is specified in the uuencoded data.
When decoding, if the value of the property is not empty, it shows the bean where to write the decoded data. It can be either the filename or the directory where the file should be written. If a directory, it should end with a backslash "\\".
After a decode operation, the FileName property contains the filename
for the created file. If the file couldn't be created because of an illegal
filename, examining FileName might give a hint about the reason of the
failure.
FileName must be set to "" (empty string) after each decode operation
since it contains the full specification of the file.
An error occurs if a uuencoding operation is initiated with an
empty FileName .
If you want to first check the uuencoded filename before creating it on disk,
you may assign an illegal directory name to FileName (always use a closing
backslash "\\" to denote it as directory), then trap the error
and check the filename appended to FileName .
public void setFileName(java.lang.String fileName)
throws IPWorksException
When uuencoding, the FileName property contains the filename that
is specified in the uuencoded data.
When decoding, if the value of the property is not empty, it shows the bean where to write the decoded data. It can be either the filename or the directory where the file should be written. If a directory, it should end with a backslash "\\".
After a decode operation, the FileName property contains the filename
for the created file. If the file couldn't be created because of an illegal
filename, examining FileName might give a hint about the reason of the
failure.
FileName must be set to "" (empty string) after each decode operation
since it contains the full specification of the file.
An error occurs if a uuencoding operation is initiated with an
empty FileName .
If you want to first check the uuencoded filename before creating it on disk,
you may assign an illegal directory name to FileName (always use a closing
backslash "\\" to denote it as directory), then trap the error
and check the filename appended to FileName .
IPWorksExceptionpublic int getFormat()
The following are the possible values for the Format property,
and the corresponding descriptions:
public void setFormat(int format)
throws IPWorksException
The following are the possible values for the Format property,
and the corresponding descriptions:
IPWorksExceptionpublic boolean isIntelliCode()
If a file is uuencoded and split over several mail messages, NetCode will normally
attempt to filter the opening and closing lines such as message headings and/or
decode scripts which don't belong to the encoded data. You should set IntelliCode to False only in the improbable case that the data is encoded improperly.
IMPORTANT: The uuencoded messages should appear in the proper order. The bean handles only the filtering of packing information and does no sorting.
The IntelliCode property applies only to the 'uuencoded' Format .
public void setIntelliCode(boolean intelliCode)
throws IPWorksException
If a file is uuencoded and split over several mail messages, NetCode will normally
attempt to filter the opening and closing lines such as message headings and/or
decode scripts which don't belong to the encoded data. You should set IntelliCode to False only in the improbable case that the data is encoded improperly.
IMPORTANT: The uuencoded messages should appear in the proper order. The bean handles only the filtering of packing information and does no sorting.
The IntelliCode property applies only to the 'uuencoded' Format .
IPWorksExceptionpublic java.lang.String getMode()
The filemode is usually an octal number such as 755 or 600
which gives the protections of that file.
If the file to uudecode is correctly read then Mode contains
the protection string given in the uuencoded data.
Given for compatibility with other systems.
Used only when Format is fmtUUE.
public void setMode(java.lang.String mode)
throws IPWorksException
The filemode is usually an octal number such as 755 or 600
which gives the protections of that file.
If the file to uudecode is correctly read then Mode contains
the protection string given in the uuencoded data.
Given for compatibility with other systems.
Used only when Format is fmtUUE.
IPWorksExceptionpublic boolean isOverwrite()
Note that more than one file may be created during uuencoding.
public void setOverwrite(boolean overwrite)
throws IPWorksException
Note that more than one file may be created during uuencoding.
IPWorksExceptionpublic int getProgressStep()
Progress event is fired. Values 0-100.
If ProgressStep is not 0, the Progress event will be fired
when 0%, n* ProgressStep and 100% of input
data is read.
If ProgressStep is 0, the Progress event is disabled.
public void setProgressStep(int progressStep)
throws IPWorksException
Progress event is fired. Values 0-100.
If ProgressStep is not 0, the Progress event will be fired
when 0%, n* ProgressStep and 100% of input
data is read.
If ProgressStep is 0, the Progress event is disabled.
IPWorksException
public java.lang.String config(java.lang.String configurationString)
throws IPWorksException
Config is a generic method available in every bean.
It is used to set and retrieveconfiguration settingsfor the
bean.
Configuration settings are similar in functionality to properties,
but they are rarely used. In order to avoid "polluting" the property
namespace of the bean, access to these internal properties is provided through the Config method.
To set a configuration setting named PROPERTY , you must call Config("PROPERTY=VALUE") , where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).
To read (query) the value of a configuration setting, you must call Config("PROPERTY") . The value will be returned as a string.
IPWorksException
public void decodeToFile()
throws IPWorksException
Decode with the format given in Format . Data is read from
the EncodedData file(s) and written in the filename specified
in the encoded data.
When UUDecoding the created filename will by default be the one
specified in the uuencoded data. DecodedData or, if DecodedData is empty, FileName can be used to override this value.
When YDecoding, the source path and filename is specified in EncodedData and the destination path and filename in DecodedData . If the encoded data indicates the name of the original file before decoding, this value will be stored in the FileName property. To decode a multi-part message, all parts must be concatenated in order in the source file.
If the string terminates with a backslash "\\" it is interpreted as a
directory in which to create decoded files. FileName contains the
filename for the created file.
IPWorksException
public void decodeToString()
throws IPWorksException
Decode according to Format : The string EncodedData is decoded into DecodedData . For uuencoded or yencoded data, If the EncodedData contains the name of the original file, this value will be stored in the FileName property.
IPWorksException
public void encodeToFile()
throws IPWorksException
Encode with the format given in Format . Data is read from the file DecodedData and is encoded in the file(s) EncodedData . When uuencoding,
the uuencoded data contain as filename the value given in FileName or, if
empty, the value of DecodedData . When YDecoding, the FileName will contain the name of the original file, if this information is indicated in the encoded data.
While UUEncoding it is recommended to give the full file path in EncodedData and the filename in FileName .
The current version of NetCode creates no message headers. If a MIME standard encoding is used such as Base64 Encoding or Quoted Printable Encoding the user should fill the header values appropriately.
IfMaxFileSizeis set and the encoded data take more space thanMaxFileSize, the data is split over several files. In this case, the user can
specify more than one filename by passing them to EncodedData in the form name? .
The filenames should exist as path\\file0.ext , path\\file1.ext ...
Question marks "?" are expanded to numerals starting with 0.
NetCode appends the extension ".uue", ".b16", or ".q_p" (depending
on the value of Format ) to the filename.
IPWorksException
public void encodeToString()
throws IPWorksException
Encode according to Format : DecodedData is encoded into EncodedData .
(the data is considered binary while uuencoding and Base64 Format s, and Text during QuotedPrintable ones.)
When uuencoding or yencoding the filename encoded into the data is taken from the FileName property.
IPWorksException
public void addNetcodeEventListener(NetcodeEventListener l)
throws java.util.TooManyListenersException
java.util.TooManyListenersExceptionpublic void removeNetcodeEventListener(NetcodeEventListener l)
|
IP*Works! V6 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||