com.sun.mail.pop3
类 DefaultFolder

java.lang.Object
  继承者 javax.mail.Folder
      继承者 com.sun.mail.pop3.DefaultFolder

public class DefaultFolder
extends Folder

The POP3 DefaultFolder. Only contains the "INBOX" folder.

版本:
1.8, 07/05/04
作者:
Christopher Cotton

字段摘要
 
从类 javax.mail.Folder 继承的字段
HOLDS_FOLDERS, HOLDS_MESSAGES, mode, READ_ONLY, READ_WRITE, store
 
方法摘要
 void appendMessages(Message[] msgs)
          Append given Messages to this folder.
 void close(boolean expunge)
          Close this Folder.
 boolean create(int type)
          Create this folder on the Store.
 boolean delete(boolean recurse)
          Delete this Folder.
 boolean exists()
          Tests if this folder physically exists on the Store.
 Message[] expunge()
          Expunge (permanently remove) messages marked DELETED.
 Folder getFolder(String name)
          Return the Folder object corresponding to the given name.
 String getFullName()
          Returns the full name of this Folder.
protected  Folder getInbox()
           
 Message getMessage(int msgno)
          Get the Message object corresponding to the given message number.
 int getMessageCount()
          Get total number of messages in this Folder.
 String getName()
          Returns the name of this Folder.
 Folder getParent()
          Returns the parent folder of this folder.
 Flags getPermanentFlags()
          Get the permanent flags supported by this Folder.
 char getSeparator()
          Return the delimiter character that separates this Folder's pathname from the names of immediate subfolders.
 int getType()
          Returns the type of this Folder, that is, whether this folder can hold messages or subfolders or both.
 boolean hasNewMessages()
          Returns true if this Folder has new messages since the last time this indication was reset.
 boolean isOpen()
          Indicates whether this Folder is in the 'open' state.
 Folder[] list(String pattern)
          Returns a list of Folders belonging to this Folder's namespace that match the specified pattern.
 void open(int mode)
          Open this Folder.
 boolean renameTo(Folder f)
          Rename this Folder.
 
从类 javax.mail.Folder 继承的方法
addConnectionListener, addFolderListener, addMessageChangedListener, addMessageCountListener, copyMessages, fetch, finalize, getDeletedMessageCount, getMessages, getMessages, getMessages, getMode, getNewMessageCount, getStore, getUnreadMessageCount, getURLName, isSubscribed, list, listSubscribed, listSubscribed, notifyConnectionListeners, notifyFolderListeners, notifyFolderRenamedListeners, notifyMessageAddedListeners, notifyMessageChangedListeners, notifyMessageRemovedListeners, removeConnectionListener, removeFolderListener, removeMessageChangedListener, removeMessageCountListener, search, search, setFlags, setFlags, setFlags, setSubscribed, toString
 
从类 java.lang.Object 继承的方法
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

方法详细信息

getName

public String getName()
从类 Folder 复制的描述
Returns the name of this Folder.

This method can be invoked on a closed Folder.

指定者:
Folder 中的 getName
返回:
name of the Folder

getFullName

public String getFullName()
从类 Folder 复制的描述
Returns the full name of this Folder. If the folder resides under the root hierarchy of this Store, the returned name is relative to the root. Otherwise an absolute name, starting with the hierarchy delimiter, is returned.

This method can be invoked on a closed Folder.

指定者:
Folder 中的 getFullName
返回:
full name of the Folder

getParent

public Folder getParent()
从类 Folder 复制的描述
Returns the parent folder of this folder. This method can be invoked on a closed Folder. If this folder is the top of a folder hierarchy, this method returns null.

Note that since Folder objects are not cached, invoking this method returns a new distinct Folder object.

指定者:
Folder 中的 getParent
返回:
Parent folder

exists

public boolean exists()
从类 Folder 复制的描述
Tests if this folder physically exists on the Store. This method can be invoked on a closed Folder.

指定者:
Folder 中的 exists
返回:
true if the folder exists, otherwise false
另请参见:
Folder.create(int)

list

public Folder[] list(String pattern)
              throws MessagingException
从类 Folder 复制的描述
Returns a list of Folders belonging to this Folder's namespace that match the specified pattern. Patterns may contain the wildcard characters "%", which matches any character except hierarchy delimiters, and "*", which matches any character.

As an example, given the folder hierarchy:

    Personal/
       Finance/
          Stocks
          Bonus
          StockOptions
       Jokes
 
list("*") on "Personal" will return the whole hierarchy.
list("%") on "Personal" will return "Finance" and "Jokes".
list("Jokes") on "Personal" will return "Jokes".
list("Stock*") on "Finance" will return "Stocks" and "StockOptions".

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

This method can be invoked on a closed Folder.

