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 Object implements Multipart
Abstract MIME multipart body.
  • Field Details

  • Constructor Details

    • AbstractMultipart

      public AbstractMultipart(String subType, List<NameValuePair> contentTypeParameters)
      Creates a new empty Multipart instance.
  • Method Details

    • getSubType

      public 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(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:
    • 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:
    • getCount

      public int getCount()
      Returns the number of body parts.
      Specified by:
      getCount in interface Multipart
      Returns:
      number of Entity objects.
    • getBodyParts

      public 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(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:
      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:
      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:
      IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= getCount()).
    • getPreamble

      public abstract 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(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 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(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.
    • getContentTypeParameters

      public List<NameValuePair> getContentTypeParameters()
      Specified by:
      getContentTypeParameters in interface Multipart
    • 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: