org.marre.mime
Class MimeBodyPart

java.lang.Object
  extended byorg.marre.mime.MimeBodyPart
Direct Known Subclasses:
MimeMultipart

public class MimeBodyPart
extends java.lang.Object

Represents a MIME body part. A body part can contain headers and a body.

Version:
$Id: MimeBodyPart.java,v 1.9 2004/11/02 17:59:47 c95men Exp $
Author:
Markus Eriksson

Field Summary
protected  byte[] myBody
           
protected  MimeContentType myContentType
           
protected  java.util.List myHeaders
           
 
Constructor Summary
MimeBodyPart()
          Creates a new empty MimeBodyPart.
MimeBodyPart(byte[] body, MimeContentType contentType)
          Creates a new empty MimeBodyPart.
MimeBodyPart(byte[] body, java.lang.String contentType)
          Creates a new empty MimeBodyPart.
 
Method Summary
 void addHeader(MimeHeader theHeader)
          Adds a mime header to this body part.
 void addHeader(java.lang.String theHeaderName, java.lang.String theHeaderValue)
          Adds a eader to this body part.
 byte[] getBody()
          Returns the content of this body part.
 int getBodySize()
          Returns the size of the body in this body part.
 MimeContentType getContentType()
          Returns the content type.
 MimeHeader getHeader(int theIndex)
          Retrieves a header with the given index.
 MimeHeader getHeader(java.lang.String headerName)
          Retrieves a header with the given name.
 int getHeaderCount()
          Returns the number of headers.
 void setContent(byte[] theContent, MimeContentType theContentType)
          Sets the main content of this body part.
 void setContent(byte[] theContent, java.lang.String theContentType)
          Sets the main content of this body part.
 void setContentId(java.lang.String theContentId)
          Sets the "Content-Id" header.
 void setContentLocation(java.lang.String theContentLocation)
          Sets the "Content-Location" header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myBody

protected byte[] myBody

myContentType

protected MimeContentType myContentType

myHeaders

protected java.util.List myHeaders
Constructor Detail

MimeBodyPart

public MimeBodyPart()
Creates a new empty MimeBodyPart.


MimeBodyPart

public MimeBodyPart(byte[] body,
                    MimeContentType contentType)
Creates a new empty MimeBodyPart.


MimeBodyPart

public MimeBodyPart(byte[] body,
                    java.lang.String contentType)
Creates a new empty MimeBodyPart.

Method Detail

addHeader

public void addHeader(MimeHeader theHeader)
Adds a mime header to this body part.

Parameters:
theHeader - The header to add

addHeader

public void addHeader(java.lang.String theHeaderName,
                      java.lang.String theHeaderValue)
Adds a eader to this body part.

Parameters:
theHeaderName - The name of the header
theHeaderValue - The value

getHeader

public MimeHeader getHeader(int theIndex)
Retrieves a header with the given index.

Parameters:
theIndex - Index of header to retrieve
Returns:
The header, or null if not found

getHeader

public MimeHeader getHeader(java.lang.String headerName)
Retrieves a header with the given name.

Parameters:
headerName - The name of the header to find
Returns:
The header, or null if not found

getHeaderCount

public int getHeaderCount()
Returns the number of headers.

Returns:
The number of headers

setContent

public void setContent(byte[] theContent,
                       java.lang.String theContentType)
Sets the main content of this body part.

Parameters:
theContent - The main content
theContentType - The content-type of the content

setContent

public void setContent(byte[] theContent,
                       MimeContentType theContentType)
Sets the main content of this body part.

Parameters:
theContent - The main content
theContentType - The content type

setContentId

public void setContentId(java.lang.String theContentId)
Sets the "Content-Id" header.

Parameters:
theContentId - The content-id

setContentLocation

public void setContentLocation(java.lang.String theContentLocation)
Sets the "Content-Location" header.

Parameters:
theContentLocation - The content-location

getBody

public byte[] getBody()
Returns the content of this body part.

Returns:
The content

getBodySize

public int getBodySize()
Returns the size of the body in this body part.

Returns:
The size of the body

getContentType

public MimeContentType getContentType()
Returns the content type.

Returns:
The content type


Copyright © 2002-2005 Markus Eriksson. All Rights Reserved.