|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.blackberry.api.mail.AttachmentDownloadManager
public class AttachmentDownloadManager
This class provides the ability to prgrammatically download email attachments for incoming message.
It does not support forwarded or sent messages.
Attachments can be downloaded regardless of its viewable state. That is, an attachment can be supportedAttachmentPart or unsupportedAttachmentPart.
Third party applications can implement DownloadProgressListener
to receive downloading outcomes.
Pre-validations are invoked before attachments are downloaded. If any of the following conditions happens, exceptions are thrown and the attachment will not be downloaded.
NOTE: To have the ability to cancel the attachment download, third parties will need to keep a reference of the AttachmentDownloadmanger object.
Example:
Step 1: Create a class to implement DownloadProgressListener. e.g. class AttachmentAction implements DownloadProgressListener
Step 2: Override the DownloadProgressListener's callbacks.
Step 3: Initialize AttachmentDownloadManager. e.g. AttachmentDownloadManager adm = new AttachmentDownloadManager();
Step 4: Call AttachmentDownloadManager's download method. e.g. adm.download(bodyPart, null, this); // this is the class that implements DownloadProgressListener; bodyPart is (un)supportedAttachmentPart.
Constructor Summary | ||
---|---|---|
|
AttachmentDownloadManager()
Constructor to initialize AttachmentDownloadManager instance. |
Method Summary | ||
---|---|---|
|
boolean |
cancelDownload(BodyPart bodyPart)
Cancel downloading. |
|
void |
download(BodyPart bodyPart,
String path,
DownloadProgressListener listener)
Download an attachment. |
|
void |
download(BodyPart[] bodyParts,
String path,
DownloadProgressListener listener)
Download a series of attachments. |
|
BodyPart[] |
getAttachmentBodyParts(Message msg)
Return a BodyPart array whose elements contain info of file attachment. |
|
String |
getDefaultLocation(BodyPart bodyPart)
Return the default location of the body part. |
|
String[] |
getDefaultLocations(BodyPart[] bodyParts)
Return an array of default locations. |
|
String |
getDownloadedFileName(BodyPart bodyPart)
Return the downloaded file path and name. |
|
String |
getFileContentType(BodyPart bodyPart)
Return file content type. |
|
String |
getFileName(BodyPart bodyPart)
Return the attchment name. |
|
int |
getFileSize(BodyPart bodyPart)
Return the file size. |
|
boolean |
isDownloaded(BodyPart bodyPart)
Check if the file attachment associated with the bodyPart has been downloaded. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AttachmentDownloadManager()
Method Detail |
---|
public void download(BodyPart bodyPart, String path, DownloadProgressListener listener) throws IOException
bodyPart
- - a bodypart object contains info of the email attachment.path
- – define a path where the attachment is stored. A default path is used if it is null.listener
- – A downloadProgressListener provides callbacks for downloading status. e.g. completed, in progress, or cancelled (or failed).
IllegalArgumentException
- - throws when the BodyPart is null.
IOException
- - throws if attachments already downloaded, attachment size excceeds the maximum limit set by IT,
IllegalStateException
- - throws if the attachment is being downloaded.
UnsupportedOperationException
- - throws if the message is encrypted, or the body part does not carry attachment info.
FileIOException
- - throws if there is not enough memory to download the bodyPart's attachment.
ControlledAccessException
- - throws if users are not granted to access message-related and file features or cross communicate between applications.public void download(BodyPart[] bodyParts, String path, DownloadProgressListener listener) throws IOException
if an element in the bodypart array does not contains attachment info, an UnsupportedOperationException will be thrown.
bodyPart
- - a bodypart object contains info of the email attachment.path
- – define a path where the attachment is stored. A default path is used if it is null.listener
- – A downloadProgressListener provides callbacks for downloading status. e.g. completed, in progress, or cancelled (or failed).
IllegalArgumentException
- throws if bodyPart array is null or empty.
ControlledAccessException
- - throws if users are not granted to access message-related and file features or cross communicate between applications.
UnsupportedOperationException
- - throws if the message is encrypted or a bodyPart in the BodyPart array does not carry attachment info.
FileIOException
- - throws if the filesystem does not have enough space available to save the attachments.
IOException
public boolean cancelDownload(BodyPart bodyPart)
bodyPart
- - a bodypart object contains info of the email attachment.
UnsupportedOperationException
- - throws if the bodyPart does not carry attachment info.
ControlledAccessException
- - throws if users are not granted to access message-related features.public String getDefaultLocation(BodyPart bodyPart)
bodyPart
- bodyPart containing attachments
IllegalArgumentException
- if bodyPart is null.
ControlledAccessException
- - throws if users are not granted to access message-related and file features.public String[] getDefaultLocations(BodyPart[] bodyParts)
bodyParts
- an array of bodyPart; each of which contains attachments
IllegalArgumentException
- if bodyParts or any of an array element is null.
ControlledAccessException
- - throws if users are not granted to access message-related and file features.public String getFileContentType(BodyPart bodyPart)
bodyPart
- - a bodypart object contains info of the email attachment.
ControlledAccessException
- - throws if users are not granted to access message-related features.public String getFileName(BodyPart bodyPart)
bodyPart
- - a bodypart object contains info of the email attachment.
ControlledAccessException
- - throws if users are not granted to access message-related features.public int getFileSize(BodyPart bodyPart)
bodyPart
- - a bodypart object contains info of the email attachment.
UnsupportedOperationException
- - throws if the bodyPart does not carry attachment info.
ControlledAccessException
- - throws if users are not granted to access message-related feature.public boolean isDownloaded(BodyPart bodyPart)
bodyPart
- - the body part object.
public String getDownloadedFileName(BodyPart bodyPart)
bodyPart
- - a bodypart object contains info of the email attachment.
public BodyPart[] getAttachmentBodyParts(Message msg)
Message
- - the email message object.
ControlledAccessException
- - throws if users are not granted to access message-related features.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal