gnu.mail.providers.nntp

Class NNTPRootFolder


public final class NNTPRootFolder
extends Folder

The "root" folder of the NNTP newsgroup list. The NNTP folder namespace is taken to be a flat namespace. This object allows us to retrieve folders corresponding to each newsgroup in that space.
Version:
2.0
Authors:
Chris Burdess
Cedric Hyppolite

Field Summary

Fields inherited from class javax.mail.Folder

HOLDS_FOLDERS, HOLDS_MESSAGES, READ_ONLY, READ_WRITE, mode, store

Method Summary

void
appendMessages(Message[] messages)
Appends the specified messages to this folder.
void
close(boolean expunge)
Closes this folder.
boolean
create(int type)
Create this folder in the store.
boolean
delete(boolean flag)
Deletes this folder.
boolean
exists()
Indicates whether this folder exists in the Store.
Message[]
expunge()
Expunges (permanently removing) all the messages marked DELETED.
Folder
getFolder(String name)
Returns a new Folder object associated with the specified name.
String
getFullName()
Returns the full name of this folder.
Message
getMessage(int msgnum)
Returns the message with the given number.
int
getMessageCount()
Returns the number of messages in this folder.
String
getName()
Returns the name of this folder.
Folder
getParent()
Returns the parent folder of this folder, or null if this folder is the root of a folder hierarchy.
Flags
getPermanentFlags()
Returns the permanent flags supported by this folder.
char
getSeparator()
As we're dealing with a flat namespace, the value of this is irrelevant.
int
getType()
This folder contains only folders.
boolean
hasNewMessages()
Indicates whether this folder has new messages.
boolean
isOpen()
Indicates whether this folder is open.
Folder[]
list(String pattern)
Returns the list of folders matching the specified pattern.
Folder[]
list(String pattern, ListFolderListener listener)
Returns the list of folders matching the specified pattern.
Folder[]
list(ListFolderListener listener)
Returns the list of folders matching the specified pattern.
Folder[]
listSubscribed(String pattern)
Returns the list of subscribed folders matching the specified pattern.
void
open(int mode)
Opens this folder.
boolean
renameTo(Folder folder)
Renames this folder.
void
setSubscribed(boolean flag)
This folder is always "subscribed".

Methods inherited from class javax.mail.Folder

addConnectionListener, addFolderListener, addMessageChangedListener, addMessageCountListener, appendMessages, close, copyMessages, create, delete, exists, expunge, fetch, getDeletedMessageCount, getFolder, getFullName, getMessage, getMessageCount, getMessages, getMessages, getMessages, getMode, getName, getNewMessageCount, getParent, getPermanentFlags, getSeparator, getStore, getType, getURLName, getUnreadMessageCount, hasNewMessages, isOpen, isSubscribed, list, list, listSubscribed, listSubscribed, notifyConnectionListeners, notifyFolderListeners, notifyFolderRenamedListeners, notifyMessageAddedListeners, notifyMessageChangedListeners, notifyMessageRemovedListeners, open, removeConnectionListener, removeFolderListener, removeMessageChangedListener, removeMessageCountListener, renameTo, search, search, setFlags, setFlags, setFlags, setSubscribed, toString

Method Details

appendMessages

public void appendMessages(Message[] messages)
            throws MessagingException
Appends the specified messages to this folder.

This method can be invoked on a closed folder.

Overrides:
appendMessages in interface Folder
Parameters:
Throws:
MessagingException - if the append operation failed

close

public void close(boolean expunge)
            throws MessagingException
Closes this folder. This method can only be invoked on an open folder.
Overrides:
close in interface Folder
Parameters:
expunge - if true, expunge all deleted messages

create

public boolean create(int type)
            throws MessagingException
Create this folder in the store. When this folder is created, any folders in its path that do not exist are also created.

If the creation is successful, a CREATED FolderEvent is delivered to any FolderListeners registered on this Folder and this Store.

Overrides:
create in interface Folder
Parameters:
type - the desired type of the folder

delete

public boolean delete(boolean flag)
            throws MessagingException
Deletes this folder. This method can only be invoked on a closed folder.
Overrides:
delete in interface Folder
Parameters:
Returns:
true if the folder is deleted successfully, false otherwise

exists

