|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ipworks.Netcode
The NetCode control can be used to encode or decode files or strings. UUEncode , MIME's Base64 and Quoted-Printable , as well as URL encoding formats are currently supported.
NetCode's operation is controlled by calling the control's methods or
assigning a corresponding value to the Action
property. 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 are often split over several files because of the size limit placed on the email message. Each message is preceded by information about splitting and also the mail header. NetCode supports this case in both directions:
- during encoding setting the MaxFileSize
property 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 "?".
- 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
. This multiple filename should be given to EncodedData
. While uudecoding,
if the IntelliCode
property is set to True, NetCode tries to filter the data that
don't belong to the pure uuencoded data (also the mail header).
Field Summary | |
static int |
fmtBASE64
|
static int |
fmtQP
|
static int |
fmtURL
|
static int |
fmtUUEncode
|
static int |
netcodeDecodeToFile
|
static int |
netcodeDecodeToString
|
static int |
netcodeEncodeToFile
|
static int |
netcodeEncodeToString
|
static int |
netcodeIdle
|
Constructor Summary | |
Netcode()
|
Method Summary | |
void |
addNetcodeEventListener(NetcodeEventListener l)
|
void |
decodeToFile()
Decode to file. |
void |
decodeToString()
Decode to string. |
void |
encodeToFile()
Encode to file. |
void |
encodeToString()
Encode to string. |
void |
fireProgress(int percentDone)
Occurs when PercentDone of the input is read. |
int |
getAction()
Controls the operation of NetCode. |
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 component has read from or written into. |
java.lang.String |
getFileName()
The destination filename for the encoded data. |
int |
getFormat()
Shows the type of encoding to be used. |
int |
getMaxFileSize()
When decoding, controls whether encoded data should be split into several files and gives the maximum allowed size for these files. |
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 |
setAction(int action)
Controls the operation of NetCode. |
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)
Shows the type of encoding to be used. |
void |
setIntelliCode(boolean intelliCode)
Controls whether NetCode should try to interpret several concatenated messages while uudecoding. |
void |
setMaxFileSize(int maxFileSize)
When decoding, controls whether encoded data should be split into several files and gives the maximum allowed size for these files. |
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 netcodeIdle
public static final int netcodeDecodeToFile
public static final int netcodeEncodeToFile
public static final int netcodeDecodeToString
public static final int netcodeEncodeToString
public static final int fmtUUEncode
public static final int fmtBASE64
public static final int fmtQP
public static final int fmtURL
Constructor Detail |
public Netcode()
Method Detail |
public int getAction()
Action
property to a valid action code makes
the control perform the associated action. If the action completes
successfully, execution continues normally, and Action
is
reset to 0 (Idle). If an error happens, then
an IPWorksException exception is raised.
The following are the possible values for the Action
property
and the corresponding descriptions:
Format
. Data is read from
the EncodedData
file(s) and written in the filename specified
in the encoded data.
DecodedData
or, if DecodedData
is empty, FileName
can be used to override this value.
FileName
contains the
filename for the created file.
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
.
EncodedData
and the filename in FileName
.
MaxFileSize
is set and the encoded data take more space than MaxFileSize
, 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.
Format
: The string EncodedData
is encoded into DecodedData
. FileName
contains the filename
contained in the uuencoded data.
Format
: DecodedData
is encoded into EncodedData
.
(the data is considered binary while uuencoding and Base64 Format
s, and Text during QuotedPrintable ones.)
When uuencoding
the filename is taken from the FileName
property.
public void setAction(int action) throws IPWorksException
Action
property to a valid action code makes
the control perform the associated action. If the action completes
successfully, execution continues normally, and Action
is
reset to 0 (Idle). If an error happens, then
an IPWorksException exception is raised.
The following are the possible values for the Action
property
and the corresponding descriptions:
Format
. Data is read from
the EncodedData
file(s) and written in the filename specified
in the encoded data.
DecodedData
or, if DecodedData
is empty, FileName
can be used to override this value.
FileName
contains the
filename for the created file.
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
.
EncodedData
and the filename in FileName
.
MaxFileSize
is set and the encoded data take more space than MaxFileSize
, 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.
Format
: The string EncodedData
is encoded into DecodedData
. FileName
contains the filename
contained in the uuencoded data.
Format
: DecodedData
is encoded into EncodedData
.
(the data is considered binary while uuencoding and Base64 Format
s, and Text during QuotedPrintable ones.)
When uuencoding
the filename is taken from the FileName
property.
public byte[] getDecodedData()
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
only the filename, so that no
problems occur while uudecoding in a foreign system.
When decoding, the control 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 control 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
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
only the filename, so that no
problems occur while uudecoding in a foreign system.
When decoding, the control 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 control tries to create the given
filename in this directory. If this is the case, FileName
shows the
name of the created file.
public byte[] getEncodedData()
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 control 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
, IntelliCode
, and MaxFileSize
properties
when working with multiple files.
public void setEncodedData(byte[] encodedData) throws IPWorksException
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 control 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
, IntelliCode
, and MaxFileSize
properties
when working with multiple files.
public int getFileCnt()
EncodedData
they will be expanded to 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()
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 control 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 Action
, 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 FileName
is empty and the UUEncode Format
and
the EncodeToString Action
are selected.
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
catch the exception
and check the filename appended to FileName
.
public void setFileName(java.lang.String fileName) throws IPWorksException
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 control 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 Action
, 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 FileName
is empty and the UUEncode Format
and
the EncodeToString Action
are selected.
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
catch the exception
and check the filename appended to FileName
.
public int getFormat()
Format
property,
and the corresponding descriptions:
public void setFormat(int format) throws IPWorksException
Format
property,
and the corresponding descriptions:
public boolean isIntelliCode()
IntelliCode
to False only in the improbable case that the data is decoded improperly.
IMPORTANT: The uuencoded messages should appear in the proper order. The control 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
IntelliCode
to False only in the improbable case that the data is decoded improperly.
IMPORTANT: The uuencoded messages should appear in the proper order. The control handles only the filtering of packing information and does no sorting.
The IntelliCode
property applies only to the 'uuencoded' Format
.
public int getMaxFileSize()
MaxFileSize
makes the control split the encoded data
into several files. FileCnt
will contain the number of files created. Please refer
to EncodedData
for filename conventions.
IMPORTANT: if a non-zero value is assigned to MaxFileSize
then a multiple filename should also
be assigned to EncodedData
(end with question marks "?") so that the control can expand
the filenames.
Please refer to the Error Messages section for a complete list of possible errors.
public void setMaxFileSize(int maxFileSize) throws IPWorksException
MaxFileSize
makes the control split the encoded data
into several files. FileCnt
will contain the number of files created. Please refer
to EncodedData
for filename conventions.
IMPORTANT: if a non-zero value is assigned to MaxFileSize
then a multiple filename should also
be assigned to EncodedData
(end with question marks "?") so that the control can expand
the filenames.
Please refer to the Error Messages section for a complete list of possible errors.
public java.lang.String getMode()
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
Mode
contains
the protection string given in the uuencoded data.
Given for compatibility with other systems.
Used only when Format
is fmtUUE.
public boolean isOverwrite()
public void setOverwrite(boolean overwrite) throws IPWorksException
public int getProgressStep()
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
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 fireProgress(int percentDone)
NetcodeProgressEvent
public void decodeToFile() throws IPWorksException
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.
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.
Calling this method is equivalent to setting the Action
property
to netcodeDecodeToFile .
public void decodeToString() throws IPWorksException
Format
: The string EncodedData
is encoded into DecodedData
. FileName
contains the filename
contained in the uuencoded data.
Calling this method is equivalent to setting the Action
property
to netcodeDecodeToString .
public void encodeToFile() throws IPWorksException
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
.
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.
If MaxFileSize
is set and the encoded data take more space than MaxFileSize
, 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.
Calling this method is equivalent to setting the Action
property
to netcodeEncodeToFile .
public void encodeToString() throws IPWorksException
Format
: DecodedData
is encoded into EncodedData
.
(the data is considered binary while uuencoding and Base64 Format
s, and Text during QuotedPrintable ones.)
When uuencoding
the filename is taken from the FileName
property.
Calling this method is equivalent to setting the Action
property
to netcodeEncodeToString .
public void addNetcodeEventListener(NetcodeEventListener l) throws java.util.TooManyListenersException
public void removeNetcodeEventListener(NetcodeEventListener l)
|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |