Top Description Fields Constructors Methods
com.sun.mail.pop3

public Class DefaultFolder

extends Folder
Class Inheritance
Imports
javax.mail.*

The POP3 DefaultFolder. Only contains the "INBOX" folder.
Author
Christopher Cotton

Field Summary

Inherited from javax.mail.Folder:
HOLDS_FOLDERSHOLDS_MESSAGESmodeREAD_ONLYREAD_WRITEstore

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
appendMessages(Message[]
array of Messages to be appended
msgs
)

Implements abstract javax.mail.Folder.appendMessages.

Append given Messages to this folder.
public void
close(boolean
expunges all deleted messages if this flag is true
expunge
)

Implements abstract javax.mail.Folder.close.

Close this Folder.
public boolean
create(int
The type of this folder.
type
)

Implements abstract javax.mail.Folder.create.

Create this folder on the Store.
public boolean
delete(boolean
also delete subfolders?
recurse
)

Implements abstract javax.mail.Folder.delete.

Delete this Folder.
public boolean
exists()

Implements abstract javax.mail.Folder.exists.

Tests if this folder physically exists on the Store.
public Message[]
expunge()

Implements abstract javax.mail.Folder.expunge.

Expunge (permanently remove) messages marked DELETED.
public Folder
getFolder(String
name of the Folder
name
)

Implements abstract javax.mail.Folder.getFolder.

Return the Folder object corresponding to the given name.
public String
getFullName()

Implements abstract javax.mail.Folder.getFullName.

Returns the full name of this Folder.
protected Folder
public Message
getMessage(int
the message number
msgno
)

Implements abstract javax.mail.Folder.getMessage.

Get the Message object corresponding to the given message number.
public int
getMessageCount()

Implements abstract javax.mail.Folder.getMessageCount.

Get total number of messages in this Folder.
public String
getName()

Implements abstract javax.mail.Folder.getName.

Returns the name of this Folder.
public Folder
getParent()

Implements abstract javax.mail.Folder.getParent.

Returns the parent folder of this folder.
public Flags
getPermanentFlags()

Implements abstract javax.mail.Folder.getPermanentFlags.

Get the permanent flags supported by this Folder.
public char
getSeparator()

Implements abstract javax.mail.Folder.getSeparator.

Return the delimiter character that separates this Folder's pathname from the names of immediate subfolders.
public int
getType()

Implements abstract javax.mail.Folder.getType.

Returns the type of this Folder, that is, whether this folder can hold messages or subfolders or both.
public boolean
hasNewMessages()

Implements abstract javax.mail.Folder.hasNewMessages.

Returns true if this Folder has new messages since the last time this indication was reset.
public boolean
isOpen()

Implements abstract javax.mail.Folder.isOpen.

Indicates whether this Folder is in the 'open' state.
public Folder[]
list(String
the match pattern
pattern
)

Implements abstract javax.mail.Folder.list.

Returns a list of Folders belonging to this Folder's namespace that match the specified pattern.
public void
open(int
open the Folder READ_ONLY or READ_WRITE
mode
)

Implements abstract javax.mail.Folder.open.

Open this Folder.
public boolean
renameTo(Folder
a folder representing the new name for this Folder
f
)

Implements abstract javax.mail.Folder.renameTo.

Rename this Folder.
Inherited from javax.mail.Folder:
addConnectionListeneraddFolderListeneraddMessageChangedListeneraddMessageCountListenerclosecopyMessagesfetchfinalizegetDeletedMessageCountgetMessagesgetMessagesgetMessagesgetModegetNewMessageCountgetStoregetUnreadMessageCountgetURLNameisSubscribedlistlistSubscribedlistSubscribednotifyConnectionListenersnotifyFolderListenersnotifyFolderRenamedListenersnotifyMessageAddedListenersnotifyMessageChangedListenersnotifyMessageRemovedListenersremoveConnectionListenerremoveFolderListenerremoveMessageChangedListenerremoveMessageCountListenersearchsearchsetFlagssetFlagssetFlagssetSubscribedtoString

