Package org.apache.james.mime4j.message
Class MultipartBuilder
- java.lang.Object
-
- org.apache.james.mime4j.message.MultipartBuilder
-
public class MultipartBuilder extends java.lang.Object
Multipart
builder.
-
-
Field Summary
Fields Modifier and Type Field Description private BodyFactory
bodyFactory
private java.util.List<Entity>
bodyParts
private java.lang.String
epilogue
private java.util.List<NameValuePair>
parameters
private java.lang.String
preamble
private java.lang.String
subType
-
Constructor Summary
Constructors Modifier Constructor Description private
MultipartBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MultipartBuilder
addBinaryPart(byte[] bin, java.lang.String mimeType)
MultipartBuilder
addBodyPart(Entity bodyPart)
Adds a body part to the end of the list of body parts.MultipartBuilder
addBodyPart(Entity bodyPart, int index)
Inserts a body part at the specified position in the list of body parts.MultipartBuilder
addBodyPart(BodyPartBuilder bodyPart)
MultipartBuilder
addContentTypeParameter(NameValuePair parameter)
MultipartBuilder
addTextPart(java.lang.String text, java.nio.charset.Charset charset)
Multipart
build()
MultipartBuilder
copy(Multipart other)
static MultipartBuilder
create()
static MultipartBuilder
create(java.lang.String subType)
static MultipartBuilder
createCopy(Multipart other)
java.util.List<Entity>
getBodyParts()
Gets the list of body parts.int
getCount()
Returns the number of body parts.java.lang.String
getEpilogue()
Returns epilogue.java.lang.String
getPreamble()
Returns preamble.java.lang.String
getSubType()
Gets the multipart sub-type.MultipartBuilder
removeBodyPart(int index)
Removes the body part at the specified position in the list of body parts.MultipartBuilder
replaceBodyPart(Entity bodyPart, int index)
Replaces the body part at the specified position in the list of body parts with the specified body part.MultipartBuilder
setEpilogue(java.lang.String epilogue)
Sets the epilogue.MultipartBuilder
setPreamble(java.lang.String preamble)
Sets the preamble.MultipartBuilder
setSubType(java.lang.String subType)
Sets the multipart sub-type.MultipartBuilder
use(BodyFactory bodyFactory)
-
-
-
Field Detail
-
bodyParts
private final java.util.List<Entity> bodyParts
-
subType
private java.lang.String subType
-
preamble
private java.lang.String preamble
-
epilogue
private java.lang.String epilogue
-
bodyFactory
private BodyFactory bodyFactory
-
parameters
private java.util.List<NameValuePair> parameters
-
-
Method Detail
-
create
public static MultipartBuilder create(java.lang.String subType)
-
createCopy
public static MultipartBuilder createCopy(Multipart other)
-
create
public static MultipartBuilder create()
-
use
public MultipartBuilder use(BodyFactory bodyFactory)
-
getSubType
public java.lang.String getSubType()
Gets the multipart sub-type. E.g.alternative
(the default) orparallel
. See RFC 2045 for common sub-types and their meaning.- Returns:
- the multipart sub-type.
-
setSubType
public MultipartBuilder setSubType(java.lang.String subType)
Sets the multipart sub-type. E.g.alternative
orparallel
. See RFC 2045 for common sub-types and their meaning.- Parameters:
subType
- the sub-type.
-
getCount
public int getCount()
Returns the number of body parts.- Returns:
- number of
Entity
objects.
-
getBodyParts
public java.util.List<Entity> getBodyParts()
Gets the list of body parts. The list is immutable.- Returns:
- the list of
Entity
objects.
-
addBodyPart
public MultipartBuilder addBodyPart(Entity bodyPart)
Adds a body part to the end of the list of body parts.- Parameters:
bodyPart
- the body part.
-
addBodyPart
public MultipartBuilder addBodyPart(BodyPartBuilder bodyPart)
-
addBodyPart
public MultipartBuilder addBodyPart(Entity bodyPart, int index)
Inserts a body part at the specified position in the list of body parts.- Parameters:
bodyPart
- the body part.index
- index at which the specified body part is to be inserted.
-
removeBodyPart
public MultipartBuilder removeBodyPart(int index)
Removes the body part at the specified position in the list of body parts.- Parameters:
index
- index of the body part to be removed.- Returns:
- the removed body part.
-
replaceBodyPart
public MultipartBuilder replaceBodyPart(Entity bodyPart, int index)
Replaces the body part at the specified position in the list of body parts with the specified body part.- Parameters:
bodyPart
- body part to be stored at the specified position.index
- index of body part to replace.- Returns:
- the replaced body part.
- Throws:
java.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= getCount()).
-
getPreamble
public java.lang.String getPreamble()
Returns preamble.- Returns:
- the preamble.
-
setPreamble
public MultipartBuilder setPreamble(java.lang.String preamble)
Sets the preamble.- Parameters:
preamble
- the preamble.
-
getEpilogue
public java.lang.String getEpilogue()
Returns epilogue.- Returns:
- the epilogue.
-
setEpilogue
public MultipartBuilder setEpilogue(java.lang.String epilogue)
Sets the epilogue.- Parameters:
epilogue
- the epilogue.
-
addContentTypeParameter
public MultipartBuilder addContentTypeParameter(NameValuePair parameter)
-
addTextPart
public MultipartBuilder addTextPart(java.lang.String text, java.nio.charset.Charset charset) throws java.io.IOException
- Throws:
java.io.IOException
-
addBinaryPart
public MultipartBuilder addBinaryPart(byte[] bin, java.lang.String mimeType) throws java.io.IOException
- Throws:
java.io.IOException
-
copy
public MultipartBuilder copy(Multipart other)
-
build
public Multipart build()
-
-