org.apache.geronimo.javamail.store.nntp
Class NNTPFolder

java.lang.Object
  extended by javax.mail.Folder
      extended by org.apache.geronimo.javamail.store.nntp.NNTPFolder
Direct Known Subclasses:
NNTPGroupFolder, NNTPRootFolder

public class NNTPFolder
extends Folder

The base NNTP implementation of the javax.mail.Folder This is a base class for both the Root NNTP server and each NNTP group folder.

Version:
$Rev: 437941 $
See Also:
Folder

Field Summary
protected  NNTPConnection connection
           
protected  boolean folderOpen
           
protected  String fullName
           
protected  int messageCount
           
protected  String name
           
protected  Folder parent
           
protected  Flags permanentFlags
           
protected  Session session
           
 
Fields inherited from class javax.mail.Folder
HOLDS_FOLDERS, HOLDS_MESSAGES, mode, READ_ONLY, READ_WRITE, store
 
Constructor Summary
protected NNTPFolder(NNTPStore store)
          Super class constructor the base NNTPFolder class.
 
Method Summary
 void appendMessages(Message[] msgs)
          Append messages to a folder.
protected  void checkClosed()
          Ensure the folder is not open
protected  void checkOpen()
          Ensure the folder is open
 void close(boolean expunge)
          Close the folder.
protected  void closeFolder()
          Peform folder type-specific close actions.
 boolean create(int type)
          Create a new folder.
 boolean delete(boolean recurse)
          Delete a folder.
 boolean exists()
          Indicated whether the folder "exists" or not.
 Message[] expunge()
          Expunge messages marked for deletion and return a list of the Messages.
 Folder getFolder(String name)
          Get a named subfolder from this folder.
 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 count of messages in this folder.
 String getName()
          Retrieve the folder name.
 Folder getParent()
          Returns the parent folder for this folder.
 Flags getPermanentFlags()
          Get the permanentFlags
 char getSeparator()
          No sub folders, hence there is no notion of a seperator.
 int getType()
          Return whether this folder can hold just messages or also subfolders.
 boolean hasNewMessages()
          Check for new messages.
 boolean isOpen()
          Tests the open status of the folder.
 boolean isSeen(int article)
          Test if a given article number is marked as SEEN.
 boolean isSubscribed()
          Retrieve the subscribed status for a folder.
 Folder[] list(String pattern)
          List the subfolders.
 Folder[] listSubscribed(String pattern)
          Retrieve the list of subscribed folders that match the given pattern string.
 void notifyMessageChangedListeners(int type, Message m)
           
 void open(int mode)
           
protected  void openFolder()
          Perform folder type-specific open actions.
 boolean renameTo(Folder f)
          Rename a folder.
 void setSeen(int article, boolean flag)
          Set the SEEN status for an article.
 void setSubscribed(boolean flag)
          Set the subscribed status for a folder.
 
Methods inherited from class javax.mail.Folder
addConnectionListener, addFolderListener, addMessageChangedListener, addMessageCountListener, copyMessages, fetch, finalize, getDeletedMessageCount, getMessages, getMessages, getMessages, getMode, getNewMessageCount, getStore, getUnreadMessageCount, getURLName, list, listSubscribed, notifyConnectionListeners, notifyFolderListeners, notifyFolderRenamedListeners, notifyMessageAddedListeners, notifyMessageRemovedListeners, removeConnectionListener, removeFolderListener, removeMessageChangedListener, removeMessageCountListener, search, search, setFlags, setFlags, setFlags, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

connection

protected NNTPConnection connection

session

protected Session session

name

protected String name

fullName

protected String fullName

parent

protected Folder parent

folderOpen

protected boolean folderOpen

messageCount

protected int messageCount

permanentFlags

protected Flags permanentFlags
Constructor Detail

NNTPFolder

protected NNTPFolder(NNTPStore store)
Super class constructor the base NNTPFolder class.

Parameters:
store - The javamail store this folder is attached to.
Method Detail

getName

public String getName()
Retrieve the folder name.

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

getFullName

public String getFullName()
Retrieve the folder's full name (including hierarchy information). NNTP folders are flat, so the full name is generally the same as the name.

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

getParent

public Folder getParent()
                 throws MessagingException
Returns the parent folder for this folder. Returns null if this is the root folder.

Specified by:
getParent in class Folder
Throws:
MessagingException

exists

public boolean exists()
               throws MessagingException
Indicated whether the folder "exists" or not. Existance in this context indicates that the group still exists on the server.

Specified by:
exists in class Folder
Returns:
Throws:
MessagingException

list

public Folder[] list(String pattern)
              throws MessagingException
List the subfolders. For group folders, this is a meaningless so we throw a MethodNotSupportedException.

Specified by:
list in class Folder
Parameters:
pattern - The folder pattern string.
Returns:
Never returns.
Throws:
MessagingException