指定者:
Folder 中的 list
参数:
pattern - the match pattern
返回:
array of matching Folder objects. An empty array is returned if no matching Folders exist.
抛出:
FolderNotFoundException - if this folder does not exist.
MessagingException
另请参见:
Folder.listSubscribed(java.lang.String)

getSeparator

public char getSeparator()
从类 Folder 复制的描述
Return the delimiter character that separates this Folder's pathname from the names of immediate subfolders. This method can be invoked on a closed Folder.

指定者:
Folder 中的 getSeparator
返回:
Hierarchy separator character

getType

public int getType()
从类 Folder 复制的描述
Returns the type of this Folder, that is, whether this folder can hold messages or subfolders or both. The returned value is an integer bitfield with the appropriate bits set. This method can be invoked on a closed folder.

指定者:
Folder 中的 getType
返回:
integer with appropriate bits set
另请参见:
Folder.HOLDS_FOLDERS, Folder.HOLDS_MESSAGES

create

public boolean create(int type)
               throws MessagingException
从类 Folder 复制的描述
Create this folder on the Store. When this folder is created, any folders in its path that do not exist are also created.

If the creation is successful, a CREATED FolderEvent is delivered to any FolderListeners registered on this Folder and this Store.

指定者:
Folder 中的 create
参数:
type - The type of this folder.
返回:
true if the creation succeeds, else false.
抛出:
MessagingException
另请参见:
Folder.HOLDS_FOLDERS, Folder.HOLDS_MESSAGES, FolderEvent

hasNewMessages

public boolean hasNewMessages()
                       throws MessagingException
从类 Folder 复制的描述
Returns true if this Folder has new messages since the last time this indication was reset. When this indication is set or reset depends on the Folder implementation (and in the case of IMAP, depends on the server). This method can be used to implement a lightweight "check for new mail" operation on a Folder without opening it. (For example, a thread that monitors a mailbox and flags when it has new mail.) This method should indicate whether any messages in the Folder have the RECENT flag set.

Note that this is not an incremental check for new mail, i.e., it cannot be used to determine whether any new messages have arrived since the last time this method was invoked. To implement incremental checks, the Folder needs to be opened.

This method can be invoked on a closed Folder that can contain Messages.

指定者:
Folder 中的 hasNewMessages
返回:
true if the Store has new Messages
抛出:
FolderNotFoundException - if this folder does not exist.
MessagingException

getFolder

public Folder getFolder(String name)
                 throws MessagingException
从类 Folder 复制的描述
Return the Folder object corresponding to the given name. Note that this folder does not physically have to exist in the Store. The exists() method on a Folder indicates whether it really exists on the Store.

In some Stores, name can be an absolute path if it starts with the hierarchy delimiter. Otherwise, it is interpreted relative to this Folder.

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.

This method can be invoked on a closed Folder.

指定者:
Folder 中的 getFolder
参数:
name - name of the Folder
返回:
Folder object
抛出:
MessagingException

getInbox

protected Folder getInbox()
                   throws MessagingException
抛出:
MessagingException

delete

public boolean delete(boolean recurse)
               throws MessagingException
从类 Folder 复制的描述
Delete this Folder. This method will succeed only on a closed Folder.

The recurse flag controls whether the deletion affects subfolders or not. If true, all subfolders are deleted, then this folder itself is deleted. If false, the behaviour is dependent on the folder type and is elaborated below:

指定者:
Folder 中的 delete
返回:
true if the Folder is deleted successfully
抛出:
FolderNotFoundException - if this folder does not exist
MessagingException
另请参见:
FolderEvent

renameTo

public boolean renameTo(Folder f)
                 throws MessagingException
从类 Folder 复制的描述
Rename this Folder. This method will succeed only on a closed Folder.

If the rename is successful, a RENAMED FolderEvent is delivered to FolderListeners registered on this folder and its containing Store.

指定者:
Folder 中的 renameTo
参数:
f - a folder representing the new name for this Folder
返回:
true if the Folder is renamed successfully
抛出:
FolderNotFoundException - if this folder does not exist
MessagingException
另请参见:
FolderEvent

open

public void open(int mode)
          throws MessagingException
从类 Folder 复制的描述
Open this Folder. This method is valid only on Folders that can contain Messages and that are closed.

If this folder is opened successfully, an OPENED ConnectionEvent is delivered to any ConnectionListeners registered on this Folder.

The effect of opening multiple connections to the same folder on a specifc Store is implementation dependent. Some implementations allow multiple readers, but only one writer. Others allow multiple writers as well as readers.

指定者:
Folder 中的 open
参数:
mode - open the Folder READ_ONLY or READ_WRITE
抛出:
FolderNotFoundException - if this folder does not exist.
MessagingException
另请参见:
Folder.READ_ONLY, Folder.READ_WRITE, Folder.getType(), ConnectionEvent

