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>bodyPartsprivate java.util.List<NameValuePair>contentTypeParametersprivate Entityparentprivate java.lang.StringsubType
-
Constructor Summary
Constructors Constructor Description AbstractMultipart(java.lang.String subType, java.util.List<NameValuePair> contentTypeParameters)Creates a new emptyMultipartinstance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddBodyPart(Entity bodyPart)Adds a body part to the end of the list of body parts.voidaddBodyPart(Entity bodyPart, int index)Inserts a body part at the specified position in the list of body parts.voiddispose()Disposes of the BodyParts of this Multipart.java.util.List<Entity>getBodyParts()Gets the list of body parts.java.util.List<NameValuePair>getContentTypeParameters()intgetCount()Returns the number of body parts.abstract java.lang.StringgetEpilogue()Gets the epilogue or null if the message has no epilogueEntitygetParent()Gets the parent of this body.abstract java.lang.StringgetPreamble()Gets the preamble or null if the message has no preamble.java.lang.StringgetSubType()Gets the multipart sub-type.EntityremoveBodyPart(int index)Removes the body part at the specified position in the list of body parts.EntityreplaceBodyPart(Entity bodyPart, int index)Replaces the body part at the specified position in the list of body parts with the specified body part.voidsetBodyParts(java.util.List<Entity> bodyParts)Sets the list of body parts.abstract voidsetEpilogue(java.lang.String epilogue)Sets the epilogue value, or remove it if the value passed is null.voidsetParent(Entity parent)Sets the parent of this body.abstract voidsetPreamble(java.lang.String preamble)Sets the preamble with a value or null to remove the preamble.voidsetSubType(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 emptyMultipartinstance.
-
-
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:
getSubTypein interfaceMultipart- Returns:
- the multipart sub-type.
-
setSubType
public void setSubType(java.lang.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.
-
getParent
public Entity getParent()
Description copied from interface:BodyGets the parent of this body.- Specified by:
getParentin interfaceBody- Returns:
- the parent.
- See Also:
Body.getParent()
-
setParent
public void setParent(Entity parent)
Description copied from interface:BodySets the parent of this body.- Specified by:
setParentin 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:
getBodyPartsin interfaceMultipart- Returns:
- the list of
Entityobjects.
-
setBodyParts
public void setBodyParts(java.util.List<Entity> bodyParts)
Sets the list of body parts.- Specified by:
setBodyPartsin interfaceMultipart- Parameters:
bodyParts- the new list ofEntityobjects.
-
addBodyPart
public void addBodyPart(Entity bodyPart)
Adds a body part to the end of the list of body parts.- Specified by:
addBodyPartin 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:
addBodyPartin 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:
removeBodyPartin 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:
replaceBodyPartin 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:
getPreamblein 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:
setPreamblein 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:
getEpiloguein 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:
setEpiloguein interfaceMultipart- Parameters:
epilogue- the epilogue.
-
getContentTypeParameters
public java.util.List<NameValuePair> getContentTypeParameters()
- Specified by:
getContentTypeParametersin 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:
disposein interfaceDisposable- See Also:
Disposable.dispose()
-
-