gnu.mail.providers.nntp
Class NNTPFolder

java.lang.Object
  extended by javax.mail.Folder
      extended by gnu.mail.providers.nntp.NNTPFolder

public final class NNTPFolder
extends Folder

A JavaMail folder delegate for an NNTP newsgroup.


Field Summary
 
Fields inherited from class javax.mail.Folder
HOLDS_FOLDERS, HOLDS_MESSAGES, mode, READ_ONLY, READ_WRITE, store
 
Method Summary
 void appendMessages(Message[] messages)
          NNTP servers are read-only.
 void close(boolean expunge)
          This method has no particular meaning in NNTP.
 boolean create(int type)
          NNTP servers are read-only.
 boolean delete(boolean recurse)
          NNTP servers are read-only.
 boolean exists()
          Indicates whether the newsgroup is present on the server.
 Message[] expunge()
          NNTP servers are read-only.
 void fetch(Message[] msgs, FetchProfile fp)
          Prefetch.
 Folder getFolder(java.lang.String name)
          This folder type does not contain other folders.
 java.lang.String getFullName()
          Returns the full name of this folder.
 Message getMessage(int msgnum)
          Returns the article corresponding to the specified article number.
 int getMessageCount()
          Returns the number of articles in this newsgroup.
 Message[] getMessages()
          Returns all articles in this group.
 int getMode()
          This folder type is always read-only.
 java.lang.String getName()
          Returns the name of the newsgroup, e.g.
 Folder getParent()
          This implementation uses a flat namespace, so the parent of any NNTPFolder is the NNTP root folder.
 Flags getPermanentFlags()
          Returns the flags supported by this folder.
 char getSeparator()
          If we move away from a flat namespace, this might be useful.
 int getType()
          Returns the type of this folder.
 boolean hasNewMessages()
          Indicates whether there are new articles in this newsgroup.
 boolean isOpen()
          Indicates whether this folder is open.
 boolean isSubscribed()
          Indicates if the newsgroup is subscribed.
 Folder[] list(java.lang.String pattern)
          This folder type does not contain other folders.
 Folder[] listSubscribed(java.lang.String pattern)
          This folder type does not contain other folders.
 void open(int mode)
          This method has no particular meaning in NNTP.
 boolean renameTo(Folder folder)
          NNTP servers are read-only.
 void setSubscribed(boolean flag)
          Subscribes or unsubscribes to this newsgroup.
 
Methods inherited from class javax.mail.Folder
addConnectionListener, addFolderListener, addMessageChangedListener, addMessageCountListener, copyMessages, getDeletedMessageCount, getMessages, getMessages, getNewMessageCount, getStore, getUnreadMessageCount, getURLName, list, listSubscribed, notifyConnectionListeners, notifyFolderListeners, notifyFolderRenamedListeners, notifyMessageAddedListeners, notifyMessageChangedListeners, notifyMessageRemovedListeners, removeConnectionListener, removeFolderListener, removeMessageChangedListener, removeMessageCountListener, search, search, setFlags, setFlags, setFlags, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getName

public java.lang.String getName()
Returns the name of the newsgroup, e.g. alt.test.

Specified by:
getName in class Folder

getFullName

public java.lang.String getFullName()
Description copied from class: Folder
Returns the full name of this folder. If the folder resides under the root hierarchy of its 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.

Specified by:
getFullName in class Folder
See Also:
getName()

getParent

public Folder getParent()
                 throws MessagingException
This implementation uses a flat namespace, so the parent of any NNTPFolder is the NNTP root folder.

Specified by:
getParent in class Folder
Throws:
MessagingException

getType

public int getType()
            throws MessagingException
Returns the type of this folder. This folder type only holds messages.

Specified by:
getType in class Folder
Throws:
MessagingException

isOpen

public boolean isOpen()
Description copied from class: Folder
Indicates whether this folder is open.

Specified by:
isOpen in class Folder

getMode

public int getMode()
This folder type is always read-only.

Overrides:
getMode in class Folder

getPermanentFlags

public Flags getPermanentFlags()
Returns the flags supported by this folder.

Specified by:
getPermanentFlags in class Folder

open

public void open(int mode)
          throws MessagingException
This method has no particular meaning in NNTP. However, we will use it to send a GROUP command and refresh our article stats.

Specified by:
open in class Folder
Parameters:
mode - open the Folder READ_ONLY or READ_WRITE
Throws:
FolderNotFoundException - if this folder does not exist
MessagingException

