|
IP*Works! V8 | ||||||||
| 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 formating of messages containing non-text, multipart or non 'US' formated 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 provided in Parts collection.
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 properties with message content type information,
and enter information about message parts into the Parts collection, which includes: part sizes,
part content types, part content type attributes, part content disposition, part content disposition attributes,
part encoding, part name, part filename, part headers, or part content (part decoded string or part decoded file)
for each decoded part.
Calling the DecodeFromString or DecodeFromFile to decode doesn't actually decode the message but only parses it.
The real decoding is done when the part content in the Parts collection is first accessed.
To encode data into a MIME message you should first assign values for each part to either part decoded string or part
decoded file in the Parts collection property, and optionally assign values to the other part attributes in the Parts collection. Assiging a value to the part decoded string or part decoded file through the Parts collection property,
fills out automatically the part headers into the Parts collection 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.
| Constructor Summary | |
Mime()
|
|
| Method Summary | |
void |
addMimeEventListener(ipworks.MimeEventListener l)
|
java.lang.String |
config(java.lang.String configurationString)
Sets or retrieves a beanconfiguration setting. |
void |
decodeFromFile()
Decode From File. |
void |
decodeFromStream(java.io.InputStream inputStream)
Decode From Stream. |
void |
decodeFromString()
Decode From String. |
void |
encodeToFile()
Encode To File. |
void |
encodeToStream(java.io.OutputStream outputStream)
Encode To Stream. |
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. |
HeaderList |
getMessageHeaders()
The headers of the MIME message. |
java.lang.String |
getMessageHeadersString()
String version of the MIME message headers. |
MIMEPartList |
getParts()
Contains information about all parts of a MIME message. |
void |
removeMimeEventListener(ipworks.MimeEventListener l)
|
void |
resetData()
Encode To String. |
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(HeaderList messageHeaders)
The headers of the MIME message. |
void |
setMessageHeadersString(java.lang.String messageHeadersString)
String version of the MIME message headers. |
void |
setParts(MIMEPartList parts)
Contains information about all parts of a MIME message. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 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 HeaderList 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 begining of the Message and
will fill out MessageHeaders property accordingly.
public void setMessageHeaders(HeaderList 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 begining of the Message and
will fill out MessageHeaders property accordingly.
IPWorksExceptionpublic java.lang.String getMessageHeadersString()
The component fills out MessageHeadersString upon encoding.
The user should use them as additional headers when emailing
the Message .
During decoding, if MessageHeadersString is empty the
bean will try to find the headers in the beginning of the Message and will fill out MessageHeadersString property
accordingly.
public void setMessageHeadersString(java.lang.String messageHeadersString)
throws IPWorksException
The component fills out MessageHeadersString upon encoding.
The user should use them as additional headers when emailing
the Message .
During decoding, if MessageHeadersString is empty the
bean will try to find the headers in the beginning of the Message and will fill out MessageHeadersString property
accordingly.
IPWorksExceptionpublic MIMEPartList getParts()
A MIME message consists of different parts, seperated by either a
user-specified or an auto-generated boundary. Each part has its
own set of headers which are contained in the Headers field.
The MIMEPARTS collection is filled out by the bean when a call
to either DecodeFromFile or DecodeFromString is made. However,
when the EncodeToFile or EncodeToString methods are called,
the bean encodes the data given in either DecodedFile or DecodedString into a MIME message.
This collection is indexed from 0 to Count - 1.
public void setParts(MIMEPartList parts)
throws IPWorksException
A MIME message consists of different parts, seperated by either a
user-specified or an auto-generated boundary. Each part has its
own set of headers which are contained in the Headers field.
The MIMEPARTS collection is filled out by the bean when a call
to either DecodeFromFile or DecodeFromString is made. However,
when the EncodeToFile or EncodeToString methods are called,
the bean encodes the data given in either DecodedFile or DecodedString into a MIME message.
This collection is indexed from 0 to Count - 1.
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 Parts collection
for each decoded part.
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.
IPWorksException
public void decodeFromStream(java.io.InputStream inputStream)
throws IPWorksException
Same as DecodeFromString, but now the MIME message is passed to this method as a stream.
Decodes the data given by the InputStream and optionally MessageHeaders and fills out the Parts collection.
Example (Decoding Mail Message)
MIMEControl.MessageHeaders = MailControl.MessageHeaders
MIMEControl.DecodeFromStream(InputStream)
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 Parts collection.
Example (Decoding Mail Message)
MIMEControl.MessageHeaders = MailControl.MessageHeaders
MIMEControl.Message = MailControl.MessageText
MIMEControl.DecodeFromString
IPWorksException
public void encodeToFile()
throws IPWorksException
Encode the data given in Parts collection (either decoded file or
decoded string) into a MIME message at Message and MessageHeaders using the values optionally given in Parts collection.
To encode several objects into a MIME envelope, the user should first clear any
old values left in the Parts collection.
The bean will check for each item in Parts collection (first decoded file
and then the decoded string) 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 .
Example (Encoding Data)
MIMEControl.ResetData()
MIMEControl.Parts.Add(new MIMEPart())
MIMEControl.Parts.Add(new MIMEPart())
MIMEControl.Parts[0].DecodedString = "This is plain text data"
MIMEControl.Parts[0].Encoding = peQuotedPrintable
MIMEControl.Parts[0].ContentType = "text/plain"
MIMEControl.Parts[1].DecodedFile = "C:\\filename.txt"
MIMEControl.Message = "temp.tmp"
MIMEControl.EncodeToFile()
IPWorksException
public void encodeToStream(java.io.OutputStream outputStream)
throws IPWorksException
Same as EncodeToString but the encoded data is written to a
stream instead of to the Message property.
Encode the data given in Parts collection into a MIME message.
The Message gets written to the specified OutputStream and MessageHeaders using the values optionally given in Parts collection. To encode several objects into a MIME envelope, the user
should first clear any old values left in the Parts collection
by calling ResetData .
The bean will check each item in Parts collection (first decoded file
and then decoded string) for the data to encode.
The encoded message will be written to the specified OutputStream , and
the message headers will be held by MessageHeaders .
Example (Encoding Data)
MIMEControl.ResetData()
MIMEControl.Parts.Add(new MIMEPart())
MIMEControl.Parts.Add(new MIMEPart())
MIMEControl.Parts[0].DecodedString = "This is plain text data"
MIMEControl.Parts[0].Encoding = peQuotedPrintable
MIMEControl.Parts[0].ContentType = "text/plain"
MIMEControl.Parts[1].DecodedFile = "C:\\filename.txt"
MIMEControl.EncodeToStream(OutputStream)
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 Parts collection into a MIME message.
The Message gets stored in Message and MessageHeaders using the
values optionally given in Parts collection. To encode several objects
into a MIME envelope, the user should first clear any old values left in
the Parts collection by calling ResetData .
The bean will check each item in Parts collection (first decoded file
and then decoded string) 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.Parts.Add(new MIMEPart())
MIMEControl.Parts.Add(new MIMEPart())
MIMEControl.Parts[0].DecodedString = "This is plain text data"
MIMEControl.Parts[0].Encoding = peQuotedPrintable
MIMEControl.Parts[0].ContentType = "text/plain"
MIMEControl.Parts[1].DecodedFile = "C:\\filename.txt"
MIMEControl.EncodeToString()
IPWorksException
public void resetData()
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 Parts collection into a MIME message.
The Message gets stored in Message and MessageHeaders using the
values optionally given in Parts collection. To encode several objects
into a MIME envelope, the user should first clear any old values left in
the Parts collection by calling ResetData .
The bean will check each item in Parts collection (first decoded file
and then decoded string) for the data to encode.
The encoded message will be stored in the Message property;
the message headers will be held by MessageHeaders .
IPWorksException
public void addMimeEventListener(ipworks.MimeEventListener l)
throws java.util.TooManyListenersException
java.util.TooManyListenersExceptionpublic void removeMimeEventListener(ipworks.MimeEventListener l)
|
IP*Works! V8 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||