org.umber.core.email
Class MimeManager

java.lang.Object
  extended byorg.umber.core.email.MimeManager

public class MimeManager
extends java.lang.Object

MIME content converter. Prepares Java objects for outgoing and incoming email.

Author:
jsheets

Constructor Summary
MimeManager()
          Creates a new instance of MimeManager.
 
Method Summary
 void addCustomConverter(IMimeConverter converter)
          Adds a custom MIME type converter.
 java.lang.Object convertIncoming(java.lang.String mimeType, java.lang.Object mimeObject)
          Convert an incoming email object into a more usable object for UmberEmail.getContents().
 java.lang.String convertOutgoing(java.lang.Object appObject)
          Converts an outgoing email object into a suitable outgoing format.
 IMimeConverter[] getCustomConverters()
          Retrieves an array of all custom converters.
 java.lang.String getMimeType(java.lang.Object content)
          Looks up the MIME type that corresponds to the content object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeManager

public MimeManager()
Creates a new instance of MimeManager.

Method Detail

addCustomConverter

public void addCustomConverter(IMimeConverter converter)
Adds a custom MIME type converter. Custom converters are evaluated in the opposite order the converters are added; thus, the most recently added converter will override earlier converters.

If a converter does not find a MIME type for the content object, it should return null so the other converters get a chance at the object.

Parameters:
converter - custom MIME type converter

getCustomConverters

public IMimeConverter[] getCustomConverters()
Retrieves an array of all custom converters.

Returns:
custom converters

getMimeType

public java.lang.String getMimeType(java.lang.Object content)
Looks up the MIME type that corresponds to the content object. If the object is not recognizable, returns "text/plain".

Parameters:
content - content object to find MIME type for
Returns:
MIME type

convertOutgoing

public java.lang.String convertOutgoing(java.lang.Object appObject)
                                 throws UmberEmailException
Converts an outgoing email object into a suitable outgoing format. For example, an outgoing Bellows Datum tree might be converted into a String.

Parameters:
appObject - Java object from UmberEmail.getContents()
Returns:
object to send in outgoing email
Throws:
UmberEmailException - if a fatal error occurs in the converter

convertIncoming

public java.lang.Object convertIncoming(java.lang.String mimeType,
                                        java.lang.Object mimeObject)
                                 throws UmberEmailException
Convert an incoming email object into a more usable object for UmberEmail.getContents(). For example, an incoming XML document of type "text/xml" might be converted into a Bellows Datum tree.

Parameters:
mimeType - MIME content type
mimeObject - Java object for UmberEmail.getContents()
Returns:
object to use in client application
Throws:
UmberEmailException - if a fatal error occurs in the converter