close

public void close(boolean expunge)
           throws MessagingException
从类 Folder 复制的描述
Close this Folder. This method is valid only on open Folders.

A CLOSED ConnectionEvent is delivered to any ConnectionListeners registered on this Folder. Note that the folder is closed even if this method terminates abnormally by throwing a MessagingException.

指定者:
Folder 中的 close
参数:
expunge - expunges all deleted messages if this flag is true
抛出:
MessagingException
另请参见:
ConnectionEvent

isOpen

public boolean isOpen()
从类 Folder 复制的描述
Indicates whether this Folder is in the 'open' state.

指定者:
Folder 中的 isOpen
返回:
true if this Folder is in the 'open' state.

getPermanentFlags

public Flags getPermanentFlags()
从类 Folder 复制的描述
Get the permanent flags supported by this Folder. Returns a Flags object that contains all the flags supported.

The special flag Flags.USER indicates that this Folder supports arbitrary user-defined flags.

The supported permanent flags for a folder may not be available until the folder is opened.

指定者:
Folder 中的 getPermanentFlags
返回:
permanent flags, or null if not known

getMessageCount

public int getMessageCount()
                    throws MessagingException
从类 Folder 复制的描述
Get total number of messages in this Folder.

This method can be invoked on a closed folder. However, note that for some folder implementations, getting the total message count can be an expensive operation involving actually opening the folder. In such cases, a provider can choose not to support this functionality in the closed state, in which case this method must return -1.

Clients invoking this method on a closed folder must be aware that this is a potentially expensive operation. Clients must also be prepared to handle a return value of -1 in this case.

指定者:
Folder 中的 getMessageCount
返回:
total number of messages. -1 may be returned by certain implementations if this method is invoked on a closed folder.
抛出:
FolderNotFoundException - if this folder does not exist.
MessagingException

getMessage

public Message getMessage(int msgno)
                   throws MessagingException
从类 Folder 复制的描述
Get the Message object corresponding to the given message number. A Message object's message number is the relative position of this Message in its Folder. Messages are numbered starting at 1 through the total number of message in the folder. Note that the message number for a particular Message can change during a session if other messages in the Folder are deleted and the Folder is expunged.

Message objects are light-weight references to the actual message that get filled up on demand. Hence Folder implementations are expected to provide light-weight Message objects.

Unlike Folder objects, repeated calls to getMessage with the same message number will return the same Message object, as long as no messages in this folder have been expunged.

Since message numbers can change within a session if the folder is expunged , clients are advised not to use message numbers as references to messages. Use Message objects instead.

指定者:
Folder 中的 getMessage
参数:
msgno - the message number
返回:
the Message object
抛出:
FolderNotFoundException - if this folder does not exist.
MessagingException
另请参见:
Folder.getMessageCount(), Folder.fetch(javax.mail.Message[], javax.mail.FetchProfile)

appendMessages

public void appendMessages(Message[] msgs)
                    throws MessagingException
从类 Folder 复制的描述
Append given Messages to this folder. This method can be invoked on a closed Folder. An appropriate MessageCountEvent is delivered to any MessageCountListener registered on this folder when the messages arrive in the folder.

Folder implementations must not abort this operation if a Message in the given message array turns out to be an expunged Message.

指定者:
Folder 中的 appendMessages
参数:
msgs - array of Messages to be appended
抛出:
FolderNotFoundException - if this folder does not exist.
MessagingException - if the append failed.

expunge

public Message[] expunge()
                  throws MessagingException
从类 Folder 复制的描述
Expunge (permanently remove) messages marked DELETED. Returns an array containing the expunged message objects. The getMessageNumber method on each of these message objects returns that Message's original (that is, prior to the expunge) sequence number. A MessageCountEvent containing the expunged messages is delivered to any MessageCountListeners registered on the folder.

Expunge causes the renumbering of Message objects subsequent to the expunged messages. Clients that use message numbers as references to messages should be aware of this and should be prepared to deal with the situation (probably by flushing out existing message number caches and reloading them). Because of this complexity, it is better for clients to use Message objects as references to messages, rather than message numbers. Any expunged Messages objects still have to be pruned, but other Messages in that folder are not affected by the expunge.

After a message is expunged, only the isExpunged and getMessageNumber methods are still valid on the corresponding Message object; other methods may throw MessageRemovedException

指定者:
Folder 中的 expunge
返回:
array of expunged Message objects
抛出:
FolderNotFoundException - if this folder does not exist
MessagingException
另请参见:
Message.isExpunged(), MessageCountEvent


Copyright © 2013. All Rights Reserved.