Package org.apache.james.mime4j.message
Class DefaultMessageBuilder
- java.lang.Object
-
- org.apache.james.mime4j.message.DefaultMessageBuilder
-
- All Implemented Interfaces:
MessageBuilder
public class DefaultMessageBuilder extends java.lang.Object implements MessageBuilder
Default implementation ofMessageBuilder
.
-
-
Field Summary
Fields Modifier and Type Field Description private BodyDescriptorBuilder
bodyDescBuilder
private BodyFactory
bodyFactory
private MimeConfig
config
private boolean
contentDecoding
private FieldParser<? extends ParsedField>
fieldParser
private boolean
flatMode
private MessageImplFactory
messageImplFactory
private DecodeMonitor
monitor
-
Constructor Summary
Constructors Constructor Description DefaultMessageBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Body
copy(Body body)
Returns a copy of the givenBody
that can be used (and modified) independently of the original.BodyPart
copy(Entity other)
Creates a newBodyPart
from the specifiedEntity
.Header
copy(Header other)
Creates a newHeader
from the specifiedHeader
.Message
copy(Message other)
Creates a newMessage
from the specifiedMessage
.Multipart
copy(Multipart other)
Creates a newMultipart
from the specifiedMultipart
.Header
newHeader()
Header
newHeader(Header source)
Message
newMessage()
Message
newMessage(Message source)
Message
newMessage(Message.Builder source)
private MessageImpl
newMessageImpl()
Multipart
newMultipart(java.lang.String subType)
Multipart
newMultipart(java.lang.String subType, NameValuePair... contentTypeParameters)
Multipart
newMultipart(Multipart source)
Multipart
newMultipart(MultipartBuilder source)
Header
parseHeader(java.io.InputStream is)
Message
parseMessage(java.io.InputStream is)
void
setBodyDescriptorBuilder(BodyDescriptorBuilder bodyDescBuilder)
void
setBodyFactory(BodyFactory bodyFactory)
void
setContentDecoding(boolean contentDecoding)
void
setDecodeMonitor(DecodeMonitor monitor)
void
setFieldParser(FieldParser<? extends ParsedField> fieldParser)
void
setFlatMode(boolean flatMode)
void
setMessageImplFactory(MessageImplFactory messageImplFactory)
void
setMimeEntityConfig(MimeConfig config)
-
-
-
Field Detail
-
fieldParser
private FieldParser<? extends ParsedField> fieldParser
-
messageImplFactory
private MessageImplFactory messageImplFactory
-
bodyFactory
private BodyFactory bodyFactory
-
config
private MimeConfig config
-
bodyDescBuilder
private BodyDescriptorBuilder bodyDescBuilder
-
contentDecoding
private boolean contentDecoding
-
flatMode
private boolean flatMode
-
monitor
private DecodeMonitor monitor
-
-
Method Detail
-
setFieldParser
public void setFieldParser(FieldParser<? extends ParsedField> fieldParser)
-
setMessageImplFactory
public void setMessageImplFactory(MessageImplFactory messageImplFactory)
-
setBodyFactory
public void setBodyFactory(BodyFactory bodyFactory)
-
setMimeEntityConfig
public void setMimeEntityConfig(MimeConfig config)
-
setBodyDescriptorBuilder
public void setBodyDescriptorBuilder(BodyDescriptorBuilder bodyDescBuilder)
-
setDecodeMonitor
public void setDecodeMonitor(DecodeMonitor monitor)
-
setContentDecoding
public void setContentDecoding(boolean contentDecoding)
-
setFlatMode
public void setFlatMode(boolean flatMode)
-
copy
public Header copy(Header other)
Creates a newHeader
from the specifiedHeader
. TheHeader
instance is initialized with a copy of the list ofField
s of the specifiedHeader
. TheField
objects are not copied because they are immutable and can safely be shared between headers.- Parameters:
other
- header to copy.
-
copy
public BodyPart copy(Entity other)
Creates a newBodyPart
from the specifiedEntity
. TheBodyPart
instance is initialized with copies of header and body of the specifiedEntity
. The parent entity of the new body part isnull
.- Parameters:
other
- body part to copy.- Throws:
java.lang.UnsupportedOperationException
- ifother
contains aSingleBody
that does not support thecopy()
operation.java.lang.IllegalArgumentException
- ifother
contains aBody
that is neither aMessage
,Multipart
orSingleBody
.
-
copy
public Multipart copy(Multipart other)
Creates a newMultipart
from the specifiedMultipart
. TheMultipart
instance is initialized with copies of preamble, epilogue, sub type and the list of body parts of the specifiedMultipart
. The parent entity of the new multipart isnull
.- Parameters:
other
- multipart to copy.- Throws:
java.lang.UnsupportedOperationException
- ifother
contains aSingleBody
that does not support thecopy()
operation.java.lang.IllegalArgumentException
- ifother
contains aBody
that is neither aMessage
,Multipart
orSingleBody
.
-
copy
public Body copy(Body body)
Returns a copy of the givenBody
that can be used (and modified) independently of the original. The copy should bedisposed of
when it is no longer needed.The
parent
of the returned copy isnull
, that is, the copy is detached from the parent entity of the original.- Parameters:
body
- body to copy.- Returns:
- a copy of the given body.
- Throws:
java.lang.UnsupportedOperationException
- ifbody
is an instance ofSingleBody
that does not support thecopy()
operation (or contains such aSingleBody
).java.lang.IllegalArgumentException
- ifbody
isnull
orbody
is aBody
that is neither aMessageImpl
,Multipart
orSingleBody
(or contains such aBody
).
-
copy
public Message copy(Message other)
Creates a newMessage
from the specifiedMessage
. TheMessage
instance is initialized with copies of header and body of the specifiedMessage
. The parent entity of the new message isnull
.- Parameters:
other
- message to copy.- Throws:
java.lang.UnsupportedOperationException
- ifother
contains aSingleBody
that does not support thecopy()
operation.java.lang.IllegalArgumentException
- ifother
contains aBody
that is neither aMessageImpl
,Multipart
orSingleBody
.
-
newHeader
public Header newHeader()
- Specified by:
newHeader
in interfaceMessageBuilder
-
newHeader
public Header newHeader(Header source)
- Specified by:
newHeader
in interfaceMessageBuilder
-
newMultipart
public Multipart newMultipart(java.lang.String subType)
- Specified by:
newMultipart
in interfaceMessageBuilder
-
newMultipart
public Multipart newMultipart(java.lang.String subType, NameValuePair... contentTypeParameters)
-
newMultipart
public Multipart newMultipart(Multipart source)
- Specified by:
newMultipart
in interfaceMessageBuilder
-
parseHeader
public Header parseHeader(java.io.InputStream is) throws java.io.IOException, MimeIOException
- Specified by:
parseHeader
in interfaceMessageBuilder
- Throws:
java.io.IOException
MimeIOException
-
newMessage
public Message newMessage()
- Specified by:
newMessage
in interfaceMessageBuilder
-
newMessage
public Message newMessage(Message source)
- Specified by:
newMessage
in interfaceMessageBuilder
-
parseMessage
public Message parseMessage(java.io.InputStream is) throws java.io.IOException, MimeIOException
- Specified by:
parseMessage
in interfaceMessageBuilder
- Throws:
java.io.IOException
MimeIOException
-
newMessageImpl
private MessageImpl newMessageImpl()
-
newMultipart
public Multipart newMultipart(MultipartBuilder source)
- Specified by:
newMultipart
in interfaceMessageBuilder
-
newMessage
public Message newMessage(Message.Builder source)
- Specified by:
newMessage
in interfaceMessageBuilder
-
-