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.OutputStream
encodeStream(java.io.OutputStream out, java.lang.String encoding, boolean binaryBody)
private ByteSequence
getBoundary(ContentTypeField contentType)
private ContentTypeField
getContentType(Multipart multipart)
void
writeBody(Body body, java.io.OutputStream out)
Write the specifiedBody
to the specifiedOutputStream
.private void
writeBytes(ByteSequence byteSequence, java.io.OutputStream out)
void
writeEntity(Entity entity, java.io.OutputStream out)
Write the specifiedEntity
to the specifiedOutputStream
.void
writeField(Field field, java.io.OutputStream out)
Write the specifiedField
to the specifiedOutputStream
.void
writeHeader(Header header, java.io.OutputStream out)
Write the specifiedHeader
to the specifiedOutputStream
.void
writeMessage(Message message, java.io.OutputStream out)
Write the specifiedMessage
to the specifiedOutputStream
.void
writeMultipart(Multipart multipart, java.io.OutputStream out)
Write the specifiedMultipart
to 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 specifiedBody
to the specifiedOutputStream
.- Specified by:
writeBody
in interfaceMessageWriter
- Parameters:
body
- theBody
to 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 specifiedEntity
to the specifiedOutputStream
.- Specified by:
writeEntity
in interfaceMessageWriter
- Parameters:
entity
- theEntity
to 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 specifiedMessage
to the specifiedOutputStream
.- Specified by:
writeMessage
in interfaceMessageWriter
- Parameters:
message
- theMessage
to 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 specifiedMultipart
to the specifiedOutputStream
.- Specified by:
writeMultipart
in interfaceMessageWriter
- Parameters:
multipart
- theMultipart
to 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 specifiedField
to the specifiedOutputStream
.- Specified by:
writeField
in interfaceMessageWriter
- Parameters:
field
- theField
to 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 specifiedHeader
to the specifiedOutputStream
.- Specified by:
writeHeader
in interfaceMessageWriter
- Parameters:
header
- theHeader
to 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
-
-