|
IP*Works! V9 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectipworks.Mime
public class 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 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
. Assigning a value to the part decoded string or part decoded file through the Parts
collection
,
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()
Creates an instance of Mime Bean. |
|
Mime(java.lang.String runtimeLicense)
Creates an instance of Mime Bean with specified run-time license. |
Method Summary | |
---|---|
void |
addMimeEventListener(MimeEventListener l)
|
java.lang.String |
config(java.lang.String configurationString)
Sets or retrieves a configuration setting. |
void |
decodeFromFile()
Decodes from file. |
void |
decodeFromStream(java.io.InputStream inputStream)
Decodes from stream. |
void |
decodeFromString()
Decodes from string. |
void |
encodeToFile()
Encodes to file. |
void |
encodeToStream(java.io.OutputStream outputStream)
Encodes to stream. |
void |
encodeToString()
Encodes 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(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 |
setMessageHeadersString(java.lang.String messageHeadersString)
String version of the MIME message headers. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Mime()
public Mime(java.lang.String runtimeLicense)
Method Detail |
---|
public java.lang.String getBoundary()
This property contains the boundary separating the MIME parts and has a maximum length of 80 bytes. 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
This property contains the boundary separating the MIME parts and has a maximum length of 80 bytes. 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
.
IPWorksException
public java.lang.String getContentType()
This property contains the value of the content-type header of the message which was encoded/decoded. 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 this property.
public void setContentType(java.lang.String contentType) throws IPWorksException
This property contains the value of the content-type header of the message which was encoded/decoded. 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 this property.
IPWorksException
public java.lang.String getContentTypeAttr()
This property contains content-type attributes such as "filename", "boundary", "charset", etc.
public void setContentTypeAttr(java.lang.String contentTypeAttr) throws IPWorksException
This property contains content-type attributes such as "filename", "boundary", "charset", etc.
IPWorksException
public byte[] getMessage()
This property contains the encoded message text or a path to a file which contains the encoded message text. The bean fills out this property with the message
body and MessageHeaders
during encoding. The user may assign
both the headers and the body to this property and leave MessageHeaders
empty before decoding.
public void setMessage(byte[] message) throws IPWorksException
This property contains the encoded message text or a path to a file which contains the encoded message text. The bean fills out this property with the message
body and MessageHeaders
during encoding. The user may assign
both the headers and the body to this property and leave MessageHeaders
empty before decoding.
IPWorksException
public HeaderList getMessageHeaders()
This property contains the headers of the MIME message. The bean fills out this property upon encoding. The user should
use them as additional headers when emailing the Message
.
During decoding, if this property is empty the bean will
try to find the headers in the beginning of the Message
and
will fill out this property accordingly.
public java.lang.String getMessageHeadersString()
The component fills out MessageHeadersString
upon encoding.
The user should use them as additional headers when emailing
the Message
.
This property contains a string version of the MIME message headers.
During decoding, if this property is empty the
bean will try to find the headers in the beginning of the Message
and will fill out this 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
.
This property contains a string version of the MIME message headers.
During decoding, if this property is empty the
bean will try to find the headers in the beginning of the Message
and will fill out this property
accordingly.
IPWorksException
public MIMEPartList getParts()
This property contains information about all parts of a MIME message.
A MIME message consists of different parts, separated 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 size - 1.
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 retrieve configuration settings
for 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.
The bean accepts one or more of the following configuration settings .
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.
EncodeToFile
or EncodeToString
are called. If false, only the message will be
encoded.The default value for IncludeHeaders
is false.
MessageHeaders
. If the header is not present during decoding, the component
throws an exception. This config is false by default.
IPWorksException
public void decodeFromFile() throws IPWorksException
This method 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
This method decodes from stream. Same as DecodeFromString, but now the MIME message is passed to this method as a stream.
This method decodes the data given by the InputStream and optionally MessageHeaders
and fills out the Parts
collection
.
Example (Decoding Mail Message)
MIMEControl.MessageHeaders.AddRange(MailControl.MessageHeaders)
MIMEControl.DecodeFromStream(InputStream)
IPWorksException
public void decodeFromString() throws IPWorksException
This method decodes from string. Same as DecodeFromFile, but now the Message
denotes the real
encoded message rather than a filename.
This method decodes the data given in Message
and optionally MessageHeaders
and fills out the Parts
collection
.
Example (Decoding Mail Message)
MIMEControl.MessageHeaders.AddRange(MailControl.MessageHeaders)
MIMEControl.Message = MailControl.MessageText
MIMEControl.DecodeFromString
IPWorksException
public void encodeToFile() throws IPWorksException
This method encodes 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
This method encodes to stream. Same as EncodeToString
but the encoded data is written to a
stream instead of to the Message
property.
This method encodes 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
This method encodes to string. Same as EncodeToFile
but the encoded data is held in the Message
property rather than saved to a file.
This method encodes 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
This method 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.TooManyListenersException
public void removeMimeEventListener(MimeEventListener l)
|
IP*Works! V9 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |