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 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 OutputStream
encodeStream(OutputStream out, String encoding, boolean binaryBody)
void
writeBody(Body body, OutputStream out)
Write the specifiedBody
to the specifiedOutputStream
.void
writeEntity(Entity entity, OutputStream out)
Write the specifiedEntity
to the specifiedOutputStream
.void
writeField(Field field, OutputStream out)
Write the specifiedField
to the specifiedOutputStream
.void
writeHeader(Header header, OutputStream out)
Write the specifiedHeader
to the specifiedOutputStream
.void
writeMessage(Message message, OutputStream out)
Write the specifiedMessage
to the specifiedOutputStream
.void
writeMultipart(Multipart multipart, OutputStream out)
Write the specifiedMultipart
to the specifiedOutputStream
.
-
-
-
Method Detail
-
asBytes
public static byte[] asBytes(Message message) throws IOException
- Throws:
IOException
-
writeBody
public void writeBody(Body body, OutputStream out) throws IOException
Write the specifiedBody
to the specifiedOutputStream
.- Specified by:
writeBody
in interfaceMessageWriter
- Parameters:
body
- theBody
to write.out
- the OutputStream to write to.- Throws:
IOException
- if an I/O error occurs.
-
writeEntity
public void writeEntity(Entity entity, OutputStream out) throws IOException
Write the specifiedEntity
to the specifiedOutputStream
.- Specified by:
writeEntity
in interfaceMessageWriter
- Parameters:
entity
- theEntity
to write.out
- the OutputStream to write to.- Throws:
IOException
- if an I/O error occurs.
-
writeMessage
public void writeMessage(Message message, OutputStream out) throws IOException
Write the specifiedMessage
to the specifiedOutputStream
.- Specified by:
writeMessage
in interfaceMessageWriter
- Parameters:
message
- theMessage
to write.out
- the OutputStream to write to.- Throws:
IOException
- if an I/O error occurs.
-
writeMultipart
public void writeMultipart(Multipart multipart, OutputStream out) throws IOException
Write the specifiedMultipart
to the specifiedOutputStream
.- Specified by:
writeMultipart
in interfaceMessageWriter
- Parameters:
multipart
- theMultipart
to write.out
- the OutputStream to write to.- Throws:
IOException
- if an I/O error occurs.
-
writeField
public void writeField(Field field, OutputStream out) throws IOException
Write the specifiedField
to the specifiedOutputStream
.- Specified by:
writeField
in interfaceMessageWriter
- Parameters:
field
- theField
to write.out
- the OutputStream to write to.- Throws:
IOException
- if an I/O error occurs.
-
writeHeader
public void writeHeader(Header header, OutputStream out) throws IOException
Write the specifiedHeader
to the specifiedOutputStream
.- Specified by:
writeHeader
in interfaceMessageWriter
- Parameters:
header
- theHeader
to write.out
- the OutputStream to write to.- Throws:
IOException
- if an I/O error occurs.
-
encodeStream
protected OutputStream encodeStream(OutputStream out, String encoding, boolean binaryBody) throws IOException
- Throws:
IOException
-
-