Store (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.mail Class Store

java.lang.Object
  extended by javax.mail.Service
      extended by javax.mail.Store

public abstract class Store
extends Service

An abstract class that models a message store and its access protocol, for storing and retrieving messages. Subclasses provide actual implementations.

Note that Store extends the Service class, which provides many common methods for naming stores, connecting to stores, and listening to connection events.

版本:
1.28, 07/05/04
作者:
John Mani, Bill Shannon
另请参见:
Service, ConnectionEvent, StoreEvent

字段摘要
 
Fields inherited from class javax.mail.Service
debug, session, url
 
构造器摘要
protected Store(Session session, URLName urlname)
          Constructor.
 
方法摘要
 void addFolderListener(FolderListener l)
          Add a listener for Folder events on any Folder object obtained from this Store.
 void addStoreListener(StoreListener l)
          Add a listener for StoreEvents on this Store.
abstract  Folder getDefaultFolder()
          Returns a Folder object that represents the 'root' of the default namespace presented to the user by the Store.
abstract  Folder getFolder(String name)
          Return the Folder object corresponding to the given name.
abstract  Folder getFolder(URLName url)
          Return a closed Folder object, corresponding to the given URLName.
 Folder[] getPersonalNamespaces()
          Return a set of folders representing the personal namespaces for the current user.
 Folder[] getSharedNamespaces()
          Return a set of folders representing the shared namespaces.
 Folder[] getUserNamespaces(String user)
          Return a set of folders representing the namespaces for user.
protected  void notifyFolderListeners(int type, Folder folder)
          Notify all FolderListeners.
protected  void notifyFolderRenamedListeners(Folder oldF, Folder newF)
          Notify all FolderListeners about the renaming of a folder.
protected  void notifyStoreListeners(int type, String message)
          Notify all StoreListeners.
 void removeFolderListener(FolderListener l)
          Remove a listener for Folder events.
 void removeStoreListener(StoreListener l)
          Remove a listener for Store events.
 
类方法继承 javax.mail.Service
addConnectionListener, close, connect, connect, connect, connect, finalize, getURLName, isConnected, notifyConnectionListeners, protocolConnect, queueEvent, removeConnectionListener, setConnected, setURLName, toString
 
类方法继承 java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

构造器详细信息

Store

protected Store(Session session,
                URLName urlname)
Constructor.

参数:
session - Session object for this Store.
urlname - URLName object to be used for this Store

方法详细信息

getDefaultFolder

public abstract Folder getDefaultFolder()
                                 throws MessagingException
Returns a Folder object that represents the 'root' of the default namespace presented to the user by the Store.

返回:
the root Folder
抛出异常:
IllegalStateException - if this Store is not connected.
MessagingException

getFolder

public abstract Folder getFolder(String name)
                          throws MessagingException
Return the Folder object corresponding to the given name. Note that a Folder object is returned even if the named folder does not physically exist on the Store. The exists() method on the folder object indicates whether this folder really exists.

Folder objects are not cached by the Store, so invoking this method on the same name multiple times will return that many distinct Folder objects.

参数:
name - The name of the Folder. In some Stores, name can be an absolute path if it starts with the hierarchy delimiter. Else it is interpreted relative to the 'root' of this namespace.
返回:
Folder object
抛出异常:
IllegalStateException - if this Store is not connected.
MessagingException
另请参见:
Folder.exists(), Folder.create(int)

getFolder

public abstract Folder getFolder(URLName url)
                          throws MessagingException
Return a closed Folder object, corresponding to the given URLName. The store specified in the given URLName should refer to this Store object.

Implementations of this method may obtain the name of the actual folder using the getFile() method on URLName, and use that name to create the folder.

参数:
url - URLName that denotes a folder
返回:
Folder object
抛出异常:
IllegalStateException - if this Store is not connected.
MessagingException
另请参见:
URLName

getPersonalNamespaces

public Folder[] getPersonalNamespaces()
                               throws MessagingException
Return a set of folders representing the personal namespaces for the current user. A personal namespace is a set of names that is considered within the personal scope of the authenticated user. Typically, only the authenticated user has access to mail folders in their personal namespace. If an INBOX exists for a user, it must appear within the user's personal namespace. In the typical case, there should be only one personal namespace for each user in each Store.

This implementation returns an array with a single entry containing the return value of the getDefaultFolder method. Subclasses should override this method to return appropriate information.

返回:
array of Folder objects
抛出异常:
IllegalStateException - if this Store is not connected.
MessagingException
从以下版本开始:
JavaMail 1.2

getUserNamespaces

public Folder[] getUserNamespaces(String user)
                           throws MessagingException
Return a set of folders representing the namespaces for user. The namespaces returned represent the personal namespaces for the user. To access mail folders in the other user's namespace, the currently authenticated user must be explicitly granted access rights. For example, it is common for a manager to grant to their secretary access rights to their mail folders.

This implementation returns an empty array. Subclasses should override this method to return appropriate information.

返回:
array of Folder objects
抛出异常:
IllegalStateException - if this Store is not connected.
MessagingException
从以下版本开始:
JavaMail 1.2

getSharedNamespaces

public Folder[] getSharedNamespaces()
                             throws MessagingException
Return a set of folders representing the shared namespaces. A shared namespace is a namespace that consists of mail folders that are intended to be shared amongst users and do not exist within a user's personal namespace.

This implementation returns an empty array. Subclasses should override this method to return appropriate information.

返回:
array of Folder objects
抛出异常:
IllegalStateException - if this Store is not connected.
MessagingException
从以下版本开始:
JavaMail 1.2

addStoreListener

public void addStoreListener(StoreListener l)
Add a listener for StoreEvents on this Store.

The default implementation provided here adds this listener to an internal list of StoreListeners.

参数:
l - the Listener for Store events
另请参见:
StoreEvent

removeStoreListener

public void removeStoreListener(StoreListener l)
Remove a listener for Store events.

The default implementation provided here removes this listener from the internal list of StoreListeners.

参数:
l - the listener
另请参见:
addStoreListener(javax.mail.event.StoreListener)

notifyStoreListeners

protected void notifyStoreListeners(int type,
                                    String message)
Notify all StoreListeners. Store implementations are expected to use this method to broadcast StoreEvents.

The provided default implementation queues the event into an internal event queue. An event dispatcher thread dequeues events from the queue and dispatches them to the registered StoreListeners. Note that the event dispatching occurs in a separate thread, thus avoiding potential deadlock problems.


addFolderListener

public void addFolderListener(FolderListener l)
Add a listener for Folder events on any Folder object obtained from this Store. FolderEvents are delivered to FolderListeners on the affected Folder as well as to FolderListeners on the containing Store.

The default implementation provided here adds this listener to an internal list of FolderListeners.

参数:
l - the Listener for Folder events
另请参见:
FolderEvent

removeFolderListener

public void removeFolderListener(FolderListener l)
Remove a listener for Folder events.

The default implementation provided here removes this listener from the internal list of FolderListeners.

参数:
l - the listener
另请参见:
addFolderListener(javax.mail.event.FolderListener)

notifyFolderListeners

protected void notifyFolderListeners(int type,
                                     Folder folder)
Notify all FolderListeners. Store implementations are expected to use this method to broadcast Folder events.

The provided default implementation queues the event into an internal event queue. An event dispatcher thread dequeues events from the queue and dispatches them to the registered FolderListeners. Note that the event dispatching occurs in a separate thread, thus avoiding potential deadlock problems.

参数:
type - type of FolderEvent
folder - affected Folder
另请参见:
notifyFolderRenamedListeners(javax.mail.Folder, javax.mail.Folder)

notifyFolderRenamedListeners

protected void notifyFolderRenamedListeners(Folder oldF,
                                            Folder newF)
Notify all FolderListeners about the renaming of a folder. Store implementations are expected to use this method to broadcast Folder events indicating the renaming of folders.

The provided default implementation queues the event into an internal event queue. An event dispatcher thread dequeues events from the queue and dispatches them to the registered FolderListeners. Note that the event dispatching occurs in a separate thread, thus avoiding potential deadlock problems.

参数:
oldF - the folder being renamed
newF - the folder representing the new name.
从以下版本开始:
JavaMail 1.1

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.