public boolean exists()
            throws MessagingException
Indicates whether this folder exists in the Store.

This method can be invoked on a closed folder.

Overrides:
exists in interface Folder

expunge

public Message[] expunge()
            throws MessagingException
Expunges (permanently removing) all the messages marked DELETED. Returns an array containing the expunged messages.

Expunge causes the renumbering of any messages with numbers higher than the message number of the lowest-numbered expunged message.

After a message has been expunged, only the isExpunged and getMessageNumber methods are still valid on the corresponding Message object; other methods may throw MessageRemovedException.

Overrides:
expunge in interface Folder

getFolder

public Folder getFolder(String name)
            throws MessagingException
Returns a new Folder object associated with the specified name.
Overrides:
getFolder in interface Folder

getFullName

public String getFullName()
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.

Overrides:
getFullName in interface Folder

getMessage

public Message getMessage(int msgnum)
            throws MessagingException
Returns the message with the given number. The message number is the relative position of a message in its folder, starting at 1.

Note that message numbers can change within a session if the folder is expunged, therefore the use of message numbers as references to messages is inadvisable.

Overrides:
getMessage in interface Folder
Parameters:
msgnum - the message number

getMessageCount

public int getMessageCount()
            throws MessagingException
Returns the number of messages in this folder.

This method can be invoked on a closed folder; however, note that for some stores, getting the message count can be an expensive operation involving actually opening the folder. In such cases, a provider can choose to return -1 here when the folder is closed.

Overrides:
getMessageCount in interface Folder

getName

public String getName()
Returns the name of this folder.

This method can be invoked on a closed folder.

Overrides:
getName in interface Folder

getParent

public Folder getParent()
            throws MessagingException
Returns the parent folder of this folder, or null if this folder is the root of a folder hierarchy.

This method can be invoked on a closed folder.

Overrides:
getParent in interface Folder

getPermanentFlags

public Flags getPermanentFlags()
Returns the permanent flags supported by this folder.
Overrides:
getPermanentFlags in interface Folder

getSeparator

public char getSeparator()
            throws MessagingException
As we're dealing with a flat namespace, the value of this is irrelevant.
Overrides:
getSeparator in interface Folder

getType

public int getType()
This folder contains only folders.
Overrides:
getType in interface Folder

hasNewMessages

public boolean hasNewMessages()
            throws MessagingException
Indicates whether this folder has new messages.

This method can be invoked on a closed folder that can contain messages.

Overrides:
hasNewMessages in interface Folder

isOpen

public boolean isOpen()
Indicates whether this folder is open.
Overrides:
isOpen in interface Folder

list

public Folder[] list(String pattern)
            throws MessagingException
Returns the list of folders matching the specified pattern.
Overrides:
list in interface Folder
Parameters:
pattern - the JavaMail pattern

list

public Folder[] list(String pattern,
                     ListFolderListener listener)
            throws MessagingException
Returns the list of folders matching the specified pattern.
Parameters:
pattern - the JavaMail pattern
listener - the listener that will be called for each folder name as soon as it is known

list

public Folder[] list(ListFolderListener listener)
            throws MessagingException
Returns the list of folders matching the specified pattern.
Parameters:
listener - the listener to be called as soon as a new folder is listed

listSubscribed

public Folder[] listSubscribed(String pattern)
            throws MessagingException
Returns the list of subscribed folders matching the specified pattern.
Overrides:
listSubscribed in interface Folder
Parameters:
pattern - the JavaMail pattern

open

public void open(int mode)
            throws MessagingException
Opens this folder. This method can only be invoked on a closed folder that can contain messages.
Overrides:
open in interface Folder
Parameters:
mode - open the Folder READ_ONLY or READ_WRITE

renameTo

public boolean renameTo(Folder folder)
            throws MessagingException
Renames this folder. This method can only be invoked on a closed folder.
Overrides:
renameTo in interface Folder
Parameters:
folder - a folder representing the new name for this folder
Returns:
true if the folder is renamed successfully, false otherwise

setSubscribed

public void setSubscribed(boolean flag)
            throws MessagingException
This folder is always "subscribed".
Overrides:
setSubscribed in interface Folder

© Copyright 2003, 2004 The Free Software Foundation, All rights reserved