public class POP3Folder extends Folder
HOLDS_FOLDERS, HOLDS_MESSAGES, mode, READ_ONLY, READ_WRITE| Modifier | Constructor and Description |
|---|---|
protected |
POP3Folder(POP3Store store,
String name) |
| Modifier and Type | Method and Description |
|---|---|
void |
appendMessages(Message[] msgs)
Always throws
MethodNotSupportedException
because the POP3 protocol doesn't support appending messages. |
void |
close(boolean expunge)
Close this Folder.
|
boolean |
create(int type)
Always returns
false; the POP3 protocol doesn't
support creating folders. |
protected POP3Message |
createMessage(Folder f,
int msgno) |
boolean |
delete(boolean recurse)
Always throws
MethodNotSupportedException
because the POP3 protocol doesn't allow the INBOX to
be deleted. |
boolean |
exists()
Always true for the folder "INBOX", always false for
any other name.
|
Message[] |
expunge()
Always throws
MethodNotSupportedException
because the POP3 protocol doesn't support expunging messages
without closing the folder; call the close method
with the expunge argument set to true
instead. |
void |
fetch(Message[] msgs,
FetchProfile fp)
Prefetch information about POP3 messages.
|
protected void |
finalize()
Close the folder when we're finalized.
|
Folder |
getFolder(String name)
Always throws
MessagingException because no POP3 folders
can contain subfolders. |
String |
getFullName()
Returns the full name of this Folder.
|
Message |
getMessage(int msgno)
Get the Message object corresponding to the given message
number.
|
int |
getMessageCount()
Will not change while the folder is open because the POP3
protocol doesn't support notification of new messages
arriving in open folders.
|
String |
getName()
Returns the name of this Folder.
|
Folder |
getParent()
Returns the parent folder of this folder.
|
Flags |
getPermanentFlags()
Always returns an empty
Flags object because
the POP3 protocol doesn't support any permanent flags. |
char |
getSeparator()
Always returns a NUL character because POP3 doesn't support a hierarchy.
|
int |
getSize()
Return the size of this folder, as was returned by the POP3 STAT
command when this folder was opened.
|
int[] |
getSizes()
Return the sizes of all messages in this folder, as returned
by the POP3 LIST command.
|
int |
getType()
Always returns Folder.HOLDS_MESSAGES.
|
String |
getUID(Message msg)
Return the unique ID string for this message, or null if
not available.
|
boolean |
hasNewMessages()
Always returns
false; the POP3 protocol provides
no way to determine when a new message arrives. |
boolean |
isOpen()
Indicates whether this Folder is in the 'open' state.
|
Folder[] |
list(String pattern)
Always throws
MessagingException because no POP3 folders
can contain subfolders. |
InputStream |
listCommand()
Return the raw results of the POP3 LIST command with no arguments.
|
protected void |
notifyMessageChangedListeners(int type,
Message m)
Notify all MessageChangedListeners.
|
void |
open(int mode)
Throws
FolderNotFoundException unless this
folder is named "INBOX". |
boolean |
renameTo(Folder f)
Always throws
MethodNotSupportedException
because the POP3 protocol doesn't support multiple folders. |
addConnectionListener, addFolderListener, addMessageChangedListener, addMessageCountListener, close, copyMessages, getDeletedMessageCount, getMessages, getMessages, getMessages, getMode, getNewMessageCount, getStore, getUnreadMessageCount, getURLName, isSubscribed, list, listSubscribed, listSubscribed, notifyConnectionListeners, notifyFolderListeners, notifyFolderRenamedListeners, notifyMessageAddedListeners, notifyMessageRemovedListeners, removeConnectionListener, removeFolderListener, removeMessageChangedListener, removeMessageCountListener, search, search, setFlags, setFlags, setFlags, setSubscribed, toStringpublic String getName()
FolderThis method can be invoked on a closed Folder.
public String getFullName()
FolderThis method can be invoked on a closed Folder.
getFullName in class Folderpublic Folder getParent()
FolderNote that since Folder objects are not cached, invoking this method returns a new distinct Folder object.
public boolean exists()
exists in class FolderFolder.create(int)public Folder[] list(String pattern) throws MessagingException
MessagingException because no POP3 folders
can contain subfolders.list in class Folderpattern - the match patternMessagingException - alwaysFolder.listSubscribed(java.lang.String)public char getSeparator()
getSeparator in class Folderpublic int getType()
getType in class FolderFolder.HOLDS_FOLDERS,
Folder.HOLDS_MESSAGESpublic boolean create(int type)
throws MessagingException
false; the POP3 protocol doesn't
support creating folders.create in class Foldertype - The type of this folder.MessagingException - for failuresFolder.HOLDS_FOLDERS,
Folder.HOLDS_MESSAGES,
FolderEventpublic boolean hasNewMessages()
throws MessagingException
false; the POP3 protocol provides
no way to determine when a new message arrives.hasNewMessages in class FolderFolderNotFoundException - if this folder does
not exist.MessagingException - for other failurespublic Folder getFolder(String name) throws MessagingException
MessagingException because no POP3 folders
can contain subfolders.getFolder in class Foldername - name of the FolderMessagingException - alwayspublic boolean delete(boolean recurse)
throws MessagingException
MethodNotSupportedException
because the POP3 protocol doesn't allow the INBOX to
be deleted.delete in class Folderrecurse - also delete subfolders?MethodNotSupportedException - alwaysFolderNotFoundException - if this folder does
not existMessagingException - for other failuresFolderEventpublic boolean renameTo(Folder f) throws MessagingException
MethodNotSupportedException
because the POP3 protocol doesn't support multiple folders.renameTo in class Folderf - a folder representing the new name for this FolderMethodNotSupportedException - alwaysFolderNotFoundException - if this folder does
not existMessagingException - for other failuresFolderEventpublic void open(int mode)
throws MessagingException
FolderNotFoundException unless this
folder is named "INBOX".open in class Foldermode - open the Folder READ_ONLY or READ_WRITEFolderNotFoundException - if not INBOXAuthenticationFailedException - authentication failuresMessagingException - other open failuresFolder.READ_ONLY,
Folder.READ_WRITE,
Folder.getType(),
ConnectionEventpublic void close(boolean expunge)
throws MessagingException
FolderA CLOSED ConnectionEvent is delivered to any ConnectionListeners registered on this Folder. Note that the folder is closed even if this method terminates abnormally by throwing a MessagingException.
close in class Folderexpunge - expunges all deleted messages if this flag is trueMessagingException - for other failuresConnectionEventpublic boolean isOpen()
Folderpublic Flags getPermanentFlags()
Flags object because
the POP3 protocol doesn't support any permanent flags.getPermanentFlags in class Folderpublic int getMessageCount()
throws MessagingException
getMessageCount in class FolderFolderNotFoundException - if this folder does
not exist.MessagingException - for other failurespublic Message getMessage(int msgno) throws MessagingException
FolderMessage objects are light-weight references to the actual message that get filled up on demand. Hence Folder implementations are expected to provide light-weight Message objects.
Unlike Folder objects, repeated calls to getMessage with the same message number will return the same Message object, as long as no messages in this folder have been expunged.
Since message numbers can change within a session if the folder is expunged , clients are advised not to use message numbers as references to messages. Use Message objects instead.
getMessage in class Foldermsgno - the message numberFolderNotFoundException - if this folder does
not exist.MessagingException - for other failuresFolder.getMessageCount(),
Folder.fetch(javax.mail.Message[], javax.mail.FetchProfile)protected POP3Message createMessage(Folder f, int msgno) throws MessagingException
MessagingExceptionpublic void appendMessages(Message[] msgs) throws MessagingException
MethodNotSupportedException
because the POP3 protocol doesn't support appending messages.appendMessages in class Foldermsgs - array of Messages to be appendedMethodNotSupportedException - alwaysFolderNotFoundException - if this folder does
not exist.MessagingException - if the append failed.public Message[] expunge() throws MessagingException
MethodNotSupportedException
because the POP3 protocol doesn't support expunging messages
without closing the folder; call the close method
with the expunge argument set to true
instead.expunge in class FolderMethodNotSupportedException - alwaysFolderNotFoundException - if this folder does not
existMessagingException - for other failuresMessage.isExpunged(),
MessageCountEventpublic void fetch(Message[] msgs, FetchProfile fp) throws MessagingException
UIDFolder.FetchProfileItem.UID,
POP3 UIDs for all messages in the folder are fetched using the POP3
UIDL command.
If the FetchProfile contains FetchProfile.Item.ENVELOPE,
the headers and size of all messages are fetched using the POP3 TOP
and LIST commands.fetch in class Foldermsgs - fetch items for these messagesfp - the FetchProfileMessagingException - for other failurespublic String getUID(Message msg) throws MessagingException
msg - the messageMessagingException - for failurespublic int getSize()
throws MessagingException
IllegalStateException - if the folder isn't openMessagingException - for other failurespublic int[] getSizes()
throws MessagingException
IllegalStateException - if the folder isn't openMessagingException - for other failurespublic InputStream listCommand() throws MessagingException, IOException
IllegalStateException - if the folder isn't openIOException - for I/O errors talking to the serverMessagingException - for other errorsprotected void finalize()
throws Throwable
protected void notifyMessageChangedListeners(int type,
Message m)
FolderThe provided implementation queues the event into an internal event queue. An event dispatcher thread dequeues events from the queue and dispatches them to registered MessageChangedListeners. Note that the event dispatching occurs in a separate thread, thus avoiding potential deadlock problems.
notifyMessageChangedListeners in class Foldertype - the MessageChangedEvent typem - the message that changedCopyright © 1996-2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.