org.apache.james.core
Class MimeMessageUtil

java.lang.Object
  extended by org.apache.james.core.MimeMessageUtil

public class MimeMessageUtil
extends java.lang.Object

Utility class to provide optimized write methods for the various MimeMessage implementations.


Constructor Summary
MimeMessageUtil()
           
 
Method Summary
static long calculateMessageSize(javax.mail.internet.MimeMessage message)
          Calculate the size of the give mimeMessage
static void copyStream(java.io.InputStream in, java.io.OutputStream out)
          Convenience method to copy streams
static java.io.InputStream getHeadersInputStream(javax.mail.internet.MimeMessage message, java.lang.String[] ignoreList)
          Get an InputStream which holds all headers of the given MimeMessage
static long getMessageSize(javax.mail.internet.MimeMessage message)
          Return the full site of an mimeMessage
static void writeHeadersTo(java.util.Enumeration headers, java.io.OutputStream headerOs)
          Write the message headers to the given outputstream
static void writeMessageBodyTo(javax.mail.internet.MimeMessage message, java.io.OutputStream bodyOs)
          Write message body of given mimeessage to the given outputStream
static void writeTo(javax.mail.internet.MimeMessage message, java.io.OutputStream headerOs, java.io.OutputStream bodyOs)
          Convenience method to take any MimeMessage and write the headers and body to two different output streams
static void writeTo(javax.mail.internet.MimeMessage message, java.io.OutputStream headerOs, java.io.OutputStream bodyOs, java.lang.String[] ignoreList)
          Convenience method to take any MimeMessage and write the headers and body to two different output streams, with an ignore list
static void writeToInternal(javax.mail.internet.MimeMessage message, java.io.OutputStream headerOs, java.io.OutputStream bodyOs, java.lang.String[] ignoreList)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeMessageUtil

public MimeMessageUtil()
Method Detail

writeTo

public static void writeTo(javax.mail.internet.MimeMessage message,
                           java.io.OutputStream headerOs,
                           java.io.OutputStream bodyOs)
                    throws java.io.IOException,
                           javax.mail.MessagingException
Convenience method to take any MimeMessage and write the headers and body to two different output streams

Parameters:
message - the MimeMessage reading from
headerOs - the OutputStream writting the headers to
bodyOs - the OutputStream writting the body to
Throws:
java.io.IOException - get thrown if an IO Error detected while writing to the streams
javax.mail.MessagingException - get thrown if an error detected while reading the message

writeTo

public static void writeTo(javax.mail.internet.MimeMessage message,
                           java.io.OutputStream headerOs,
                           java.io.OutputStream bodyOs,
                           java.lang.String[] ignoreList)
                    throws java.io.IOException,
                           javax.mail.MessagingException
Convenience method to take any MimeMessage and write the headers and body to two different output streams, with an ignore list

Parameters:
message - the MimeMessage reading from
headerOs - the OutputStream writting the headers to
bodyOs - the OutputStream writting the body to
ignoreList - the String[] which contains headers which should be ignored
Throws:
java.io.IOException - get thrown if an IO Error detected while writing to the streams
javax.mail.MessagingException - get thrown if an error detected while reading the message

writeToInternal

public static void writeToInternal(javax.mail.internet.MimeMessage message,
                                   java.io.OutputStream headerOs,
                                   java.io.OutputStream bodyOs,
                                   java.lang.String[] ignoreList)
                            throws javax.mail.MessagingException,
                                   java.io.IOException,
                                   javax.activation.UnsupportedDataTypeException
Parameters:
message -
headerOs -
bodyOs -
ignoreList -
Throws:
javax.mail.MessagingException
java.io.IOException
javax.activation.UnsupportedDataTypeException

writeMessageBodyTo

public static void writeMessageBodyTo(javax.mail.internet.MimeMessage message,
                                      java.io.OutputStream bodyOs)
                               throws java.io.IOException,
                                      javax.activation.UnsupportedDataTypeException,
                                      javax.mail.MessagingException
Write message body of given mimeessage to the given outputStream

Parameters:
message - the MimeMessage used as input
bodyOs - the OutputStream to write the message body to
Throws:
java.io.IOException
javax.activation.UnsupportedDataTypeException
javax.mail.MessagingException

copyStream

public static void copyStream(java.io.InputStream in,
                              java.io.OutputStream out)
                       throws java.io.IOException
Convenience method to copy streams

Parameters:
in - the InputStream used as copy source
out - the OutputStram used as copy destination
Throws:
java.io.IOException

writeHeadersTo

public static void writeHeadersTo(java.util.Enumeration headers,
                                  java.io.OutputStream headerOs)
                           throws javax.mail.MessagingException
Write the message headers to the given outputstream

Parameters:
headers - the Enumeration which holds the headers
headerOs - the OutputStream to which the headers get written
Throws:
javax.mail.MessagingException

getHeadersInputStream

public static java.io.InputStream getHeadersInputStream(javax.mail.internet.MimeMessage message,
                                                        java.lang.String[] ignoreList)
                                                 throws javax.mail.MessagingException
Get an InputStream which holds all headers of the given MimeMessage

Parameters:
message - the MimeMessage used as source
ignoreList - the String[] which holds headers which should be ignored
Returns:
stream the InputStream which holds the headers
Throws:
javax.mail.MessagingException

getMessageSize

public static long getMessageSize(javax.mail.internet.MimeMessage message)
                           throws javax.mail.MessagingException
Return the full site of an mimeMessage

Returns:
size of full message including headers
Throws:
javax.mail.MessagingException - if a problem occours while computing the message size

calculateMessageSize

public static long calculateMessageSize(javax.mail.internet.MimeMessage message)
                                 throws javax.mail.MessagingException
Calculate the size of the give mimeMessage

Parameters:
message - the MimeMessage
Returns:
size the calculated size
Throws:
javax.mail.MessagingException - if a problem occours while calculate the message size


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.