listSubscribed

public Folder[] listSubscribed(String pattern)
                        throws MessagingException
Retrieve the list of subscribed folders that match the given pattern string.

Overrides:
listSubscribed in class Folder
Parameters:
pattern - The pattern string used for the matching
Returns:
An array of matching folders from the subscribed list.
Throws:
MessagingException

getSeparator

public char getSeparator()
                  throws MessagingException
No sub folders, hence there is no notion of a seperator. We return a null character (consistent with what Sun returns for POP3 folders).

Specified by:
getSeparator in class Folder
Throws:
MessagingException

getType

public int getType()
            throws MessagingException
Return whether this folder can hold just messages or also subfolders. Only the root folder can hold other folders, so it will need to override.

Specified by:
getType in class Folder
Returns:
Either Folder.HOLDS_MESSAGES or Folder.HOLDS_FOLDERS.
Throws:
MessagingException

create

public boolean create(int type)
               throws MessagingException
Create a new folder. NNTP folders are read only, so this is a nop.

Specified by:
create in class Folder
Parameters:
type - The type of folder.
Returns:
Not support, throws an exception.
Throws:
MessagingException

hasNewMessages

public boolean hasNewMessages()
                       throws MessagingException
Check for new messages. We always return false for the root folder. The group folders will need to override.

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

getFolder

public Folder getFolder(String name)
                 throws MessagingException
Get a named subfolder from this folder. This only has meaning from the root NNTP folder.

Specified by:
getFolder in class Folder
Parameters:
name - The requested name.
Returns:
If the folder exists, returns a Folder object representing the named folder.
Throws:
MessagingException

delete

public boolean delete(boolean recurse)
               throws MessagingException
Delete a folder. This is not supported for NNTP.

Specified by:
delete in class Folder
Parameters:
recurse - The recusion flag.
Returns:
Never returns.
Throws:
MessagingException

renameTo

public boolean renameTo(Folder f)
                 throws MessagingException
Rename a folder. Not supported for NNTP folders.

Specified by:
renameTo in class Folder
Parameters:
f - The new folder specifying the rename location.
Returns:
Throws:
MessagingException

open

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

openFolder

protected void openFolder()
                   throws MessagingException
Perform folder type-specific open actions. The default action is to do nothing.

Throws:
MessagingException

closeFolder

protected void closeFolder()
                    throws MessagingException
Peform folder type-specific close actions. The default action is to do nothing.

Throws:
MessagingException

close

public void close(boolean expunge)
           throws MessagingException
Close the folder. Cleans up resources, potentially expunges messages marked for deletion, and sends an event notification.

Specified by:
close in class Folder
Parameters:
expunge - The expunge flag, which is ignored for NNTP folders.
Throws:
MessagingException

isOpen

public boolean isOpen()
Tests the open status of the folder.

Specified by:
isOpen in class Folder
Returns:
true if the folder is open, false otherwise.

getPermanentFlags

public Flags getPermanentFlags()
Get the permanentFlags

Specified by:
getPermanentFlags in class Folder
Returns:
The set of permanent flags we support (only SEEN).

getMessageCount

public int getMessageCount()
                    throws MessagingException
Get the count of messages in this folder.

Specified by:
getMessageCount in class Folder
Returns:
The message count.
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
Append messages to a folder. NNTP folders are read only, so this is not supported.

Specified by:
appendMessages in class Folder
Parameters:
msgs - The list of messages to append.
Throws:
MessagingException

expunge

public Message[] expunge()
                  throws MessagingException
Expunge messages marked for deletion and return a list of the Messages. Not supported for NNTP.

Specified by:
expunge in class Folder
Returns:
Never returns.
Throws:
MessagingException

checkOpen

protected void checkOpen()
                  throws IllegalStateException
Ensure the folder is open

Throws:
IllegalStateException

checkClosed

protected void checkClosed()
                    throws IllegalStateException
Ensure the folder is not open

Throws:
IllegalStateException

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 NNTPFolder, so that NNTPMessage has access to it Bad design on the part of the Java Mail API.

isSubscribed

public boolean isSubscribed()
Retrieve the subscribed status for a folder. This default implementation just returns false (which is true for the root folder).

Overrides:
isSubscribed in class Folder
Returns:
Always returns true.

setSubscribed

public void setSubscribed(boolean flag)
                   throws MessagingException
Set the subscribed status for a folder.

Overrides:
setSubscribed in class Folder
Parameters:
flag - The new subscribed status.
Throws:
MessagingException

isSeen

public boolean isSeen(int article)
Test if a given article number is marked as SEEN.

Parameters:
article - The target article number.
Returns:
The articles current seen status.

setSeen

public void setSeen(int article,
                    boolean flag)
             throws MessagingException
Set the SEEN status for an article.

Parameters:
article - The target article.
flag - The new seen setting.
Throws:
MessagingException


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