com.funambol.mail
Class Part

java.lang.Object
  extended by com.funambol.mail.Part
Direct Known Subclasses:
BodyPart, Message

public abstract class Part
extends java.lang.Object

The common base class for Messages and BodyParts. It models a MIME entity (see http://www.ietf.org/rfc/rfc2045.txt, par. 2.4) that defines header attributes (beginning with "content-") and content body. An entity that is also a Message has the standard non-MIME header fields whose meanings are defined by RFC 2822


Field Summary
static java.lang.String CONTENT_TRANSFER_ENCODING
          RFC 2822
static java.lang.String CONTENT_TYPE
          The MIME "Content-Type" header name
protected  java.lang.String contentType
          The MIME type of this Part
static java.lang.String ENC_7BIT
          The MIME "7bit" content transfer encoding
static java.lang.String ENC_8BIT
          The MIME "8bit" content transfer encoding
static java.lang.String ENC_B64
          The MIME "base64" content transfer encoding
static java.lang.String ENC_QP
          The MIME "quoted-printable" content transfer encoding
protected  java.util.Hashtable headers
          The headers of this Part
static java.lang.String MULTIPART
          The MIME "multipart" content type
static java.lang.String MULTIPART_ALTERNATIVE
          The MIME "multipart/mixed" content type
static java.lang.String MULTIPART_MIXED
          The MIME "multipart/mixed" content type
protected  java.lang.String size
          The size of this Part
static java.lang.String TEXT_PLAIN
          The MIME "text/plain" content type
 
Constructor Summary
protected Part()
          The default constructor
 
Method Summary
 void addHeader(java.lang.String name, java.lang.String value)
          Adds a new header to the list of headers.
 java.lang.String[] getAllHeaders()
          Returns the list of headers stored in this Message object, as an array of String
abstract  java.lang.Object getContent()
          Get the content of this Part.
 java.lang.String getContentType()
          Gets the value of the Content-Type header attribute of this Message
 java.lang.String getHeader(java.lang.String name)
          Returns the header name
 java.lang.String getSize()
           
 boolean isMultipart()
          Check if the MIME type of this Part is multipart/*
 boolean isText()
          Check if the MIME type of this Part is text/*
 boolean isTextHtml()
          Check if the MIME type of this Part is text/html
 boolean isTextPlain()
          Check if the MIME type of this Part is text/plain
 void removeHeader(java.lang.String name)
          Remove the header name from this message
abstract  void setContent(java.lang.Object content)
          Sets the content of this Part.
abstract  void setContent(java.lang.Object content, java.lang.String type)
          Sets the content and the Content-type of this Part.
 void setContentType(java.lang.String type)
          Set the MIME-type of this Part.
 void setHeader(java.lang.String name, java.lang.String val)
          Set the value of an header, replacing the old value, if any.
 void setSize(java.lang.String size)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENT_TYPE

public static final java.lang.String CONTENT_TYPE
The MIME "Content-Type" header name

See Also:
Constant Field Values

MULTIPART

public static final java.lang.String MULTIPART
The MIME "multipart" content type

See Also:
Constant Field Values

MULTIPART_MIXED

public static final java.lang.String MULTIPART_MIXED
The MIME "multipart/mixed" content type

See Also:
Constant Field Values

MULTIPART_ALTERNATIVE

public static final java.lang.String MULTIPART_ALTERNATIVE
The MIME "multipart/mixed" content type

See Also:
Constant Field Values

TEXT_PLAIN

public static final java.lang.String TEXT_PLAIN
The MIME "text/plain" content type

See Also:
Constant Field Values

CONTENT_TRANSFER_ENCODING

public static final java.lang.String CONTENT_TRANSFER_ENCODING
RFC 2822

See Also:
Constant Field Values

ENC_7BIT

public static final java.lang.String ENC_7BIT
The MIME "7bit" content transfer encoding

See Also:
Constant Field Values

ENC_8BIT

public static final java.lang.String ENC_8BIT
The MIME "8bit" content transfer encoding

See Also:
Constant Field Values

ENC_B64

public static final java.lang.String ENC_B64
The MIME "base64" content transfer encoding

See Also:
Constant Field Values

ENC_QP

public static final java.lang.String ENC_QP
The MIME "quoted-printable" content transfer encoding

See Also:
Constant Field Values

headers

protected java.util.Hashtable headers
The headers of this Part


contentType

protected java.lang.String contentType
The MIME type of this Part


size

protected java.lang.String size
The size of this Part

Constructor Detail

Part

protected Part()
The default constructor

Used only by subclasses for common initialization.

Method Detail

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Adds a new header to the list of headers.

NOTE: This method is not yet implemented and must not be called.

TODO: support multiple headers?

Parameters:
name - The name of the header attribute as described in the RFC 2822
value - The content for the attribute

getHeader

public java.lang.String getHeader(java.lang.String name)
Returns the header name

Returns:
The requested header, or null if not found

getAllHeaders

public java.lang.String[] getAllHeaders()
Returns the list of headers stored in this Message object, as an array of String

Returns:
The list of headers headers

getContent

public abstract java.lang.Object getContent()
Get the content of this Part.

Returns:
the content of this Part

getContentType

public java.lang.String getContentType()
Gets the value of the Content-Type header attribute of this Message

Returns:
The MIME media type defined in the RFC 2046

setContent

public abstract void setContent(java.lang.Object content)
                         throws MailException
Sets the content of this Part.

Throws:
MailException

setContent

public abstract void setContent(java.lang.Object content,
                                java.lang.String type)
                         throws MailException
Sets the content and the Content-type of this Part.

Throws:
MailException

setContentType

public void setContentType(java.lang.String type)
Set the MIME-type of this Part.

Parameters:
type - The value for the MIME type of this Part, without the Content-type header attributes.

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String val)
Set the value of an header, replacing the old value, if any.

Parameters:
name - The name of the header attribute as described in the RFC 2822
val - The new content for the attribute

removeHeader

public void removeHeader(java.lang.String name)
Remove the header name from this message

Parameters:
name - the name of the header to be removed

isMultipart

public boolean isMultipart()
Check if the MIME type of this Part is multipart/*

Returns:
true if the media type is multipart

isText

public boolean isText()
Check if the MIME type of this Part is text/*

Returns:
true if the media type is text

isTextPlain

public boolean isTextPlain()
Check if the MIME type of this Part is text/plain

Returns:
true if the media type is text and the subtype plain

isTextHtml

public boolean isTextHtml()
Check if the MIME type of this Part is text/html

Returns:
true if the media type is text and the subtype html

setSize

public void setSize(java.lang.String size)

getSize

public java.lang.String getSize()


Copyright © 2001-2009 Funambol.