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)
           
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)
           
static long getMessageSize(javax.mail.internet.MimeMessage message)
           
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)
           
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

Throws:
java.io.IOException
javax.mail.MessagingException

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

Throws:
java.io.IOException
javax.mail.MessagingException

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
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

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:
message -
headerOs -
ignoreList -
Throws:
javax.mail.MessagingException

getHeadersInputStream

public static java.io.InputStream getHeadersInputStream(javax.mail.internet.MimeMessage message,
                                                        java.lang.String[] ignoreList)
                                                 throws javax.mail.MessagingException
Parameters:
message -
ignoreList -
Returns:
Throws:
javax.mail.MessagingException

getMessageSize

public static long getMessageSize(javax.mail.internet.MimeMessage message)
                           throws javax.mail.MessagingException
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
Parameters:
message -
Returns:
the calculated size
Throws:
javax.mail.MessagingException


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