org.apache.james.mime4j.message
Class DefaultMessageBuilder

java.lang.Object
  extended by org.apache.james.mime4j.message.DefaultMessageBuilder
All Implemented Interfaces:
MessageBuilder

public class DefaultMessageBuilder
extends java.lang.Object
implements MessageBuilder

Default implementation of MessageBuilder.


Constructor Summary
DefaultMessageBuilder()
           
 
Method Summary
 Body copy(Body body)
          Returns a copy of the given Body that can be used (and modified) independently of the original.
 BodyPart copy(Entity other)
          Creates a new BodyPart from the specified Entity.
 Header copy(Header other)
          Creates a new Header from the specified Header.
 Message copy(Message other)
          Creates a new Message from the specified Message.
 Multipart copy(Multipart other)
          Creates a new Multipart from the specified Multipart.
 Header newHeader()
           
 Header newHeader(Header source)
           
 Message newMessage()
           
 Message newMessage(Message source)
           
 Multipart newMultipart(Multipart source)
           
 Multipart newMultipart(java.lang.String subType)
           
 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 setMimeEntityConfig(MimeConfig config)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMessageBuilder

public DefaultMessageBuilder()
Method Detail

setFieldParser

public void setFieldParser(FieldParser<? extends ParsedField> fieldParser)

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 new Header from the specified Header. The Header instance is initialized with a copy of the list of Fields of the specified Header. The Field 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 new BodyPart from the specified Entity. The BodyPart instance is initialized with copies of header and body of the specified Entity. The parent entity of the new body part is null.

Parameters:
other - body part to copy.
Throws:
java.lang.UnsupportedOperationException - if other contains a SingleBody that does not support the copy() operation.
java.lang.IllegalArgumentException - if other contains a Body that is neither a Message, Multipart or SingleBody.

copy

public Multipart copy(Multipart other)
Creates a new Multipart from the specified Multipart. The Multipart instance is initialized with copies of preamble, epilogue, sub type and the list of body parts of the specified Multipart. The parent entity of the new multipart is null.

Parameters:
other - multipart to copy.
Throws:
java.lang.UnsupportedOperationException - if other contains a SingleBody that does not support the copy() operation.
java.lang.IllegalArgumentException - if other contains a Body that is neither a Message, Multipart or SingleBody.

copy

public Body copy(Body body)
Returns a copy of the given Body that can be used (and modified) independently of the original. The copy should be disposed of when it is no longer needed.

The parent of the returned copy is null, 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 - if body is an instance of SingleBody that does not support the copy() operation (or contains such a SingleBody).
java.lang.IllegalArgumentException - if body is null or body is a Body that is neither a MessageImpl, Multipart or SingleBody (or contains such a Body).

copy

public Message copy(Message other)
Creates a new Message from the specified Message. The Message instance is initialized with copies of header and body of the specified Message. The parent entity of the new message is null.

Parameters:
other - message to copy.
Throws:
java.lang.UnsupportedOperationException - if other contains a SingleBody that does not support the copy() operation.
java.lang.IllegalArgumentException - if other contains a Body that is neither a MessageImpl, Multipart or SingleBody.

newHeader

public Header newHeader()
Specified by:
newHeader in interface MessageBuilder

newHeader

public Header newHeader(Header source)
Specified by:
newHeader in interface MessageBuilder

newMultipart

public Multipart newMultipart(java.lang.String subType)
Specified by:
newMultipart in interface MessageBuilder

newMultipart

public Multipart newMultipart(Multipart source)
Specified by:
newMultipart in interface MessageBuilder

parseHeader

public Header parseHeader(java.io.InputStream is)
                   throws java.io.IOException,
                          MimeIOException
Specified by:
parseHeader in interface MessageBuilder
Throws:
java.io.IOException
MimeIOException

newMessage

public Message newMessage()
Specified by:
newMessage in interface MessageBuilder

newMessage

public Message newMessage(Message source)
Specified by:
newMessage in interface MessageBuilder

parseMessage

public Message parseMessage(java.io.InputStream is)
                     throws java.io.IOException,
                            MimeIOException
Specified by:
parseMessage in interface MessageBuilder
Throws:
java.io.IOException
MimeIOException


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.