Constructor Detail

DefaultFolderback to summary
pack-priv DefaultFolder(POP3Store store)

Method Detail

appendMessagesback to summary
public void appendMessages(Message[] msgs) throws MessagingException

Implements abstract javax.mail.Folder.appendMessages.

Doc from javax.mail.Folder.appendMessages.

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.

Parameters
msgs:Message[]

array of Messages to be appended

Annotations
@Override
Exceptions
MessagingException:
if the append failed.
closeback to summary
public void close(boolean expunge) throws MessagingException

Implements abstract javax.mail.Folder.close.

Doc from javax.mail.Folder.close.

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.

Parameters
expunge:boolean

expunges all deleted messages if this flag is true

Annotations
@Override
Exceptions
MessagingException:
for other failures
createback to summary
public boolean create(int type) throws MessagingException

Implements abstract javax.mail.Folder.create.

Doc from javax.mail.Folder.create.

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.

Parameters
type:int

The type of this folder.

Returns:boolean

true if the creation succeeds, else false.

Annotations
@Override
Exceptions
MessagingException:
for failures
deleteback to summary
public boolean delete(boolean recurse) throws MessagingException

Implements abstract javax.mail.Folder.delete.

Doc from javax.mail.Folder.delete.

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:

  • The folder can contain only messages: (type == HOLDS_MESSAGES).
    All messages within the folder are removed. The folder itself is then removed. An appropriate FolderEvent is generated by the Store and this folder.
  • The folder can contain only subfolders: (type == HOLDS_FOLDERS).
    If this folder is empty (does not contain any subfolders at all), it is removed. An appropriate FolderEvent is generated by the Store and this folder.
    If this folder contains any subfolders, the delete fails and returns false.
  • The folder can contain subfolders as well as messages:
    If the folder is empty (no messages or subfolders), it is removed. If the folder contains no subfolders, but only messages, then all messages are removed. The folder itself is then removed. In both the above cases, an appropriate FolderEvent is generated by the Store and this folder.

    If the folder contains subfolders there are 3 possible choices an implementation is free to do:

    1. The operation fails, irrespective of whether this folder contains messages or not. Some implementations might elect to go with this simple approach. The delete() method returns false.
    2. Any messages within the folder are removed. Subfolders are not removed. The folder itself is not removed or affected in any manner. The delete() method returns true. And the exists() method on this folder will return true indicating that this folder still exists.
      An appropriate FolderEvent is generated by the Store and this folder.
    3. Any messages within the folder are removed. Subfolders are not removed. The folder itself changes its type from HOLDS_FOLDERS | HOLDS_MESSAGES to HOLDS_FOLDERS. Thus new messages cannot be added to this folder, but new subfolders can be created underneath. The delete() method returns true indicating success. The exists() method on this folder will return true indicating that this folder still exists.
      An appropriate FolderEvent is generated by the Store and this folder.
Parameters
recurse:boolean

also delete subfolders?

Returns:boolean

true if the Folder is deleted successfully

Annotations
@Override
Exceptions
MessagingException:
for other failures
existsback to summary
public boolean exists()

Implements abstract javax.mail.Folder.exists.

Doc from javax.mail.Folder.exists.

Tests if this folder physically exists on the Store. This method can be invoked on a closed Folder.

Returns:boolean

true if the folder exists, otherwise false

Annotations
@Override
expungeback to summary
public Message[] expunge() throws MessagingException

Implements abstract javax.mail.Folder.expunge.

Doc from javax.mail.Folder.expunge.

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

Returns:Message[]

array of expunged Message objects

Annotations
@Override
Exceptions
MessagingException:
for other failures
getFolderback to summary
public Folder getFolder(String name) throws MessagingException

Implements abstract javax.mail.Folder.getFolder.

Doc from javax.mail.Folder.getFolder.

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.

Parameters
name:String

name of the Folder

Returns:Folder

Folder object

