public class IMAPStore extends Store implements ResponseHandler
Applications that need to make use of IMAP-specific features may cast
a Store
object to an IMAPStore
object and
use the methods on this class. The getQuota
and
setQuota
methods support the IMAP QUOTA extension.
Refer to RFC 2087
for more information.
See the com.sun.mail.imap package documentation for further information on the IMAP protocol provider.
WARNING: The APIs unique to this class should be considered EXPERIMENTAL. They may be changed in the future in ways that are incompatible with applications using the current APIs.
Modifier and Type | Field and Description |
---|---|
static int |
RESPONSE
A special event type for a StoreEvent to indicate an IMAP
response, if the mail.imap.enableimapevents property is set.
|
Constructor and Description |
---|
IMAPStore(Session session,
URLName url)
Constructor that takes a Session object and a URLName that
represents a specific IMAP server.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this Store.
|
Folder |
getDefaultFolder()
Get the default folder, representing the root of this user's
namespace.
|
Folder |
getFolder(java.lang.String name)
Get named folder.
|
Folder |
getFolder(URLName url)
Get named folder.
|
Folder[] |
getPersonalNamespaces()
Using the IMAP NAMESPACE command (RFC 2342), return a set
of folders representing the Personal namespaces.
|
Quota[] |
getQuota(java.lang.String root)
Get the quotas for the named quota root.
|
Folder[] |
getSharedNamespaces()
Using the IMAP NAMESPACE command (RFC 2342), return a set
of folders representing the Shared namespaces.
|
Folder[] |
getUserNamespaces(java.lang.String user)
Using the IMAP NAMESPACE command (RFC 2342), return a set
of folders representing the User's namespaces.
|
void |
handleResponse(Response r)
Response handler method.
|
boolean |
hasCapability(java.lang.String capability)
Return true if the specified capability string is in the list
of capabilities the server announced.
|
void |
idle()
Use the IMAP IDLE command (see
RFC 2177),
if supported by the server, to enter idle mode so that the server
can send unsolicited notifications
without the need for the client to constantly poll the server.
|
boolean |
isConnected()
Check whether this store is connected.
|
boolean |
isSSL()
Does this IMAPStore use SSL when connecting to the server?
|
void |
setPassword(java.lang.String password)
Set the password that will be used for subsequent connections
after this Store is first connected (for example, when creating
a connection to open a Folder).
|
void |
setQuota(Quota quota)
Set the quotas for the quota root specified in the quota argument.
|
void |
setUsername(java.lang.String user)
Set the user name that will be used for subsequent connections
after this Store is first connected (for example, when creating
a connection to open a Folder).
|
public static final int RESPONSE
public IMAPStore(Session session, URLName url)
public boolean isSSL()
public void setUsername(java.lang.String user)
Some IMAP servers may provide an authentication ID that can be used for more efficient authentication for future connections. This authentication ID is provided in a server-specific manner not described here.
Most applications will never need to use this method.
public void setPassword(java.lang.String password)
Most applications will never need to use this method.
public boolean hasCapability(java.lang.String capability) throws MessagingException
MessagingException
public boolean isConnected()
public void close() throws MessagingException
MessagingException
public Folder getDefaultFolder() throws MessagingException
MessagingException
public Folder getFolder(java.lang.String name) throws MessagingException
MessagingException
public Folder getFolder(URLName url) throws MessagingException
MessagingException
public Folder[] getPersonalNamespaces() throws MessagingException
MessagingException
public Folder[] getUserNamespaces(java.lang.String user) throws MessagingException
MessagingException
public Folder[] getSharedNamespaces() throws MessagingException
MessagingException
public Quota[] getQuota(java.lang.String root) throws MessagingException
root
- the name of the quota rootMessagingException
- if the server doesn't support the
QUOTA extensionpublic void setQuota(Quota quota) throws MessagingException
getQuota
method, but it need not be.quota
- the quota to setMessagingException
- if the server doesn't support the
QUOTA extensionpublic void handleResponse(Response r)
handleResponse
in interface ResponseHandler
public void idle() throws MessagingException
ConnectionListener
to be notified of
events. When another thread (e.g., the listener thread)
needs to issue an IMAP comand for this Store, the idle mode will
be terminated and this method will return. Typically the caller
will invoke this method in a loop.
If the mail.imap.enableimapevents property is set, notifications
received while the IDLE command is active will be delivered to
ConnectionListener
s as events with a type of
IMAPStore.RESPONSE
. The event's message will be
the raw IMAP response string.
Note that most IMAP servers will not deliver any events when
using the IDLE command on a connection with no mailbox selected
(i.e., this method). In most cases you'll want to use the
idle
method on IMAPFolder
.
NOTE: This capability is highly experimental and likely will change in future releases.
The mail.imap.minidletime property enforces a minimum delay before returning from this method, to ensure that other threads have a chance to issue commands before the caller invokes this method again. The default delay is 10 milliseconds.
MessagingException
- if the server doesn't support the
IDLE extensionjava.lang.IllegalStateException
- if the store isn't connected"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"