org.apache.geronimo.javamail.store.pop3
Class POP3Folder

java.lang.Object
  extended by javax.mail.Folder
      extended by org.apache.geronimo.javamail.store.pop3.POP3Folder
Direct Known Subclasses:
POP3RootFolder

public class POP3Folder
extends Folder

The POP3 implementation of the javax.mail.Folder Note that only INBOX is supported in POP3

http://www.faqs.org/rfcs/rfc1939.html

Version:
$Rev: 689140 $ $Date: 2008-08-26 13:20:01 -0400 (Tue, 26 Aug 2008) $
See Also:
Folder

Field Summary
protected  boolean exists
           
protected  int folderType
           
protected  String fullName
           
protected  boolean isFolderOpen
           
protected  int mode
           
protected  int msgCount
           
 
Fields inherited from class javax.mail.Folder
HOLDS_FOLDERS, HOLDS_MESSAGES, READ_ONLY, READ_WRITE, store
 
Constructor Summary
POP3Folder(POP3Store store, String name)
          Create a new folder associate with a POP3 store instance.
 
Method Summary
 void appendMessages(Message[] msgs)
           
protected  void cleanupFolder(boolean disconnected)
          Do folder cleanup.
 void close(boolean expunge)
          Close a POP3 folder.
 boolean create(int type)
          Always returns false as any creation operation must fail.
 boolean delete(boolean recurse)
           
 boolean exists()
          Indicate whether a folder exists.
 Message[] expunge()
           
protected  void expungeDeletedMessages(POP3Connection connection)
          Mark any messages we've flagged as deleted from the POP3 server before closing.
 void fetch(Message[] msgs, FetchProfile fp)
           
protected  POP3Connection getConnection()
          Retrieve the connection attached to this folder.
 Folder getFolder(String name)
           
 String getFullName()
          Retrieve the folder's full name (including hierarchy information).
 Message getMessage(int msgNum)
          Checks wether the message is in cache, if not will create a new message object and return it.
 int getMessageCount()
          Get the folder message count.
 int getMode()
           
 String getName()
          Retrieve the folder name.
 Folder getParent()
          Never return "this" as the parent folder.
 Flags getPermanentFlags()
           
 char getSeparator()
          No sub folders, hence there is no notion of a seperator.
 int getType()
          There's no hierarchy in POP3, so the only type is HOLDS_MESSAGES (and only one of those exists).
 String getUID(Message msg)
          Retrieve the UID for a given message.
 boolean hasNewMessages()
          No way to detect new messages, so always return false.
 boolean isOpen()
           
 Folder[] list(String pattern)
           
 void notifyMessageChangedListeners(int type, Message m)
           
 void open(int mode)
           
protected  void releaseConnection(POP3Connection connection)
          Release our connection back to the Store.
 boolean renameTo(Folder f)
           
 
Methods inherited from class javax.mail.Folder
addConnectionListener, addFolderListener, addMessageChangedListener, addMessageCountListener, copyMessages, finalize, getDeletedMessageCount, getMessages, getMessages, getMessages, getNewMessageCount, getStore, getUnreadMessageCount, getURLName, isSubscribed, list, listSubscribed, listSubscribed, notifyConnectionListeners, notifyFolderListeners, notifyFolderRenamedListeners, notifyMessageAddedListeners, notifyMessageRemovedListeners, removeConnectionListener, removeFolderListener, removeMessageChangedListener, removeMessageCountListener, search, search, setFlags, setFlags, setFlags, setSubscribed, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isFolderOpen

protected boolean isFolderOpen

mode

protected int mode

msgCount

protected int msgCount

fullName

protected String fullName

exists

protected boolean exists

folderType

protected int folderType
Constructor Detail

POP3Folder

public POP3Folder(POP3Store store,
                  String name)
Create a new folder associate with a POP3 store instance.

Parameters:
store - The owning Store.
name - The name of the folder. Note that POP3 stores only have 2 real folders, the root ("") and the in-basket ("INBOX"). It is possible to create other instances of Folder associated with the Store, but they will be non-functional.
Method Detail

getName

public String getName()
Retrieve the folder name. This is the simple folder name at the its hiearchy level. This can be invoked when the folder is closed.

Specified by:
getName in class Folder
Returns:
The folder's name.

getFullName

public String getFullName()
Retrieve the folder's full name (including hierarchy information). This can be invoked when the folder is closed.

Specified by:
getFullName in class Folder
Returns:
The full name value.

getParent

public Folder getParent()
                 throws MessagingException
Never return "this" as the parent folder. Somebody not familliar with POP3 may do something like while(getParent() != null) or something simmilar which will result in an infinte loop

Specified by:
getParent in class Folder
Throws:
MessagingException

exists

public boolean exists()
               throws MessagingException
Indicate whether a folder exists. Only the root folder and "INBOX" will ever return true.