Annotations
@Override
Exceptions
MessagingException:
for failures
getFullNameback to summary
public String getFullName()

Implements abstract javax.mail.Folder.getFullName.

Doc from javax.mail.Folder.getFullName.

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.

Returns:String

full name of the Folder

Annotations
@Override
getInboxback to summary
protected Folder getInbox() throws MessagingException
getMessageback to summary
public Message getMessage(int msgno) throws MessagingException

Implements abstract javax.mail.Folder.getMessage.

Doc from javax.mail.Folder.getMessage.

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.

Parameters
msgno:int

the message number

Returns:Message

the Message object

Annotations
@Override
Exceptions
MessagingException:
for other failures
getMessageCountback to summary
public int getMessageCount() throws MessagingException

Implements abstract javax.mail.Folder.getMessageCount.

Doc from javax.mail.Folder.getMessageCount.

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.

Returns:int

total number of messages. -1 may be returned by certain implementations if this method is invoked on a closed folder.

Annotations
@Override
Exceptions
MessagingException:
for other failures
getNameback to summary
public String getName()

Implements abstract javax.mail.Folder.getName.

Doc from javax.mail.Folder.getName.

Returns the name of this Folder.

This method can be invoked on a closed Folder.

Returns:String

name of the Folder

Annotations
@Override
getParentback to summary
public Folder getParent()

Implements abstract javax.mail.Folder.getParent.

Doc from javax.mail.Folder.getParent.

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.

Returns:Folder

Parent folder

Annotations
@Override
getPermanentFlagsback to summary
public Flags getPermanentFlags()

Implements abstract javax.mail.Folder.getPermanentFlags.

Doc from javax.mail.Folder.getPermanentFlags.

Get the permanent flags supported by this Folder. Returns a Flags object that contains all the flags supported.

The special flag Flags.Flag.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.

Returns:Flags

permanent flags, or null if not known

Annotations
@Override
getSeparatorback to summary
public char getSeparator()

Implements abstract javax.mail.Folder.getSeparator.

Doc from javax.mail.Folder.getSeparator.

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.

Returns:char

Hierarchy separator character

Annotations
@Override
getTypeback to summary
public int getType()

Implements abstract javax.mail.Folder.getType.

Doc from javax.mail.Folder.getType.

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.

Returns:int

integer with appropriate bits set

Annotations
@Override
hasNewMessagesback to summary
public boolean hasNewMessages() throws MessagingException

Implements abstract javax.mail.Folder.hasNewMessages.

Doc from javax.mail.Folder.hasNewMessages.

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.

Returns:boolean

true if the Store has new Messages

Annotations
@Override
Exceptions
MessagingException:
for other failures
isOpenback to summary
public boolean isOpen()

Implements abstract javax.mail.Folder.isOpen.

Doc from javax.mail.Folder.isOpen.

Indicates whether this Folder is in the 'open' state.

Returns:boolean

true if this Folder is in the 'open' state.

Annotations
@Override
listback to summary
public Folder[] list(String pattern) throws MessagingException

Implements abstract javax.mail.Folder.list.

Doc from javax.mail.Folder.list.

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.

Parameters
pattern:String

the match pattern

Returns:Folder[]

array of matching Folder objects. An empty array is returned if no matching Folders exist.

Annotations
@Override
Exceptions
MessagingException:
for other failures
openback to summary
public void open(int mode) throws MessagingException

Implements abstract javax.mail.Folder.open.

Doc from javax.mail.Folder.open.

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.

Parameters
mode:int

open the Folder READ_ONLY or READ_WRITE

Annotations
@Override
Exceptions
MessagingException:
for other failures
renameToback to summary
public boolean renameTo(Folder f) throws MessagingException

Implements abstract javax.mail.Folder.renameTo.

Doc from javax.mail.Folder.renameTo.

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.

Parameters
f:Folder

a folder representing the new name for this Folder

Returns:boolean

true if the Folder is renamed successfully

Annotations
@Override
Exceptions
MessagingException:
for other failures