IP*Works! V8

ipworks
Class Mime

java.lang.Object
  |
  +--ipworks.Mime

public class Mime
extends java.lang.Object

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

Mime

public Mime()
Method Detail

getBoundary

public java.lang.String getBoundary()
The boundary separating the MIME parts. 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 .


setBoundary

public void setBoundary(java.lang.String boundary)
                 throws IPWorksException
The boundary separating the MIME parts. 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

getContentType

public java.lang.String getContentType()
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 the ContentTypeAttr property.


setContentType

public void setContentType(java.lang.String contentType)
                    throws IPWorksException
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 the ContentTypeAttr property.

IPWorksException

getContentTypeAttr

public java.lang.String getContentTypeAttr()
The attributes for content-type header of the message which was encoded/decoded.

The ContentTypeAttr property contains content-type attributes such as "filename", "boundary", "charset", etc..


setContentTypeAttr

public void setContentTypeAttr(java.lang.String contentTypeAttr)
                        throws IPWorksException
The attributes for content-type header of the message which was encoded/decoded.

The ContentTypeAttr property contains content-type attributes such as "filename", "boundary", "charset", etc..

IPWorksException

getMessage

public byte[] getMessage()
Contains the encoded message text or a path to a file which contains the encoded message text.

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.


setMessage

public void setMessage(byte[] message)
                throws IPWorksException
Contains the encoded message text or a path to a file which contains the encoded message text.

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.

IPWorksException

getMessageHeaders

public HeaderList getMessageHeaders()
The headers of the MIME message.

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.


setMessageHeaders

public void setMessageHeaders(HeaderList messageHeaders)
                       throws IPWorksException
The headers of the MIME message.

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.

IPWorksException

getMessageHeadersString

public java.lang.String getMessageHeadersString()
String version of the MIME message headers.

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.


setMessageHeadersString

public void setMessageHeadersString(java.lang.String messageHeadersString)
                             throws IPWorksException
String version of the MIME message headers.

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.

IPWorksException

getParts

public MIMEPartList getParts()
Contains information about all parts of a MIME message.

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.


setParts

public void setParts(MIMEPartList parts)
              throws IPWorksException
Contains information about all parts of a MIME message.

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

config

public java.lang.String config(java.lang.String configurationString)
                        throws IPWorksException
Sets or retrieves a beanconfiguration setting.

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

decodeFromFile

public void decodeFromFile()
                    throws IPWorksException
Decode From File.

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

decodeFromStream

public void decodeFromStream(java.io.InputStream inputStream)
                      throws IPWorksException
Decode From Stream.

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

decodeFromString

public void decodeFromString()
                      throws IPWorksException
Decode From String.

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

encodeToFile

public void encodeToFile()
                  throws IPWorksException
Encode To File.

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

encodeToStream

public void encodeToStream(java.io.OutputStream outputStream)
                    throws IPWorksException
Encode To Stream.

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

encodeToString

public void encodeToString()
                    throws IPWorksException
Encode To String.

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

resetData

public void resetData()
               throws IPWorksException
Encode To String.

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

addMimeEventListener

public void addMimeEventListener(ipworks.MimeEventListener l)
                          throws java.util.TooManyListenersException
java.util.TooManyListenersException

removeMimeEventListener

public void removeMimeEventListener(ipworks.MimeEventListener l)

IP*Works! V8

Copyright (c) 2007 /n software inc. - All rights reserved.