net.rim.blackberry.api.mail
Class BodyPart

java.lang.Object
  extended by net.rim.blackberry.api.mail.BodyPart
All Implemented Interfaces:
Part
Direct Known Subclasses:
MimeBodyPart, PDAPContactAttachmentPart, SupportedAttachmentPart, TextBodyPart, UnsupportedAttachmentPart

public abstract class BodyPart
extends Object
implements Part

Represents a part contained in a Multipart.

A body part object comprises header attributes and body contents. This is an abstract class; subclasses provide actual implementations.

The BlackBerry Mail API provides three classes that implement different types of body parts: TextBodyPart, SupportedAttachmentPart, and UnsupportedAttachmentPart.

See Also:
Multipart
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

Nested Class Summary
Category: Signed static interface BodyPart.ContentType
          The following constants define some common attachment types and subtypes.
 
Field Summary
Category: Signed static String CONTENT_TYPE
          MIME content-type header type.
Category: Signed protected static byte[] CRLF
          Line feed character.
Category: Signed protected static byte[] EMPTY
          Empty character.
Category: Signed protected static char SEPARATOR
          Separator (:) character.
 
Fields inherited from interface net.rim.blackberry.api.mail.Part
ATTACHMENT, INLINE
 
Constructor Summary
Category: Signed protected BodyPart(Multipart parent)
          Constructs a new BodyPart instance.
 
Method Summary
Category: Signed  void addHeader(String name, String value)
          Adds a header for this body part.
Category: Signed  Enumeration getAllHeaders()
          Retrieves all headers associated with this body part as an Enumeration of String objects.
Category: Signed  String getContentType()
          Retrieves this body part's content type.
Category: Signed  String[] getHeader(String header)
          Retrieves all headers of a specific name.
Category: Signed  Multipart getParent()
          Retrieves the multi-part object containing this body part.
Category: Signed  boolean hasMore()
          Determines if more data for this body part is available on the server.
Category: Signed  boolean isMimeType(String mimeType)
          Determines if this body part is of the specified MIME content type.
Category: Signed  boolean moreRequestSent()
          Determines if a request has been sent for more data for this body part.
Category: Signed  void removeHeader(String header)
          Removes a header from this body part.
Category: Signed  void setContentType(String value)
          Sets this body part's content type.
Category: Signed  void setHeader(String header, String value)
          Sets a header for this body part, by type.
Category: Signed  void writeTo(OutputStream os)
          Writes information about this body part's content type to provided output stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.rim.blackberry.api.mail.Part
getContent, getInputStream, getSize, setContent
 



Field Detail

CONTENT_TYPE

public static String CONTENT_TYPE
MIME content-type header type.

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

SEPARATOR

protected static final char SEPARATOR
Separator (:) character.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

CRLF

protected static final byte[] CRLF
Line feed character.

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

EMPTY

protected static final byte[] EMPTY
Empty character.

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0


Constructor Detail

BodyPart

protected BodyPart(Multipart parent)
Constructs a new BodyPart instance.

Parameters:
parent - The multi-part object to contain this body part.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0


Method Detail

getParent

public Multipart getParent()
Retrieves the multi-part object containing this body part.

Returns:
This body part's containing multi-part.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

addHeader

public void addHeader(String name,
                      String value)
Adds a header for this body part.

Note that currently only the BodyPart.CONTENT_TYPE header is supported; sub-classes should implement support for an expanded variety of headers if they require it. Invoking this method more than once will therefore overwrite the content-type value previously associated with this body part.

Specified by:
addHeader in interface Part
Parameters:
name - Name for his header; currently, only BodyPart.CONTENT_TYPE is supported.
value - Value associated with this header (i.e. content type for this body part).
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

getAllHeaders

public Enumeration getAllHeaders()
Retrieves all headers associated with this body part as an Enumeration of String objects.

Specified by:
getAllHeaders in interface Part
Returns:
Enumeration containing all the headers added to this body part.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

getContentType

public String getContentType()
Retrieves this body part's content type.

Specified by:
getContentType in interface Part
Returns:
The MIME type for this body part.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

setContentType

public void setContentType(String value)
Sets this body part's content type.

Note: This method is currently unsupported.

Parameters:
value - MIME content type for this body part.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

getHeader

public String[] getHeader(String header)
Retrieves all headers of a specific name.

Specified by:
getHeader in interface Part
Parameters:
header - Name of the headers to retrieve (currently only BodyPart.CONTENT_TYPE headers are supported; see BodyPart.addHeader(java.lang.String, java.lang.String)).
Returns:
List of values for the specified header type, or an empty array if no header values yet set for this body part.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

isMimeType

public boolean isMimeType(String mimeType)
Determines if this body part is of the specified MIME content type.

Specified by:
isMimeType in interface Part
Parameters:
mimeType - MIME content type to match against this body type.
Returns:
True if this body part is of the specified MIME type; otherwise, false.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

removeHeader

public void removeHeader(String header)
Removes a header from this body part.

Specified by:
removeHeader in interface Part
Parameters:
header - Header type to remove; all header values of this type get removed. Currently, this method supports only the BodyPart.CONTENT_TYPE header type.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

setHeader

public void setHeader(String header,
                      String value)
Sets a header for this body part, by type.

Specified by:
setHeader in interface Part
Parameters:
header - Header type to set; currently, this method supports only the BodyPart.CONTENT_TYPE header type.
value - Value to set for the specified header type.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

writeTo

public void writeTo(OutputStream os)
             throws IOException
Writes information about this body part's content type to provided output stream.

Specified by:
writeTo in interface Part
Parameters:
os - Output stream to which to write the retrieved information.
Throws:
IOException - Signals that an I/O error has occurred.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

hasMore

public boolean hasMore()
Determines if more data for this body part is available on the server.

Returns:
True if more data is available; otherwise, false.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

moreRequestSent

public boolean moreRequestSent()
Determines if a request has been sent for more data for this body part.

Returns:
True if more data has been requested for this body part; otherwise, false.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.