Package org.apache.james.mime4j.message
Class BodyPartBuilder
- java.lang.Object
-
- org.apache.james.mime4j.internal.AbstractEntityBuilder
-
- org.apache.james.mime4j.message.BodyPartBuilder
-
public class BodyPartBuilder extends AbstractEntityBuilder
BodyPartbuilder.
-
-
Field Summary
Fields Modifier and Type Field Description private BodyFactorybodyFactory
-
Constructor Summary
Constructors Constructor Description BodyPartBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AbstractEntityBuilderaddField(Field field)Adds a field to the end of the list of fields.BodyPartbuild()static BodyPartBuildercreate()AbstractEntityBuilderremoveFields(java.lang.String name)Removes allFields having the specified field name.BodyPartBuildersetBody(byte[] bin, java.lang.String mimeType)Sets binary content of this message with the given MIME type.BodyPartBuildersetBody(java.lang.String text, java.lang.String subtype, java.nio.charset.Charset charset)Sets text of this message with the given MIME subtype and charset.BodyPartBuildersetBody(java.lang.String text, java.nio.charset.Charset charset)Sets text of this message with the charset.BodyPartBuildersetBody(BinaryBody binaryBody)Sets binaryBody of this message.BodyPartBuildersetBody(Body body)Sets body of this message.BodyPartBuildersetBody(Message message)Sets body of this message.BodyPartBuildersetBody(Multipart multipart)Sets body of this message.BodyPartBuildersetBody(TextBody textBody)Sets body of this message.BodyPartBuildersetContentDisposition(java.lang.String dispositionType)Sets content disposition of this message to the specified disposition type.BodyPartBuildersetContentDisposition(java.lang.String dispositionType, java.lang.String filename)Sets content disposition of this message to the specified disposition type and filename.BodyPartBuildersetContentDisposition(java.lang.String dispositionType, java.lang.String filename, long size)Sets content disposition of this message to the specified values.BodyPartBuildersetContentDisposition(java.lang.String dispositionType, java.lang.String filename, long size, java.util.Date creationDate, java.util.Date modificationDate, java.util.Date readDate)Sets content disposition of this message to the specified values.BodyPartBuildersetContentTransferEncoding(java.lang.String contentTransferEncoding)Sets transfer encoding of this message.BodyPartBuildersetContentType(java.lang.String mimeType, NameValuePair... parameters)Sets transfer encoding of this message.BodyPartBuildersetField(Field field)Sets or replaces a field.BodyPartBuilderuse(BodyFactory bodyFactory)SetsBodyFactorythat will be used to generate message body.-
Methods inherited from class org.apache.james.mime4j.internal.AbstractEntityBuilder
clearFields, containsField, getBody, getCharset, getContentTransferEncoding, getCreationDate, getDispositionType, getField, getField, getFields, getFields, getFields, getFilename, getMimeType, getModificationDate, getReadDate, getSize, obtainField, setBody, setBody, setBody
-
-
-
-
Field Detail
-
bodyFactory
private BodyFactory bodyFactory
-
-
Method Detail
-
create
public static BodyPartBuilder create()
-
use
public BodyPartBuilder use(BodyFactory bodyFactory)
SetsBodyFactorythat will be used to generate message body.- Parameters:
bodyFactory- body factory.
-
setField
public BodyPartBuilder setField(Field field)
Description copied from class:AbstractEntityBuilderSets or replaces a field. This method is useful for header fields such as Subject or Message-ID that should not occur more than once in a message. If this builder does not already contain a header field of the same name as the given field then it is added to the end of the list of fields (same behavior asAbstractEntityBuilder.addField(org.apache.james.mime4j.stream.Field)). Otherwise the first occurrence of a field with the same name is replaced by the given field and all further occurrences are removed.- Overrides:
setFieldin classAbstractEntityBuilder- Parameters:
field- the field to set.
-
addField
public AbstractEntityBuilder addField(Field field)
Description copied from class:AbstractEntityBuilderAdds a field to the end of the list of fields.- Overrides:
addFieldin classAbstractEntityBuilder- Parameters:
field- the field to add.
-
removeFields
public AbstractEntityBuilder removeFields(java.lang.String name)
Description copied from class:AbstractEntityBuilderRemoves allFields having the specified field name.- Overrides:
removeFieldsin classAbstractEntityBuilder- Parameters:
name- the field name (e.g. From, Subject).
-
setContentTransferEncoding
public BodyPartBuilder setContentTransferEncoding(java.lang.String contentTransferEncoding)
Description copied from class:AbstractEntityBuilderSets transfer encoding of this message.- Overrides:
setContentTransferEncodingin classAbstractEntityBuilder- Parameters:
contentTransferEncoding- transfer encoding to use.
-
setContentType
public BodyPartBuilder setContentType(java.lang.String mimeType, NameValuePair... parameters)
Description copied from class:AbstractEntityBuilderSets transfer encoding of this message.- Overrides:
setContentTypein classAbstractEntityBuilder- Parameters:
mimeType- MIME type of this message the MIME type to use.parameters- content type parameters to use.
-
setContentDisposition
public BodyPartBuilder setContentDisposition(java.lang.String dispositionType)
Description copied from class:AbstractEntityBuilderSets content disposition of this message to the specified disposition type. No filename, size or date parameters are included in the content disposition.- Overrides:
setContentDispositionin classAbstractEntityBuilder- Parameters:
dispositionType- disposition type value (usuallyinlineorattachment).
-
setContentDisposition
public BodyPartBuilder setContentDisposition(java.lang.String dispositionType, java.lang.String filename)
Description copied from class:AbstractEntityBuilderSets content disposition of this message to the specified disposition type and filename. No size or date parameters are included in the content disposition.- Overrides:
setContentDispositionin classAbstractEntityBuilder- Parameters:
dispositionType- disposition type value (usuallyinlineorattachment).filename- filename parameter value ornullif the parameter should not be included.
-
setContentDisposition
public BodyPartBuilder setContentDisposition(java.lang.String dispositionType, java.lang.String filename, long size)
Description copied from class:AbstractEntityBuilderSets content disposition of this message to the specified values. No date parameters are included in the content disposition.- Overrides:
setContentDispositionin classAbstractEntityBuilder- Parameters:
dispositionType- disposition type value (usuallyinlineorattachment).filename- filename parameter value ornullif the parameter should not be included.size- size parameter value or-1if the parameter should not be included.
-
setContentDisposition
public BodyPartBuilder setContentDisposition(java.lang.String dispositionType, java.lang.String filename, long size, java.util.Date creationDate, java.util.Date modificationDate, java.util.Date readDate)
Description copied from class:AbstractEntityBuilderSets content disposition of this message to the specified values.- Overrides:
setContentDispositionin classAbstractEntityBuilder- Parameters:
dispositionType- disposition type value (usuallyinlineorattachment).filename- filename parameter value ornullif the parameter should not be included.size- size parameter value or-1if the parameter should not be included.creationDate- creation-date parameter value ornullif the parameter should not be included.modificationDate- modification-date parameter value ornullif the parameter should not be included.readDate- read-date parameter value ornullif the parameter should not be included.
-
setBody
public BodyPartBuilder setBody(Body body)
Description copied from class:AbstractEntityBuilderSets body of this message. Also sets the content type based on properties of the givenBody.- Overrides:
setBodyin classAbstractEntityBuilder- Parameters:
body- the body.
-
setBody
public BodyPartBuilder setBody(TextBody textBody)
Description copied from class:AbstractEntityBuilderSets body of this message. Also sets the content type based on properties of the givenBody.- Overrides:
setBodyin classAbstractEntityBuilder- Parameters:
textBody- the body.
-
setBody
public BodyPartBuilder setBody(BinaryBody binaryBody)
Description copied from class:AbstractEntityBuilderSets binaryBody of this message. Also sets the content type based on properties of the givenBody.- Overrides:
setBodyin classAbstractEntityBuilder- Parameters:
binaryBody- the binaryBody.
-
setBody
public BodyPartBuilder setBody(Multipart multipart)
Description copied from class:AbstractEntityBuilderSets body of this message. Also sets the content type based on properties of the givenMultipart.- Overrides:
setBodyin classAbstractEntityBuilder- Parameters:
multipart- the body.
-
setBody
public BodyPartBuilder setBody(Message message)
Description copied from class:AbstractEntityBuilderSets body of this message. Also sets the content type based on properties of the givenMessage.- Overrides:
setBodyin classAbstractEntityBuilder- Parameters:
message- the body.
-
setBody
public BodyPartBuilder setBody(java.lang.String text, java.nio.charset.Charset charset) throws java.io.IOException
Sets text of this message with the charset.- Parameters:
text- the text.charset- the charset of the text.- Throws:
java.io.IOException
-
setBody
public BodyPartBuilder setBody(java.lang.String text, java.lang.String subtype, java.nio.charset.Charset charset) throws java.io.IOException
Sets text of this message with the given MIME subtype and charset.- Parameters:
text- the text.charset- the charset of the text.subtype- the text subtype (e.g. "plain", "html" or "xml").- Throws:
java.io.IOException
-
setBody
public BodyPartBuilder setBody(byte[] bin, java.lang.String mimeType) throws java.io.IOException
Sets binary content of this message with the given MIME type.- Parameters:
bin- the body.mimeType- the MIME media type of the specified body ("type/subtype").- Throws:
java.io.IOException
-
build
public BodyPart build()
-
-