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 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
-
-
-
-
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: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 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:
getParent
in classFolder
- Throws:
MessagingException
-
getType
public int getType() throws MessagingException
Returns the type of this folder. This folder type only holds messages.- Specified by:
getType
in classFolder
- Throws:
MessagingException
-
isOpen
public boolean isOpen()
Description copied from class:Folder
Indicates 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:
getPermanentFlags
in classFolder
-
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 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 MessagingException
This method has no particular meaning in NNTP.- Specified by:
close
in classFolder
- 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 classFolder
- Throws:
MessagingException
-
hasNewMessages
public boolean hasNewMessages() throws MessagingException
Indicates whether there are new articles in this newsgroup.- Specified by:
hasNewMessages
in classFolder
- Throws:
MessagingException
-
getMessageCount
public int getMessageCount() throws MessagingException
Returns the number of articles in this newsgroup.- Specified by:
getMessageCount
in classFolder
- Throws:
MessagingException
-
getMessage
public Message getMessage(int msgnum) throws MessagingException
Returns the article corresponding to the specified article number.- Specified by:
getMessage
in 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:
getMessages
in classFolder
- Throws:
FolderNotFoundException
- if this folder does not existMessagingException
-
fetch
public void fetch(Message[] msgs, FetchProfile fp) throws MessagingException
Prefetch.- Overrides:
fetch
in 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:
isSubscribed
in classFolder
-
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 classFolder
- Throws:
MessagingException
-
getFolder
public Folder getFolder(java.lang.String name) throws MessagingException
This folder type does not contain other folders.- Specified by:
getFolder
in 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:
list
in 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:
listSubscribed
in classFolder
- 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 classFolder
- Throws:
MessagingException
-
create
public boolean create(int type) throws MessagingException
NNTP servers are read-only.- Specified by:
create
in classFolder
- 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 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:
renameTo
in 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:
appendMessages
in 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:
expunge
in classFolder
- Throws:
FolderNotFoundException
- if this folder does not existMessagingException
-
-