|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ipworks.Mime
The MIME control allows for easy implementation of the Multipurpose Internet Mail Extensions or MIME as defined in RFC 1521 and updated in RFCs 2045-2049. Those standards provide for formating of messages containing non-text, multipart or non 'US' formated text.
The control's operation is controlled by the control's methods or the Action
property. It may be used for decoding or encoding of messages. Message
holds the content of the encoded message or the filename which holds
the encoded data. The decoded data is put in PartDecodedString
and/or PartDecodedFile
depending on the user's query.
To decode a MIME message you should first assign either the whole message (headers
and body) to Message
or put the message headers to MessageHeaders
and the message body or the filename holding it to Message
.
Calling DecodeFromFile
or DecodeFromString
or setting the Action
property to decode directs the control to start parsing the message:
it will fill out the ContentType
, ContentTypeAttr
and PartCount
properties as well as the array properties PartSize
, PartContentType
, PartContentTypeAttr
, PartContentDisposition
, PartContentDispositionAttr
, PartEncoding
, PartName
, PartFilename
, PartHeaders
,
for each decoded part from 0 to PartCount
-1.
For each part you may then get the content out of PartDecodedString
or PartDecodedFile
properties. Calling the Decode methods or setting
the Action
to decode doesn't actually decode the message but only parses it.
The real decoding is done when the respective array property PartDecodedFile
or PartDecodedString
is first accessed for any particular index.
To encode data into a MIME message you should first assign values for each part
to either PartDecodedString
or PartDecodedFile
, optionally assign
values to the other Part- properties. Assiging a value to the PartDecodedString
or PartDecodedFile
properties fills out automatically the PartHeaders
property
for the respective part. Calling EncodeToFile
, EncodeToString
or setting the Action
property to encode directs the control to fill out the Message
with
the message body and the MessageHeaders
with the headers.
The Progress
event is fired as the message is parsed and the data
is decoded/encoded.
Field Summary | |
static int |
mimeDecodeFromFile
|
static int |
mimeDecodeFromString
|
static int |
mimeEncodeToFile
|
static int |
mimeEncodeToString
|
static int |
mimeIdle
|
static int |
mimeResetData
|
static int |
pe77Bit
|
static int |
pe78Bit
|
static int |
pe7Base64
|
static int |
pe7Binary
|
static int |
pe7QuotedPrintable
|
Constructor Summary | |
Mime()
|
Method Summary | |
void |
addMimeEventListener(MimeEventListener l)
|
void |
decodeFromFile()
Decode From File. |
void |
decodeFromString()
Decode From String. |
void |
encodeToFile()
Encode To File. |
void |
encodeToString()
Encode To String. |
void |
fireProgress(int percentDone)
Shows the progress of decoding/encoding the input data. |
int |
getAction()
Controls the operation of MIME component. |
java.lang.String |
getBoundary()
The boundary separating the MIME parts. |
java.lang.String |
getContentType()
The value of the content-type header of the message which was encoded/decoded. |
java.lang.String |
getContentTypeAttr()
The attributes for content-type header of the message which was encoded/decoded. |
byte[] |
getMessage()
Filename holding the encoded message or the encoded message itself. |
java.lang.String |
getMessageHeaders()
The headers of the MIME message. |
java.lang.String |
getPartContentDisposition(int partIdx)
Content Disposition for each part 0 to PartCount -1. |
java.lang.String |
getPartContentDispositionAttr(int partIdx)
Array holding the content disposition's attributes, if any, for each part, numbered 0 to PartCount -1. |
java.lang.String |
getPartContentId(int partIdx)
Content type for each part 0 to PartCount -1. |
java.lang.String |
getPartContentType(int partIdx)
Content type for each part 0 to PartCount -1. |
java.lang.String |
getPartContentTypeAttr(int partIdx)
Array holding the content type attributes, if any, for each part, numbered 0 to PartCount -1. |
int |
getPartCount()
The number of MIME parts in the encoded message. |
java.lang.String |
getPartDecodedFile(int partIdx)
Array holding the filenames with the decoded data numbered 0 to PartCount -1. |
byte[] |
getPartDecodedString(int partIdx)
Array property. |
int |
getPartEncoding(int partIdx)
The actual content encoding type for each part 0 to PartCount -1. |
java.lang.String |
getPartFilename(int partIdx)
The filename attribute specified in the headers of the part. |
java.lang.String |
getPartHeaders(int partIdx)
Headers for each MIME part, numbered 0 to PartCount -1. |
java.lang.String |
getPartName(int partIdx)
The name given to a part, such as the filename. |
int |
getPartSize(int partIdx)
The size of each PartDecodedFile or PartDecodedString . |
void |
removeMimeEventListener(MimeEventListener l)
|
void |
resetData()
Resets the values of all headers and Part- properties. |
void |
setAction(int action)
Controls the operation of MIME component. |
void |
setBoundary(java.lang.String boundary)
The boundary separating the MIME parts. |
void |
setContentType(java.lang.String contentType)
The value of the content-type header of the message which was encoded/decoded. |
void |
setContentTypeAttr(java.lang.String contentTypeAttr)
The attributes for content-type header of the message which was encoded/decoded. |
void |
setMessage(byte[] message)
Filename holding the encoded message or the encoded message itself. |
void |
setMessageHeaders(java.lang.String messageHeaders)
The headers of the MIME message. |
void |
setPartContentDisposition(int partIdx,
java.lang.String partContentDisposition)
Content Disposition for each part 0 to PartCount -1. |
void |
setPartContentDispositionAttr(int partIdx,
java.lang.String partContentDispositionAttr)
Array holding the content disposition's attributes, if any, for each part, numbered 0 to PartCount -1. |
void |
setPartContentId(int partIdx,
java.lang.String partContentId)
Content type for each part 0 to PartCount -1. |
void |
setPartContentType(int partIdx,
java.lang.String partContentType)
Content type for each part 0 to PartCount -1. |
void |
setPartContentTypeAttr(int partIdx,
java.lang.String partContentTypeAttr)
Array holding the content type attributes, if any, for each part, numbered 0 to PartCount -1. |
void |
setPartCount(int partCount)
The number of MIME parts in the encoded message. |
void |
setPartDecodedFile(int partIdx,
java.lang.String partDecodedFile)
Array holding the filenames with the decoded data numbered 0 to PartCount -1. |
void |
setPartDecodedString(int partIdx,
byte[] partDecodedString)
Array property. |
void |
setPartEncoding(int partIdx,
int partEncoding)
The actual content encoding type for each part 0 to PartCount -1. |
void |
setPartFilename(int partIdx,
java.lang.String partFilename)
The filename attribute specified in the headers of the part. |
void |
setPartHeaders(int partIdx,
java.lang.String partHeaders)
Headers for each MIME part, numbered 0 to PartCount -1. |
void |
setPartName(int partIdx,
java.lang.String partName)
The name given to a part, such as the filename. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int mimeIdle
public static final int mimeDecodeFromFile
public static final int mimeDecodeFromString
public static final int mimeEncodeToFile
public static final int mimeEncodeToString
public static final int mimeResetData
public static final int pe77Bit
public static final int pe7QuotedPrintable
public static final int pe7Base64
public static final int pe78Bit
public static final int pe7Binary
Constructor Detail |
public Mime()
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:
Message
and optionally MessageHeaders
and fills out the PartCount
, property and the array properties PartSize
, PartContentType
, PartContentTypeAttr
, PartEncoding
, PartName
, PartHeaders
,
for each decoded part from 0 to PartCount
-1. For each part you may
get the content out of PartDecodedString
or PartDecodedFile
property.
The decoded data will be held in PartDecodedString
or otherwise saved in a temporary
file given by PartDecodedFile
when the user asks for the value of the respective
property.
Message
denotes the real encoded message rather than a filename.
PartDecodedFile
or PartDecodedString
into a MIME message at Message
and MessageHeaders
using the
values optionally given in PartContentType
, PartContentTypeAttr
, PartEncoding
, PartName
, PartHeaders
. To encode several objects
into a MIME envelope, the user should first clear any old values left in
the Part- properties and then assign values for all the indices starting with 1.
The control will check for each index first the PartDecodedFile
and then PartDecodedString
for the data to encode.
The encoded message will be saved in the file pointed by Message
;
the message headers will be held by MessageHeaders
.
Message
property rather than saved to a file.
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:
Message
and optionally MessageHeaders
and fills out the PartCount
, property and the array properties PartSize
, PartContentType
, PartContentTypeAttr
, PartEncoding
, PartName
, PartHeaders
,
for each decoded part from 0 to PartCount
-1. For each part you may
get the content out of PartDecodedString
or PartDecodedFile
property.
The decoded data will be held in PartDecodedString
or otherwise saved in a temporary
file given by PartDecodedFile
when the user asks for the value of the respective
property.
Message
denotes the real encoded message rather than a filename.
PartDecodedFile
or PartDecodedString
into a MIME message at Message
and MessageHeaders
using the
values optionally given in PartContentType
, PartContentTypeAttr
, PartEncoding
, PartName
, PartHeaders
. To encode several objects
into a MIME envelope, the user should first clear any old values left in
the Part- properties and then assign values for all the indices starting with 1.
The control will check for each index first the PartDecodedFile
and then PartDecodedString
for the data to encode.
The encoded message will be saved in the file pointed by Message
;
the message headers will be held by MessageHeaders
.
Message
property rather than saved to a file.
public java.lang.String getBoundary()
The control will truncate any string longer than 80
if assigned to Boundary
.
public void setBoundary(java.lang.String boundary) throws IPWorksException
The control will truncate any string longer than 80
if assigned to Boundary
.
public java.lang.String getContentType()
MessageHeaders
. It shows
the user about the type of the parts and their relation to each other.
The content-type attributes such as filename, boundary, charset etc are held
in the ContentTypeAttr
property.
public void setContentType(java.lang.String contentType) throws IPWorksException
MessageHeaders
. It shows
the user about the type of the parts and their relation to each other.
The content-type attributes such as filename, boundary, charset etc are held
in the ContentTypeAttr
property.
public java.lang.String getContentTypeAttr()
ContentTypeAttr
property. Its values and semantics on those of ContentType
.
public void setContentTypeAttr(java.lang.String contentTypeAttr) throws IPWorksException
ContentTypeAttr
property. Its values and semantics on those of ContentType
.
public byte[] getMessage()
Message
with the message
body and MessageHeaders
during encoding. The user may assign
both the headers and the body to Message
and leave MessageHeaders
empty before decoding.
public void setMessage(byte[] message) throws IPWorksException
Message
with the message
body and MessageHeaders
during encoding. The user may assign
both the headers and the body to Message
and leave MessageHeaders
empty before decoding.
public java.lang.String getMessageHeaders()
MessageHeaders
upon encoding. The user should
use them as additional headers when emailing the Message
.
During decoding, if MessageHeaders
is empty, the control will
try to find the headers in the begining of the Message
and
will fill out MessageHeaders
property accordingly.
public void setMessageHeaders(java.lang.String messageHeaders) throws IPWorksException
MessageHeaders
upon encoding. The user should
use them as additional headers when emailing the Message
.
During decoding, if MessageHeaders
is empty, the control will
try to find the headers in the begining of the Message
and
will fill out MessageHeaders
property accordingly.
public java.lang.String getPartContentDisposition(int partIdx) throws IPWorksException
PartDecodedFile
property is changed. Changing PartContentDisposition
recalculates the PartHeaders
property as well.
A valid PartIdx is 0 to PartCount
-1.
public void setPartContentDisposition(int partIdx, java.lang.String partContentDisposition) throws IPWorksException
PartDecodedFile
property is changed. Changing PartContentDisposition
recalculates the PartHeaders
property as well.
A valid PartIdx is 0 to PartCount
-1.
public java.lang.String getPartContentDispositionAttr(int partIdx) throws IPWorksException
PartContentDispositionAttr
are the names of the
form-variables while creating an HTTP post, values for filenames etc.
Setting this property recalculates the PartHeaders
property.
A valid PartIdx is 0 to PartCount
-1.
public void setPartContentDispositionAttr(int partIdx, java.lang.String partContentDispositionAttr) throws IPWorksException
PartContentDispositionAttr
are the names of the
form-variables while creating an HTTP post, values for filenames etc.
Setting this property recalculates the PartHeaders
property.
A valid PartIdx is 0 to PartCount
-1.
public java.lang.String getPartContentId(int partIdx) throws IPWorksException
PartDecodedFile
property is changed. Changing PartContentId
recalculates the PartHeaders
property as well.
A valid PartIdx is 0 to PartCount
-1.
public void setPartContentId(int partIdx, java.lang.String partContentId) throws IPWorksException
PartDecodedFile
property is changed. Changing PartContentId
recalculates the PartHeaders
property as well.
A valid PartIdx is 0 to PartCount
-1.
public java.lang.String getPartContentType(int partIdx) throws IPWorksException
PartDecodedFile
property is changed. Changing PartContentType
recalculates the PartHeaders
property as well.
A valid PartIdx is 0 to PartCount
-1.
public void setPartContentType(int partIdx, java.lang.String partContentType) throws IPWorksException
PartDecodedFile
property is changed. Changing PartContentType
recalculates the PartHeaders
property as well.
A valid PartIdx is 0 to PartCount
-1.
public java.lang.String getPartContentTypeAttr(int partIdx) throws IPWorksException
PartHeaders
property.
A valid PartIdx is 0 to PartCount
-1.
public void setPartContentTypeAttr(int partIdx, java.lang.String partContentTypeAttr) throws IPWorksException
PartHeaders
property.
A valid PartIdx is 0 to PartCount
-1.
public int getPartCount()
PartCount
during decoding with the number of parts
in the Message
. All the Part- properties have valid indexes 0 to PartCount
-1.
The user may set PartCount
before encoding to the number of parts she wants the
control to encode.
public void setPartCount(int partCount) throws IPWorksException
PartCount
during decoding with the number of parts
in the Message
. All the Part- properties have valid indexes 0 to PartCount
-1.
The user may set PartCount
before encoding to the number of parts she wants the
control to encode.
public java.lang.String getPartDecodedFile(int partIdx) throws IPWorksException
PartDecodedFile
for the first time after setting Action
to decode directs the control to actually decode the part and save
the data in a temporary file. The user is responsible
for deleting the temporary file.
Setting a value to PartDecodedFile
directs the component to calculate the
file size and fill out the respective PartSize
property.
Valid PartIdx values are 0 to PartCount
-1.
public void setPartDecodedFile(int partIdx, java.lang.String partDecodedFile) throws IPWorksException
PartDecodedFile
for the first time after setting Action
to decode directs the control to actually decode the part and save
the data in a temporary file. The user is responsible
for deleting the temporary file.
Setting a value to PartDecodedFile
directs the component to calculate the
file size and fill out the respective PartSize
property.
Valid PartIdx values are 0 to PartCount
-1.
public byte[] getPartDecodedString(int partIdx) throws IPWorksException
Message
to PartDecodedString
property
when PartDecodedString
's value is first queried.
Setting a value to PartDecodedString
fills out the PartSize
property
with the string size if PartDecodedFile
is empty.
The control checks during encoding first PartDecodedFile
:
if it is empty then the control uses the value of PartDecodedString
.
A valid PartIdx is 0 to PartCount
-1.
public void setPartDecodedString(int partIdx, byte[] partDecodedString) throws IPWorksException
Message
to PartDecodedString
property
when PartDecodedString
's value is first queried.
Setting a value to PartDecodedString
fills out the PartSize
property
with the string size if PartDecodedFile
is empty.
The control checks during encoding first PartDecodedFile
:
if it is empty then the control uses the value of PartDecodedString
.
A valid PartIdx is 0 to PartCount
-1.
public int getPartEncoding(int partIdx) throws IPWorksException
PartEncoding
determines how to encode the data or how
they were actually encoded in the Message
as specified in the Content-Transfer-Encoding header.
A valid PartIdx is 0 to PartCount
-1.
Possible values for PartEncoding
are:
public void setPartEncoding(int partIdx, int partEncoding) throws IPWorksException
PartEncoding
determines how to encode the data or how
they were actually encoded in the Message
as specified in the Content-Transfer-Encoding header.
A valid PartIdx is 0 to PartCount
-1.
Possible values for PartEncoding
are:
public java.lang.String getPartFilename(int partIdx) throws IPWorksException
PartDecodedFile
sets automatically the PartFilename
and consequently the PartHeaders
property for
the same PartIdx .
A valid PartIdx is 0 to PartCount
-1.
public void setPartFilename(int partIdx, java.lang.String partFilename) throws IPWorksException
PartDecodedFile
sets automatically the PartFilename
and consequently the PartHeaders
property for
the same PartIdx .
A valid PartIdx is 0 to PartCount
-1.
public java.lang.String getPartHeaders(int partIdx) throws IPWorksException
PartHeaders
each time any of the other Part-
properties for that PartIdx is changed. If additional headers are needed
they should be appended after all the other Part- properties for that PartIdx are set.
Valid PartIdx values are 0 to PartCount
-1.
public void setPartHeaders(int partIdx, java.lang.String partHeaders) throws IPWorksException
PartHeaders
each time any of the other Part-
properties for that PartIdx is changed. If additional headers are needed
they should be appended after all the other Part- properties for that PartIdx are set.
Valid PartIdx values are 0 to PartCount
-1.
public java.lang.String getPartName(int partIdx) throws IPWorksException
PartDecodedFile
sets automatically the PartName
and consequently the PartHeaders
property for
the same PartIdx .
A valid PartIdx is 0 to PartCount
-1.
public void setPartName(int partIdx, java.lang.String partName) throws IPWorksException
PartDecodedFile
sets automatically the PartName
and consequently the PartHeaders
property for
the same PartIdx .
A valid PartIdx is 0 to PartCount
-1.
public int getPartSize(int partIdx) throws IPWorksException
PartDecodedFile
then control fills out PartSize
of the same PartIdx with the file size or an error occurrs
if the file doesn't exist. If PartDecodedFile
is empty and a value is assigned
to PartDecodedString
then PartSize
will be equal to the string's size.
During decoding the PartSize
is filled with the size of each part as soon
as Action
is set to decode.
public void fireProgress(int percentDone)
MimeProgressEvent
public void decodeFromFile() throws IPWorksException
Message
and optionally MessageHeaders
and fills out the PartCount
, property and the array properties PartSize
, PartContentType
, PartContentTypeAttr
, PartEncoding
, PartName
, PartHeaders
,
for each decoded part from 0 to PartCount
-1. For each part you may
get the content out of PartDecodedString
or PartDecodedFile
property.
The decoded data will be held in PartDecodedString
or otherwise saved in a temporary
file given by PartDecodedFile
when the user asks for the value of the respective
property.
Calling this method is equivalent to setting the Action
property
to mimeDecodeFromFile .
public void decodeFromString() throws IPWorksException
Message
denotes the real encoded message rather than a filename.
Calling this method is equivalent to setting the Action
property
to mimeDecodeFromString .
public void encodeToFile() throws IPWorksException
PartDecodedFile
or PartDecodedString
into a MIME message at Message
and MessageHeaders
using the
values optionally given in PartContentType
, PartContentTypeAttr
, PartEncoding
, PartName
, PartHeaders
. To encode several objects
into a MIME envelope, the user should first clear any old values left in
the Part- properties and then assign values for all the indices starting with 1.
The control will check for each index first the PartDecodedFile
and then PartDecodedString
for the data to encode.
The encoded message will be saved in the file pointed by Message
;
the message headers will be held by MessageHeaders
.
Calling this method is equivalent to setting the Action
property
to mimeEncodeToFile .
public void encodeToString() throws IPWorksException
Message
property rather than saved to a file.
Calling this method is equivalent to setting the Action
property
to mimeEncodeToString .
public void resetData() throws IPWorksException
Calling this method is equivalent to setting the Action
property
to mimeResetData .
public void addMimeEventListener(MimeEventListener l) throws java.util.TooManyListenersException
public void removeMimeEventListener(MimeEventListener l)
|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |