Package gnu.mail.providers.nntp
Class NNTPFolder
- java.lang.Object
-
- javax.mail.Folder
-
- gnu.mail.providers.nntp.NNTPFolder
-
public final class NNTPFolder extends Folder
A JavaMail folder delegate for an NNTP newsgroup.- Version:
- 2.0
- Author:
- Chris Burdess
-
-
Field Summary
-
Fields inherited from class javax.mail.Folder
HOLDS_FOLDERS, HOLDS_MESSAGES, mode, READ_ONLY, READ_WRITE, store
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendMessages(Message[] messages)NNTP servers are read-only.voidclose(boolean expunge)This method has no particular meaning in NNTP.booleancreate(int type)NNTP servers are read-only.booleandelete(boolean recurse)NNTP servers are read-only.booleanexists()Indicates whether the newsgroup is present on the server.Message[]expunge()NNTP servers are read-only.voidfetch(Message[] msgs, FetchProfile fp)Prefetch.FoldergetFolder(java.lang.String name)This folder type does not contain other folders.java.lang.StringgetFullName()Returns the full name of this folder.MessagegetMessage(int msgnum)Returns the article corresponding to the specified article number.intgetMessageCount()Returns the number of articles in this newsgroup.Message[]getMessages()Returns all articles in this group.intgetMode()This folder type is always read-only.java.lang.StringgetName()Returns the name of the newsgroup, e.g.FoldergetParent()This implementation uses a flat namespace, so the parent of any NNTPFolder is the NNTP root folder.FlagsgetPermanentFlags()Returns the flags supported by this folder.chargetSeparator()If we move away from a flat namespace, this might be useful.intgetType()Returns the type of this folder.booleanhasNewMessages()Indicates whether there are new articles in this newsgroup.booleanisOpen()Indicates whether this folder is open.booleanisSubscribed()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.voidopen(int mode)This method has no particular meaning in NNTP.booleanrenameTo(Folder folder)NNTP servers are read-only.voidsetSubscribed(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
-
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name of the newsgroup, e.g.alt.test.
-
getFullName
public java.lang.String getFullName()
Description copied from class:FolderReturns 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:
getFullNamein classFolder- 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:
getParentin classFolder- Throws:
MessagingException
-
getType
public int getType() throws MessagingExceptionReturns the type of this folder. This folder type only holds messages.- Specified by:
getTypein classFolder- Throws:
MessagingException
-
isOpen
public boolean isOpen()
Description copied from class:FolderIndicates whether this folder is open.
-
getMode
public int getMode()
This folder type is always read-only.
-
getPermanentFlags
public Flags getPermanentFlags()
Returns the flags supported by this folder.- Specified by:
getPermanentFlagsin classFolder
-
open
public void open(int mode) throws MessagingExceptionThis method has no particular meaning in NNTP. However, we will use it to send a GROUP command and refresh our article stats.- Specified by:
openin classFolder- Parameters:
mode- open the Folder READ_ONLY or READ_WRITE- Throws:
FolderNotFoundException- if this folder does not existMessagingException
-
close
public void close(boolean expunge) throws MessagingExceptionThis method has no particular meaning in NNTP.- Specified by:
closein classFolder- Parameters:
expunge- if true, expunge all deleted messages- Throws:
MessagingException
-
exists
public boolean exists() throws MessagingExceptionIndicates whether the newsgroup is present on the server.- Specified by:
existsin classFolder- Throws:
MessagingException
-
hasNewMessages
public boolean hasNewMessages() throws MessagingExceptionIndicates whether there are new articles in this newsgroup.- Specified by:
hasNewMessagesin classFolder- Throws:
MessagingException
-
getMessageCount
public int getMessageCount() throws MessagingExceptionReturns the number of articles in this newsgroup.- Specified by:
getMessageCountin classFolder- Throws:
MessagingException
-
getMessage
public Message getMessage(int msgnum) throws MessagingException
Returns the article corresponding to the specified article number.- Specified by:
getMessagein classFolder- Parameters:
msgnum- the message number- Throws:
MessageRemovedException- often ;-)FolderNotFoundException- if this folder does not existMessagingException
-
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:
getMessagesin classFolder- Throws:
FolderNotFoundException- if this folder does not existMessagingException
-
fetch
public void fetch(Message[] msgs, FetchProfile fp) throws MessagingException
Prefetch.- Overrides:
fetchin classFolder- Parameters:
msgs- the messages to fetch the items forfp- 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:
isSubscribedin classFolder
-
setSubscribed
public void setSubscribed(boolean flag) throws MessagingExceptionSubscribes or unsubscribes to this newsgroup. This uses the newsrc mechanism associated with this folder's store.- Overrides:
setSubscribedin classFolder- Throws:
MessagingException
-
getFolder
public Folder getFolder(java.lang.String name) throws MessagingException
This folder type does not contain other folders.- Specified by:
getFolderin classFolder- 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:
listin classFolder- 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:
listSubscribedin classFolder- Parameters:
pattern- the match pattern- Throws:
MessagingException
-
getSeparator
public char getSeparator() throws MessagingExceptionIf we move away from a flat namespace, this might be useful.- Specified by:
getSeparatorin classFolder- Throws:
MessagingException
-
create
public boolean create(int type) throws MessagingExceptionNNTP servers are read-only.- Specified by:
createin classFolder- Parameters:
type- the desired type of the folder- Throws:
MessagingException
-
delete
public boolean delete(boolean recurse) throws MessagingExceptionNNTP servers are read-only.- Specified by:
deletein classFolder- Parameters:
recurse- delete any subfolders- Returns:
- true if the folder is deleted successfully, false otherwise
- Throws:
FolderNotFoundException- if this folder does not existMessagingException
-
renameTo
public boolean renameTo(Folder folder) throws MessagingException
NNTP servers are read-only.- Specified by:
renameToin classFolder- 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 existMessagingException
-
appendMessages
public void appendMessages(Message[] messages) throws MessagingException
NNTP servers are read-only.- Specified by:
appendMessagesin classFolder- Parameters:
messages- array of messages to be appended- Throws:
FolderNotFoundException- if this folder does not existMessagingException- if the append operation failed
-
expunge
public Message[] expunge() throws MessagingException
NNTP servers are read-only.- Specified by:
expungein classFolder- Throws:
FolderNotFoundException- if this folder does not existMessagingException
-
-