Package org.apache.james.mime4j.message
Class DefaultMessageWriter
- java.lang.Object
-
- org.apache.james.mime4j.message.DefaultMessageWriter
-
- All Implemented Interfaces:
MessageWriter
public class DefaultMessageWriter extends java.lang.Object implements MessageWriter
Default implementation ofMessageWriter.
-
-
Constructor Summary
Constructors Constructor Description DefaultMessageWriter()Protected constructor prevents direct instantiation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static byte[]asBytes(Message message)protected java.io.OutputStreamencodeStream(java.io.OutputStream out, java.lang.String encoding, boolean binaryBody)private ByteSequencegetBoundary(ContentTypeField contentType)private ContentTypeFieldgetContentType(Multipart multipart)voidwriteBody(Body body, java.io.OutputStream out)Write the specifiedBodyto the specifiedOutputStream.private voidwriteBytes(ByteSequence byteSequence, java.io.OutputStream out)voidwriteEntity(Entity entity, java.io.OutputStream out)Write the specifiedEntityto the specifiedOutputStream.voidwriteField(Field field, java.io.OutputStream out)Write the specifiedFieldto the specifiedOutputStream.voidwriteHeader(Header header, java.io.OutputStream out)Write the specifiedHeaderto the specifiedOutputStream.voidwriteMessage(Message message, java.io.OutputStream out)Write the specifiedMessageto the specifiedOutputStream.voidwriteMultipart(Multipart multipart, java.io.OutputStream out)Write the specifiedMultipartto the specifiedOutputStream.
-
-
-
Method Detail
-
asBytes
public static byte[] asBytes(Message message) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBody
public void writeBody(Body body, java.io.OutputStream out) throws java.io.IOException
Write the specifiedBodyto the specifiedOutputStream.- Specified by:
writeBodyin interfaceMessageWriter- Parameters:
body- theBodyto write.out- the OutputStream to write to.- Throws:
java.io.IOException- if an I/O error occurs.
-
writeEntity
public void writeEntity(Entity entity, java.io.OutputStream out) throws java.io.IOException
Write the specifiedEntityto the specifiedOutputStream.- Specified by:
writeEntityin interfaceMessageWriter- Parameters:
entity- theEntityto write.out- the OutputStream to write to.- Throws:
java.io.IOException- if an I/O error occurs.
-
writeMessage
public void writeMessage(Message message, java.io.OutputStream out) throws java.io.IOException
Write the specifiedMessageto the specifiedOutputStream.- Specified by:
writeMessagein interfaceMessageWriter- Parameters:
message- theMessageto write.out- the OutputStream to write to.- Throws:
java.io.IOException- if an I/O error occurs.
-
writeMultipart
public void writeMultipart(Multipart multipart, java.io.OutputStream out) throws java.io.IOException
Write the specifiedMultipartto the specifiedOutputStream.- Specified by:
writeMultipartin interfaceMessageWriter- Parameters:
multipart- theMultipartto write.out- the OutputStream to write to.- Throws:
java.io.IOException- if an I/O error occurs.
-
writeField
public void writeField(Field field, java.io.OutputStream out) throws java.io.IOException
Write the specifiedFieldto the specifiedOutputStream.- Specified by:
writeFieldin interfaceMessageWriter- Parameters:
field- theFieldto write.out- the OutputStream to write to.- Throws:
java.io.IOException- if an I/O error occurs.
-
writeHeader
public void writeHeader(Header header, java.io.OutputStream out) throws java.io.IOException
Write the specifiedHeaderto the specifiedOutputStream.- Specified by:
writeHeaderin interfaceMessageWriter- Parameters:
header- theHeaderto write.out- the OutputStream to write to.- Throws:
java.io.IOException- if an I/O error occurs.
-
encodeStream
protected java.io.OutputStream encodeStream(java.io.OutputStream out, java.lang.String encoding, boolean binaryBody) throws java.io.IOException- Throws:
java.io.IOException
-
getContentType
private ContentTypeField getContentType(Multipart multipart)
-
getBoundary
private ByteSequence getBoundary(ContentTypeField contentType)
-
writeBytes
private void writeBytes(ByteSequence byteSequence, java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
-