Package org.apache.james.mime4j.message
Class MultipartBuilder
- java.lang.Object
-
- org.apache.james.mime4j.message.MultipartBuilder
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MultipartBuilderaddBinaryPart(byte[] bin, String mimeType)MultipartBuilderaddBodyPart(Entity bodyPart)Adds a body part to the end of the list of body parts.MultipartBuilderaddBodyPart(Entity bodyPart, int index)Inserts a body part at the specified position in the list of body parts.MultipartBuilderaddBodyPart(BodyPartBuilder bodyPart)MultipartBuilderaddContentTypeParameter(NameValuePair parameter)MultipartBuilderaddTextPart(String text, Charset charset)Multipartbuild()MultipartBuildercopy(Multipart other)static MultipartBuildercreate()static MultipartBuildercreate(String subType)static MultipartBuildercreateCopy(Multipart other)List<Entity>getBodyParts()Gets the list of body parts.intgetCount()Returns the number of body parts.StringgetEpilogue()Returns epilogue.StringgetPreamble()Returns preamble.StringgetSubType()Gets the multipart sub-type.MultipartBuilderremoveBodyPart(int index)Removes the body part at the specified position in the list of body parts.MultipartBuilderreplaceBodyPart(Entity bodyPart, int index)Replaces the body part at the specified position in the list of body parts with the specified body part.MultipartBuildersetEpilogue(String epilogue)Sets the epilogue.MultipartBuildersetPreamble(String preamble)Sets the preamble.MultipartBuildersetSubType(String subType)Sets the multipart sub-type.MultipartBuilderuse(BodyFactory bodyFactory)
-
-
-
Method Detail
-
create
public static MultipartBuilder create(String subType)
-
createCopy
public static MultipartBuilder createCopy(Multipart other)
-
create
public static MultipartBuilder create()
-
use
public MultipartBuilder use(BodyFactory bodyFactory)
-
getSubType
public 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(String subType)
Sets the multipart sub-type. E.g.alternativeorparallel. 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
Entityobjects.
-
getBodyParts
public List<Entity> getBodyParts()
Gets the list of body parts. The list is immutable.- Returns:
- the list of
Entityobjects.
-
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:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index >= getCount()).
-
getPreamble
public String getPreamble()
Returns preamble.- Returns:
- the preamble.
-
setPreamble
public MultipartBuilder setPreamble(String preamble)
Sets the preamble.- Parameters:
preamble- the preamble.
-
getEpilogue
public String getEpilogue()
Returns epilogue.- Returns:
- the epilogue.
-
setEpilogue
public MultipartBuilder setEpilogue(String epilogue)
Sets the epilogue.- Parameters:
epilogue- the epilogue.
-
addContentTypeParameter
public MultipartBuilder addContentTypeParameter(NameValuePair parameter)
-
addTextPart
public MultipartBuilder addTextPart(String text, Charset charset) throws IOException
- Throws:
IOException
-
addBinaryPart
public MultipartBuilder addBinaryPart(byte[] bin, String mimeType) throws IOException
- Throws:
IOException
-
copy
public MultipartBuilder copy(Multipart other)
-
build
public Multipart build()
-
-