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 BodyDescriptorBuilderbodyDescBuilderprivate BodyFactorybodyFactoryprivate MimeConfigconfigprivate booleancontentDecodingprivate FieldParser<? extends ParsedField>fieldParserprivate booleanflatModeprivate MessageImplFactorymessageImplFactoryprivate DecodeMonitormonitor
-
Constructor Summary
Constructors Constructor Description DefaultMessageBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Bodycopy(Body body)Returns a copy of the givenBodythat can be used (and modified) independently of the original.BodyPartcopy(Entity other)Creates a newBodyPartfrom the specifiedEntity.Headercopy(Header other)Creates a newHeaderfrom the specifiedHeader.Messagecopy(Message other)Creates a newMessagefrom the specifiedMessage.Multipartcopy(Multipart other)Creates a newMultipartfrom the specifiedMultipart.HeadernewHeader()HeadernewHeader(Header source)MessagenewMessage()MessagenewMessage(Message source)MessagenewMessage(Message.Builder source)private MessageImplnewMessageImpl()MultipartnewMultipart(java.lang.String subType)MultipartnewMultipart(java.lang.String subType, NameValuePair... contentTypeParameters)MultipartnewMultipart(Multipart source)MultipartnewMultipart(MultipartBuilder source)HeaderparseHeader(java.io.InputStream is)MessageparseMessage(java.io.InputStream is)voidsetBodyDescriptorBuilder(BodyDescriptorBuilder bodyDescBuilder)voidsetBodyFactory(BodyFactory bodyFactory)voidsetContentDecoding(boolean contentDecoding)voidsetDecodeMonitor(DecodeMonitor monitor)voidsetFieldParser(FieldParser<? extends ParsedField> fieldParser)voidsetFlatMode(boolean flatMode)voidsetMessageImplFactory(MessageImplFactory messageImplFactory)voidsetMimeEntityConfig(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 newHeaderfrom the specifiedHeader. TheHeaderinstance is initialized with a copy of the list ofFields of the specifiedHeader. TheFieldobjects 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 newBodyPartfrom the specifiedEntity. TheBodyPartinstance 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- ifothercontains aSingleBodythat does not support thecopy()operation.java.lang.IllegalArgumentException- ifothercontains aBodythat is neither aMessage,MultipartorSingleBody.
-
copy
public Multipart copy(Multipart other)
Creates a newMultipartfrom the specifiedMultipart. TheMultipartinstance 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- ifothercontains aSingleBodythat does not support thecopy()operation.java.lang.IllegalArgumentException- ifothercontains aBodythat is neither aMessage,MultipartorSingleBody.
-
copy
public Body copy(Body body)
Returns a copy of the givenBodythat can be used (and modified) independently of the original. The copy should bedisposed ofwhen it is no longer needed.The
parentof 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- ifbodyis an instance ofSingleBodythat does not support thecopy()operation (or contains such aSingleBody).java.lang.IllegalArgumentException- ifbodyisnullorbodyis aBodythat is neither aMessageImpl,MultipartorSingleBody(or contains such aBody).
-
copy
public Message copy(Message other)
Creates a newMessagefrom the specifiedMessage. TheMessageinstance 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- ifothercontains aSingleBodythat does not support thecopy()operation.java.lang.IllegalArgumentException- ifothercontains aBodythat is neither aMessageImpl,MultipartorSingleBody.
-
newHeader
public Header newHeader()
- Specified by:
newHeaderin interfaceMessageBuilder
-
newHeader
public Header newHeader(Header source)
- Specified by:
newHeaderin interfaceMessageBuilder
-
newMultipart
public Multipart newMultipart(java.lang.String subType)
- Specified by:
newMultipartin interfaceMessageBuilder
-
newMultipart
public Multipart newMultipart(java.lang.String subType, NameValuePair... contentTypeParameters)
-
newMultipart
public Multipart newMultipart(Multipart source)
- Specified by:
newMultipartin interfaceMessageBuilder
-
parseHeader
public Header parseHeader(java.io.InputStream is) throws java.io.IOException, MimeIOException
- Specified by:
parseHeaderin interfaceMessageBuilder- Throws:
java.io.IOExceptionMimeIOException
-
newMessage
public Message newMessage()
- Specified by:
newMessagein interfaceMessageBuilder
-
newMessage
public Message newMessage(Message source)
- Specified by:
newMessagein interfaceMessageBuilder
-
parseMessage
public Message parseMessage(java.io.InputStream is) throws java.io.IOException, MimeIOException
- Specified by:
parseMessagein interfaceMessageBuilder- Throws:
java.io.IOExceptionMimeIOException
-
newMessageImpl
private MessageImpl newMessageImpl()
-
newMultipart
public Multipart newMultipart(MultipartBuilder source)
- Specified by:
newMultipartin interfaceMessageBuilder
-
newMessage
public Message newMessage(Message.Builder source)
- Specified by:
newMessagein interfaceMessageBuilder
-
-