Specified by:
exists in class Folder
Returns:
true for real POP3 folders, false for any other instances that have been created.
Throws:
MessagingException

list

public Folder[] list(String pattern)
              throws MessagingException
Specified by:
list in class Folder
Throws:
MessagingException

getSeparator

public char getSeparator()
                  throws MessagingException
No sub folders, hence there is no notion of a seperator. This is always a null character.

Specified by:
getSeparator in class Folder
Throws:
MessagingException

getType

public int getType()
            throws MessagingException
There's no hierarchy in POP3, so the only type is HOLDS_MESSAGES (and only one of those exists).

Specified by:
getType in class Folder
Returns:
Always returns HOLDS_MESSAGES.
Throws:
MessagingException

create

public boolean create(int type)
               throws MessagingException
Always returns false as any creation operation must fail.

Specified by:
create in class Folder
Parameters:
type - The type of folder to create. This is ignored.
Returns:
Always returns false.
Throws:
MessagingException

hasNewMessages

public boolean hasNewMessages()
                       throws MessagingException
No way to detect new messages, so always return false.

Specified by:
hasNewMessages in class Folder
Returns:
Always returns false.
Throws:
MessagingException

getFolder

public Folder getFolder(String name)
                 throws MessagingException
Specified by:
getFolder in class Folder
Throws:
MessagingException

delete

public boolean delete(boolean recurse)
               throws MessagingException
Specified by:
delete in class Folder
Throws:
MessagingException

renameTo

public boolean renameTo(Folder f)
                 throws MessagingException
Specified by:
renameTo in class Folder
Throws:
MessagingException

open

public void open(int mode)
          throws MessagingException
Specified by:
open in class Folder
Throws:
MessagingException
See Also:
Folder.open(int)

close

public void close(boolean expunge)
           throws MessagingException
Close a POP3 folder.

Specified by:
close in class Folder
Parameters:
expunge - The expunge flag (ignored for POP3).
Throws:
MessagingException

expungeDeletedMessages

protected void expungeDeletedMessages(POP3Connection connection)
                               throws MessagingException
Mark any messages we've flagged as deleted from the POP3 server before closing.

Throws:
MessagingException

cleanupFolder

protected void cleanupFolder(boolean disconnected)
                      throws MessagingException
Do folder cleanup. This is used both for normal close operations, and adnormal closes where the server has sent us a BYE message.

Parameters:
expunge - Indicates whether open messages should be expunged.
disconnected - The disconnected flag. If true, the server has cut us off, which means our connection can not be returned to the connection pool.
Throws:
MessagingException

isOpen

public boolean isOpen()
Specified by:
isOpen in class Folder

getPermanentFlags

public Flags getPermanentFlags()
Specified by:
getPermanentFlags in class Folder

getMessageCount

public int getMessageCount()
                    throws MessagingException
Get the folder message count.

Specified by:
getMessageCount in class Folder
Returns:
The number of messages in the folder.
Throws:
MessagingException

getMessage

public Message getMessage(int msgNum)
                   throws MessagingException
Checks wether the message is in cache, if not will create a new message object and return it.

Specified by:
getMessage in class Folder
Throws:
MessagingException
See Also:
Folder.getMessage(int)

appendMessages

public void appendMessages(Message[] msgs)
                    throws MessagingException
Specified by:
appendMessages in class Folder
Throws:
MessagingException

expunge

public Message[] expunge()
                  throws MessagingException
Specified by:
expunge in class Folder
Throws:
MessagingException

getMode

public int getMode()
            throws IllegalStateException
Overrides:
getMode in class Folder
Throws:
IllegalStateException

fetch

public void fetch(Message[] msgs,
                  FetchProfile fp)
           throws MessagingException
Overrides:
fetch in class Folder
Throws:
MessagingException
See Also:
The JavaMail API recommends that this method be overrident to provide a meaningfull implementation.

getUID

public String getUID(Message msg)
              throws MessagingException
Retrieve the UID for a given message.

Parameters:
msg - The message of interest.
Returns:
The String UID value for this message.
Throws:
MessagingException

notifyMessageChangedListeners

public void notifyMessageChangedListeners(int type,
                                          Message m)
Overrides:
notifyMessageChangedListeners in class Folder
See Also:
this method is protected and cannot be used outside of Folder, therefore had to explicitly expose it via a method in POP3Folder, so that POP3Message has access to it Bad design on the part of the Java Mail API.

getConnection

protected POP3Connection getConnection()
                                throws MessagingException
Retrieve the connection attached to this folder. Throws an exception if we don't have an active connection.

Returns:
The current connection object.
Throws:
MessagingException

releaseConnection

protected void releaseConnection(POP3Connection connection)
                          throws MessagingException
Release our connection back to the Store.

Parameters:
connection - The connection to release.
Throws:
MessagingException


Copyright © 2003-2009 The Apache Software Foundation. All Rights Reserved.