to.etc.smtp
Class MimeWriter

java.lang.Object
  extended by to.etc.smtp.MimeWriter

public class MimeWriter
extends java.lang.Object

Write MIME messages. Allows embedding MIME bodies.

Author:
Frits Jalvingh Created on Jan 24, 2010

Constructor Summary
protected MimeWriter(java.io.OutputStream os)
           
 
Method Summary
 void close()
          Write the final boundary terminating the mime body.
static MimeWriter createMimeWriter(java.io.OutputStream os, java.lang.String contentType, java.lang.String rest)
           
 MimeWriter createSubMime(java.lang.String contenttype, java.lang.String rest)
          Create a MIME part in THIS version that is a full MIME compound document itself.
protected  byte[] getBoundary()
           
protected  java.lang.String getBoundaryString()
           
 void partHeader(java.lang.String name, java.lang.String value)
           
 void partStart(boolean base64, java.lang.String contenttype, java.lang.String rest)
           
 java.io.OutputStream partStream()
          Returns the content stream for the current part.
 java.io.Writer partWriter(java.lang.String encoding)
          Get a writer which allows writing content to the data in the appropriate format and encoding.
protected  void rawHeader(java.lang.String name, java.lang.String value)
           
 void write(byte[] data)
           
 void write(byte[] data, int off, int len)
          Write the specified data TO this writer's output.
 void write(java.lang.String s)
          Writes a string in the current encoding.
 void writeBody(java.lang.String contenttype, java.lang.String trailer)
           
protected  void writeCRLF()
           
protected  void writeOpenBoundary()
          Write a boundary segment for a 'next' part.
 void writeVersion()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeWriter

protected MimeWriter(java.io.OutputStream os)
Method Detail

getBoundary

protected byte[] getBoundary()

getBoundaryString

protected java.lang.String getBoundaryString()

write

public void write(byte[] data,
                  int off,
                  int len)
           throws java.io.IOException
Write the specified data TO this writer's output.

Parameters:
data -
off -
len -
Throws:
java.io.IOException

write

public final void write(byte[] data)
                 throws java.io.IOException
Throws:
java.io.IOException

write

public void write(java.lang.String s)
           throws java.io.IOException
Writes a string in the current encoding.

Parameters:
s -
Throws:
java.io.IOException

rawHeader

protected void rawHeader(java.lang.String name,
                         java.lang.String value)
                  throws java.io.IOException
Throws:
java.io.IOException

writeOpenBoundary

protected void writeOpenBoundary()
                          throws java.io.IOException
Write a boundary segment for a 'next' part.

Throws:
java.io.IOException

writeCRLF

protected void writeCRLF()
                  throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Write the final boundary terminating the mime body.

Throws:
java.io.IOException

writeVersion

public void writeVersion()
                  throws java.io.IOException
Throws:
java.io.IOException

writeBody

public void writeBody(java.lang.String contenttype,
                      java.lang.String trailer)
               throws java.io.IOException
Throws:
java.io.IOException

createMimeWriter

public static MimeWriter createMimeWriter(java.io.OutputStream os,
                                          java.lang.String contentType,
                                          java.lang.String rest)
                                   throws java.io.IOException
Throws:
java.io.IOException

partStart

public void partStart(boolean base64,
                      java.lang.String contenttype,
                      java.lang.String rest)
               throws java.io.IOException
Throws:
java.io.IOException

partHeader

public void partHeader(java.lang.String name,
                       java.lang.String value)
                throws java.io.IOException
Throws:
java.io.IOException

partStream

public java.io.OutputStream partStream()
                                throws java.io.IOException
Returns the content stream for the current part.

Returns:
Throws:
java.io.IOException

partWriter

public java.io.Writer partWriter(java.lang.String encoding)
                          throws java.io.IOException
Get a writer which allows writing content to the data in the appropriate format and encoding.

Returns:
Throws:
java.io.IOException

createSubMime

public MimeWriter createSubMime(java.lang.String contenttype,
                                java.lang.String rest)
                         throws java.io.IOException
Create a MIME part in THIS version that is a full MIME compound document itself. This creates the boundary header and the initial MIME headers.

Returns:
Throws:
java.io.IOException