close

public void close(boolean expunge)
           throws MessagingException
This method has no particular meaning in NNTP.

Specified by:
close in class Folder
Parameters:
expunge - if true, expunge all deleted messages
Throws:
MessagingException

exists

public boolean exists()
               throws MessagingException
Indicates whether the newsgroup is present on the server.

Specified by:
exists in class Folder
Throws:
MessagingException

hasNewMessages

public boolean hasNewMessages()
                       throws MessagingException
Indicates whether there are new articles in this newsgroup.

Specified by:
hasNewMessages in class Folder
Throws:
MessagingException

getMessageCount

public int getMessageCount()
                    throws MessagingException
Returns the number of articles in this newsgroup.

Specified by:
getMessageCount in class Folder
Throws:
MessagingException

getMessage

public Message getMessage(int msgnum)
                   throws MessagingException
Returns the article corresponding to the specified article number.

Specified by:
getMessage in class Folder
Parameters:
msgnum - the message number
Throws:
MessageRemovedException - often ;-)
FolderNotFoundException - if this folder does not exist
MessagingException

getMessages

public Message[] getMessages()
                      throws MessagingException
Returns all articles in this group. This tries XHDR first to retrieve Message-IDs for the articles. If this fails we fall back to statting each article.

Overrides:
getMessages in class Folder
Throws:
FolderNotFoundException - if this folder does not exist
MessagingException

fetch

public void fetch(Message[] msgs,
                  FetchProfile fp)
           throws MessagingException
Prefetch.

Overrides:
fetch in class Folder
Parameters:
msgs - the messages to fetch the items for
fp - the fetch profile
Throws:
MessagingException

isSubscribed

public boolean isSubscribed()
Indicates if the newsgroup is subscribed. This uses the newsrc mechanism associated with this folder's store.

Overrides:
isSubscribed in class Folder

setSubscribed

public void setSubscribed(boolean flag)
                   throws MessagingException
Subscribes or unsubscribes to this newsgroup. This uses the newsrc mechanism associated with this folder's store.

Overrides:
setSubscribed in class Folder
Throws:
MessagingException

getFolder

public Folder getFolder(java.lang.String name)
                 throws MessagingException
This folder type does not contain other folders.

Specified by:
getFolder in class Folder
Parameters:
name - the name of the folder
Throws:
MessagingException

list

public Folder[] list(java.lang.String pattern)
              throws MessagingException
This folder type does not contain other folders.

Specified by:
list in class Folder
Parameters:
pattern - the match pattern
Throws:
MessagingException

listSubscribed

public Folder[] listSubscribed(java.lang.String pattern)
                        throws MessagingException
This folder type does not contain other folders.

Overrides:
listSubscribed in class Folder
Parameters:
pattern - the match pattern
Throws:
MessagingException

getSeparator

public char getSeparator()
                  throws MessagingException
If we move away from a flat namespace, this might be useful.

Specified by:
getSeparator in class Folder
Throws:
MessagingException

create

public boolean create(int type)
               throws MessagingException
NNTP servers are read-only.

Specified by:
create in class Folder
Parameters:
type - the desired type of the folder
Throws:
MessagingException

delete

public boolean delete(boolean recurse)
               throws MessagingException
NNTP servers are read-only.

Specified by:
delete in class Folder
Parameters:
recurse - delete any subfolders
Returns:
true if the folder is deleted successfully, false otherwise
Throws:
FolderNotFoundException - if this folder does not exist
MessagingException

renameTo

public boolean renameTo(Folder folder)
                 throws MessagingException
NNTP servers are read-only.

Specified by:
renameTo in class Folder
Parameters:
folder - a folder representing the new name for this folder
Returns:
true if the folder is renamed successfully, false otherwise
Throws:
FolderNotFoundException - if this folder does not exist
MessagingException

appendMessages

public void appendMessages(Message[] messages)
                    throws MessagingException
NNTP servers are read-only.

Specified by:
appendMessages in class Folder
Parameters:
messages - array of messages to be appended
Throws:
FolderNotFoundException - if this folder does not exist
MessagingException - if the append operation failed

expunge

public Message[] expunge()
                  throws MessagingException
NNTP servers are read-only.

Specified by:
expunge in class Folder
Throws:
FolderNotFoundException - if this folder does not exist
MessagingException