org.apache.james.mime4j.message
Class AbstractMultipart

java.lang.Object
  extended by 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
protected  java.util.List<Entity> bodyParts
           
 
Constructor Summary
AbstractMultipart(java.lang.String subType)
          Creates a new empty Multipart instance.
 
Method Summary
 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.
 int getCount()
          Returns the number of body parts.
abstract  java.lang.String getEpilogue()
          Gets the epilogue or null if the message has no epilogue
 Entity 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bodyParts

protected java.util.List<Entity> bodyParts
Constructor Detail

AbstractMultipart

public AbstractMultipart(java.lang.String subType)
Creates a new empty Multipart instance.

Method Detail

getSubType

public java.lang.String getSubType()
Gets the multipart sub-type. E.g. alternative (the default) or parallel. See RFC 2045 for common sub-types and their meaning.

Specified by:
getSubType in interface Multipart
Returns:
the multipart sub-type.

setSubType

public void setSubType(java.lang.String subType)
Sets the multipart sub-type. E.g. alternative or parallel. 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 interface Body
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 interface Body
Parameters:
parent - the parent.
See Also:
Body.setParent(org.apache.james.mime4j.dom.Entity)

getCount

public int getCount()
Returns the number of body parts.

Specified by:
getCount in interface Multipart
Returns:
number of Entity objects.

getBodyParts

public java.util.List<Entity> getBodyParts()
Gets the list of body parts. The list is immutable.

Specified by:
getBodyParts in interface Multipart
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 interface Multipart
Parameters:
bodyParts - the new list of Entity objects.

addBodyPart

public void addBodyPart(Entity bodyPart)
Adds a body part to the end of the list of body parts.

Specified by:
addBodyPart in interface Multipart
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 interface Multipart
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 interface Multipart
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 interface Multipart
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 interface Multipart
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 interface Multipart
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 interface Multipart
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 interface Multipart
Parameters:
epilogue - the epilogue.

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 interface Disposable
See Also:
Disposable.dispose()


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.