|
IP*Works! V6 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--ipworks.Mime
The MIME bean 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 formatting of messages containing non-text, multipart or non 'US' formatted text.
The bean 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 into the MessageHeaders property
and the message body or the filename holding it into the Message property.
Calling DecodeFromFile or DecodeFromString directs the bean 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 DecodeFromString or DecodeFromFile 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. Assigning a value to the PartDecodedString or PartDecodedFile properties fills out automatically the PartHeaders property
for the respective part. Calling EncodeToFile or EncodeToString directs the bean 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 |
pe7Bit
|
static int |
pe8Bit
|
static int |
peBase64
|
static int |
peBinary
|
static int |
peQuotedPrintable
|
| Constructor Summary | |
Mime()
|
|
| Method Summary | |
void |
addMimeEventListener(MimeEventListener l)
|
java.lang.String |
config(java.lang.String configurationString)
Sets or retrieves a beanconfiguration setting. |
void |
decodeFromFile()
Decode From File. |
void |
decodeFromString()
Decode From String. |
void |
encodeToFile()
Encode To File. |
void |
encodeToString()
Encode To String. |
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()
Contains the encoded message text or a path to a file which contains the encoded message text. |
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 id 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 |
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)
Contains the encoded message text or a path to a file which contains the encoded message text. |
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 id 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 pe7Bit
public static final int peQuotedPrintable
public static final int peBase64
public static final int pe8Bit
public static final int peBinary
| Constructor Detail |
public Mime()
| Method Detail |
public java.lang.String getBoundary()
The bean will automatically generate a random boundary value during encoding if no value is given. During decoding this property is filled with the boundary from the actual MIME message.
The bean will truncate any string longer than 80 bytes
if assigned to Boundary .
public void setBoundary(java.lang.String boundary)
throws IPWorksException
The bean will automatically generate a random boundary value during encoding if no value is given. During decoding this property is filled with the boundary from the actual MIME message.
The bean will truncate any string longer than 80 bytes
if assigned to Boundary .
IPWorksExceptionpublic java.lang.String getContentType()
The bean filters it out from the 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
The bean filters it out from the 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.
IPWorksExceptionpublic java.lang.String getContentTypeAttr()
The ContentTypeAttr property contains content-type attributes such
as "filename", "boundary", "charset", etc..
public void setContentTypeAttr(java.lang.String contentTypeAttr)
throws IPWorksException
The ContentTypeAttr property contains content-type attributes such
as "filename", "boundary", "charset", etc..
IPWorksExceptionpublic byte[] getMessage()
The bean fills out 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
The bean fills out 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.
IPWorksExceptionpublic java.lang.String getMessageHeaders()
The bean fills out MessageHeaders upon encoding. The user should
use them as additional headers when emailing the Message .
During decoding, if MessageHeaders is empty the bean will
try to find the headers in the beginning of the Message and
will fill out MessageHeaders property accordingly.
public void setMessageHeaders(java.lang.String messageHeaders)
throws IPWorksException
The bean fills out MessageHeaders upon encoding. The user should
use them as additional headers when emailing the Message .
During decoding, if MessageHeaders is empty the bean will
try to find the headers in the beginning of the Message and
will fill out MessageHeaders property accordingly.
IPWorksException
public java.lang.String getPartContentDisposition(int partIdx)
throws IPWorksException
PartCount -1.
This value is used in the Content-Disposition header. Typical values include
"form-data", "attachment" etc. The bean fills it out each time
the PartDecodedFile property is changed. Changing PartContentDisposition recalculates the PartHeaders property as well.
A valid PartIdx is 0 to PartCount -1.
IPWorksException
public void setPartContentDisposition(int partIdx,
java.lang.String partContentDisposition)
throws IPWorksException
PartCount -1.
This value is used in the Content-Disposition header. Typical values include
"form-data", "attachment" etc. The bean fills it out each time
the PartDecodedFile property is changed. Changing PartContentDisposition recalculates the PartHeaders property as well.
A valid PartIdx is 0 to PartCount -1.
IPWorksException
public java.lang.String getPartContentDispositionAttr(int partIdx)
throws IPWorksException
PartCount -1.
Typical values for 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.
IPWorksException
public void setPartContentDispositionAttr(int partIdx,
java.lang.String partContentDispositionAttr)
throws IPWorksException
PartCount -1.
Typical values for 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.
IPWorksException
public java.lang.String getPartContentId(int partIdx)
throws IPWorksException
PartCount -1.
This value is used in the Content-Id header. The bean fills
it out each time
the PartDecodedFile property is changed. Changing PartContentId recalculates the PartHeaders property as well.
A valid PartIdx is 0 to PartCount -1.
IPWorksException
public void setPartContentId(int partIdx,
java.lang.String partContentId)
throws IPWorksException
PartCount -1.
This value is used in the Content-Id header. The bean fills
it out each time
the PartDecodedFile property is changed. Changing PartContentId recalculates the PartHeaders property as well.
A valid PartIdx is 0 to PartCount -1.
IPWorksException
public java.lang.String getPartContentType(int partIdx)
throws IPWorksException
PartCount -1.
This value is used in the Content-Type header. Typical values include
"image/gif", "text/plain" etc. The bean fills it out each time
the PartDecodedFile property is changed. Changing PartContentType recalculates the PartHeaders property as well.
A valid PartIdx is 0 to PartCount -1.
IPWorksException
public void setPartContentType(int partIdx,
java.lang.String partContentType)
throws IPWorksException
PartCount -1.
This value is used in the Content-Type header. Typical values include
"image/gif", "text/plain" etc. The bean fills it out each time
the PartDecodedFile property is changed. Changing PartContentType recalculates the PartHeaders property as well.
A valid PartIdx is 0 to PartCount -1.
IPWorksException
public java.lang.String getPartContentTypeAttr(int partIdx)
throws IPWorksException
PartCount -1.
Setting this property recalculates the PartHeaders property.
A valid PartIdx is 0 to PartCount -1.
IPWorksException
public void setPartContentTypeAttr(int partIdx,
java.lang.String partContentTypeAttr)
throws IPWorksException
PartCount -1.
Setting this property recalculates the PartHeaders property.
A valid PartIdx is 0 to PartCount -1.
IPWorksExceptionpublic int getPartCount()
The bean fills out 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
bean to encode.
public void setPartCount(int partCount)
throws IPWorksException
The bean fills out 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
bean to encode.
IPWorksException
public java.lang.String getPartDecodedFile(int partIdx)
throws IPWorksException
PartCount -1.
Accessing PartDecodedFile for the first time after calling the DecodeFromString or DecodeFromFile method, directs the bean 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.
IPWorksException
public void setPartDecodedFile(int partIdx,
java.lang.String partDecodedFile)
throws IPWorksException
PartCount -1.
Accessing PartDecodedFile for the first time after calling the DecodeFromString or DecodeFromFile method, directs the bean 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.
IPWorksException
public byte[] getPartDecodedString(int partIdx)
throws IPWorksException
PartCount -1.
The bean decodes the actual part of 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 bean checks during encoding first PartDecodedFile :
if it is empty then the bean uses the value of PartDecodedString .
A valid PartIdx is 0 to PartCount -1.
IPWorksException
public void setPartDecodedString(int partIdx,
byte[] partDecodedString)
throws IPWorksException
PartCount -1.
The bean decodes the actual part of 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 bean checks during encoding first PartDecodedFile :
if it is empty then the bean uses the value of PartDecodedString .
A valid PartIdx is 0 to PartCount -1.
IPWorksException
public int getPartEncoding(int partIdx)
throws IPWorksException
PartCount -1.
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:
IPWorksException
public void setPartEncoding(int partIdx,
int partEncoding)
throws IPWorksException
PartCount -1.
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:
IPWorksException
public java.lang.String getPartFilename(int partIdx)
throws IPWorksException
Changing the value of PartDecodedFile sets automatically the PartFilename and consequently the PartHeaders property for
the same PartIdx .
A valid PartIdx is 0 to PartCount -1.
IPWorksException
public void setPartFilename(int partIdx,
java.lang.String partFilename)
throws IPWorksException
Changing the value of PartDecodedFile sets automatically the PartFilename and consequently the PartHeaders property for
the same PartIdx .
A valid PartIdx is 0 to PartCount -1.
IPWorksException
public java.lang.String getPartHeaders(int partIdx)
throws IPWorksException
PartCount -1.
The bean fills out 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.
IPWorksException
public void setPartHeaders(int partIdx,
java.lang.String partHeaders)
throws IPWorksException
PartCount -1.
The bean fills out 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.
IPWorksException
public java.lang.String getPartName(int partIdx)
throws IPWorksException
Changing the value of PartDecodedFile sets automatically the PartName and consequently the PartHeaders property for
the same PartIdx .
A valid PartIdx is 0 to PartCount -1.
IPWorksException
public void setPartName(int partIdx,
java.lang.String partName)
throws IPWorksException
Changing the value of PartDecodedFile sets automatically the PartName and consequently the PartHeaders property for
the same PartIdx .
A valid PartIdx is 0 to PartCount -1.
IPWorksException
public int getPartSize(int partIdx)
throws IPWorksException
PartDecodedFile or PartDecodedString .
If a non empty value is assigned to PartDecodedFile then bean fills out PartSize of the same PartIdx with the file size or an error occurs
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.
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 decodeFromFile()
throws IPWorksException
Decodes the data file given in 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.
Example (Decoding From File)
MIMEControl.Message = "C:\\filename.txt"
MIMEControl.DecodeFromFile
Here, C:\\filename.txt must contain the MIME headers and body. If not, the MessageHeaders property must also be set to the appropriate MIME headers.
If the Encoded data is file data,the decoded file(s) will be given in PartDecodedFile .
Otherwise, the decoded data will be in the PartDecodedString property.
IPWorksException
public void decodeFromString()
throws IPWorksException
Same as DecodeFromFile, but now
the Message denotes the real encoded message rather than a filename.
Decodes the data given in 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.
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.
Example (Decoding Mail Message)
MIMEControl.MessageHeaders = MailControl.MessageHeaders
MIMEControl.Message = MailControl.MessageText
MIMEControl.DecodeFromString If the Encoded data is file data,the decoded file(s) will be given in PartDecodedFile .
Otherwise, the decoded data will be in the PartDecodedString property.
IPWorksException
public void encodeToFile()
throws IPWorksException
Encode the data given in either 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 0.
The bean 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 to by Message ;
the message headers will be held by MessageHeaders .
NOTE: To include the headers, set theIncludeHeadersconfig property to true.
Example (Encoding Data)
MIMEControl.ResetData()
MIMEControl.PartCount = 2
MIMEControl.PartDecodedString(0) = "This is plain text data"
MIMEControl.PartEncoding(0) = peQuotedPrintable
MIMEControl.PartContentType(0) = "text/plain"
MIMEControl.PartDecodedFile(1) = "C:\\filename.txt"
MIMEControl.Message = "temp.tmp"
MIMEControl.EncodeToFile()
IPWorksException
public void encodeToString()
throws IPWorksException
Same as EncodeToFile but the encoded data is held in the Message property rather than saved to a file.
Encode the data given in either PartDecodedFile or PartDecodedString into a MIME message. The Message gets stored in 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 by calling ResetData and then assign values for
all the indices starting with 0.
The bean will check for each index first the PartDecodedFile and then PartDecodedString for the data to encode.
The encoded message will be stored in the Message property;
the message headers will be held by MessageHeaders .
Example (Encoding Data)
MIMEControl.ResetData()
MIMEControl.PartCount = 2
MIMEControl.PartDecodedString(0) = "This is plain text data"
MIMEControl.PartEncoding(0) = peQuotedPrintable
MIMEControl.PartContentType(0) = "text/plain"
MIMEControl.PartDecodedFile(1) = "C:\\filename.txt"
MIMEControl.EncodeToString()
IPWorksException
public void resetData()
throws IPWorksException
Resets the values of all headers and Part- properties. It is an easy way to reset the bean's properties before starting to populate the Part- properties with new values.
IPWorksException
public void addMimeEventListener(MimeEventListener l)
throws java.util.TooManyListenersException
java.util.TooManyListenersExceptionpublic void removeMimeEventListener(MimeEventListener l)
|
IP*Works! V6 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||