Package org.apache.james.mime4j.message
Class AbstractMultipart
- java.lang.Object
-
- org.apache.james.mime4j.message.AbstractMultipart
-
- All Implemented Interfaces:
Body
,Disposable
,Multipart
- Direct Known Subclasses:
MultipartImpl
public abstract class AbstractMultipart extends java.lang.Object implements Multipart
Abstract MIME multipart body.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<Entity>
bodyParts
private java.util.List<NameValuePair>
contentTypeParameters
private Entity
parent
private java.lang.String
subType
-
Constructor Summary
Constructors Constructor Description AbstractMultipart(java.lang.String subType, java.util.List<NameValuePair> contentTypeParameters)
Creates a new emptyMultipart
instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addBodyPart(Entity bodyPart)
Adds a body part to the end of the list of body parts.void
addBodyPart(Entity bodyPart, int index)
Inserts a body part at the specified position in the list of body parts.void
dispose()
Disposes of the BodyParts of this Multipart.java.util.List<Entity>
getBodyParts()
Gets the list of body parts.java.util.List<NameValuePair>
getContentTypeParameters()
int
getCount()
Returns the number of body parts.abstract java.lang.String
getEpilogue()
Gets the epilogue or null if the message has no epilogueEntity
getParent()
Gets the parent of this body.abstract java.lang.String
getPreamble()
Gets the preamble or null if the message has no preamble.java.lang.String
getSubType()
Gets the multipart sub-type.Entity
removeBodyPart(int index)
Removes the body part at the specified position in the list of body parts.Entity
replaceBodyPart(Entity bodyPart, int index)
Replaces the body part at the specified position in the list of body parts with the specified body part.void
setBodyParts(java.util.List<Entity> bodyParts)
Sets the list of body parts.abstract void
setEpilogue(java.lang.String epilogue)
Sets the epilogue value, or remove it if the value passed is null.void
setParent(Entity parent)
Sets the parent of this body.abstract void
setPreamble(java.lang.String preamble)
Sets the preamble with a value or null to remove the preamble.void
setSubType(java.lang.String subType)
Sets the multipart sub-type.
-
-
-
Field Detail
-
bodyParts
protected java.util.List<Entity> bodyParts
-
parent
private Entity parent
-
subType
private java.lang.String subType
-
contentTypeParameters
private final java.util.List<NameValuePair> contentTypeParameters
-
-
Constructor Detail
-
AbstractMultipart
public AbstractMultipart(java.lang.String subType, java.util.List<NameValuePair> contentTypeParameters)
Creates a new emptyMultipart
instance.
-
-
Method Detail
-
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.- Specified by:
getSubType
in interfaceMultipart
- Returns:
- the multipart sub-type.
-
setSubType
public void 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.
-
getParent
public Entity getParent()
Description copied from interface:Body
Gets the parent of this body.- Specified by:
getParent
in interfaceBody
- Returns:
- the parent.
- See Also:
Body.getParent()
-
setParent
public void setParent(Entity parent)
Description copied from interface:Body
Sets the parent of this body.- Specified by:
setParent
in interfaceBody
- Parameters:
parent
- the parent.- See Also:
Body.setParent(org.apache.james.mime4j.dom.Entity)
-
getCount
public int getCount()
Returns the number of body parts.
-
getBodyParts
public java.util.List<Entity> getBodyParts()
Gets the list of body parts. The list is immutable.- Specified by:
getBodyParts
in interfaceMultipart
- Returns:
- the list of
Entity
objects.
-
setBodyParts
public void setBodyParts(java.util.List<Entity> bodyParts)
Sets the list of body parts.- Specified by:
setBodyParts
in interfaceMultipart
- Parameters:
bodyParts
- the new list ofEntity
objects.
-
addBodyPart
public void addBodyPart(Entity bodyPart)
Adds a body part to the end of the list of body parts.- Specified by:
addBodyPart
in interfaceMultipart
- Parameters:
bodyPart
- the body part.
-
addBodyPart
public void addBodyPart(Entity bodyPart, int index)
Inserts a body part at the specified position in the list of body parts.- Specified by:
addBodyPart
in interfaceMultipart
- Parameters:
bodyPart
- the body part.index
- index at which the specified body part is to be inserted.- Throws:
java.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index > getCount()).
-
removeBodyPart
public Entity removeBodyPart(int index)
Removes the body part at the specified position in the list of body parts.- Specified by:
removeBodyPart
in interfaceMultipart
- Parameters:
index
- index of the body part to be removed.- Returns:
- the removed body part.
- Throws:
java.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= getCount()).
-
replaceBodyPart
public Entity replaceBodyPart(Entity bodyPart, int index)
Replaces the body part at the specified position in the list of body parts with the specified body part.- Specified by:
replaceBodyPart
in interfaceMultipart
- 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 abstract java.lang.String getPreamble()
Gets the preamble or null if the message has no preamble.- Specified by:
getPreamble
in interfaceMultipart
- Returns:
- the preamble.
-
setPreamble
public abstract void setPreamble(java.lang.String preamble)
Sets the preamble with a value or null to remove the preamble.- Specified by:
setPreamble
in interfaceMultipart
- Parameters:
preamble
- the preamble.
-
getEpilogue
public abstract java.lang.String getEpilogue()
Gets the epilogue or null if the message has no epilogue- Specified by:
getEpilogue
in interfaceMultipart
- Returns:
- the epilogue.
-
setEpilogue
public abstract void setEpilogue(java.lang.String epilogue)
Sets the epilogue value, or remove it if the value passed is null.- Specified by:
setEpilogue
in interfaceMultipart
- Parameters:
epilogue
- the epilogue.
-
getContentTypeParameters
public java.util.List<NameValuePair> getContentTypeParameters()
- Specified by:
getContentTypeParameters
in interfaceMultipart
-
dispose
public void dispose()
Disposes of the BodyParts of this Multipart. Note that the dispose call does not get forwarded to the parent entity of this Multipart.- Specified by:
dispose
in interfaceDisposable
- See Also:
Disposable.dispose()
-
-