- java.lang.Object
-
- jakarta.mail.Folder
-
- com.sun.mail.pop3.POP3Folder
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class POP3Folder extends jakarta.mail.FolderA POP3 Folder (can only be "INBOX"). See the com.sun.mail.pop3 package documentation for further information on the POP3 protocol provider.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPOP3Folder(POP3Store store, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendMessages(jakarta.mail.Message[] msgs)Always throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't support appending messages.voidclose(boolean expunge)booleancreate(int type)Always returnsfalse; the POP3 protocol doesn't support creating folders.protected POP3MessagecreateMessage(jakarta.mail.Folder f, int msgno)booleandelete(boolean recurse)Always throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't allow the INBOX to be deleted.booleanexists()Always true for the folder "INBOX", always false for any other name.jakarta.mail.Message[]expunge()Always throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't support expunging messages without closing the folder; call theclosemethod with theexpungeargument set totrueinstead.voidfetch(jakarta.mail.Message[] msgs, jakarta.mail.FetchProfile fp)Prefetch information about POP3 messages.protected voidfinalize()Close the folder when we're finalized.jakarta.mail.FoldergetFolder(java.lang.String name)Always throwsMessagingExceptionbecause no POP3 folders can contain subfolders.java.lang.StringgetFullName()jakarta.mail.MessagegetMessage(int msgno)intgetMessageCount()Will not change while the folder is open because the POP3 protocol doesn't support notification of new messages arriving in open folders.java.lang.StringgetName()jakarta.mail.FoldergetParent()jakarta.mail.FlagsgetPermanentFlags()Always returns an emptyFlagsobject because the POP3 protocol doesn't support any permanent flags.chargetSeparator()Always returns a NUL character because POP3 doesn't support a hierarchy.intgetSize()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.intgetType()Always returns Folder.HOLDS_MESSAGES.java.lang.StringgetUID(jakarta.mail.Message msg)Return the unique ID string for this message, or null if not available.booleanhasNewMessages()Always returnsfalse; the POP3 protocol provides no way to determine when a new message arrives.booleanisOpen()jakarta.mail.Folder[]list(java.lang.String pattern)Always throwsMessagingExceptionbecause no POP3 folders can contain subfolders.java.io.InputStreamlistCommand()Return the raw results of the POP3 LIST command with no arguments.protected voidnotifyMessageChangedListeners(int type, jakarta.mail.Message m)voidopen(int mode)ThrowsFolderNotFoundExceptionunless this folder is named "INBOX".booleanrenameTo(jakarta.mail.Folder f)Always throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't support multiple folders.-
Methods inherited from class jakarta.mail.Folder
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, toString
-
-
-
-
Constructor Detail
-
POP3Folder
protected POP3Folder(POP3Store store, java.lang.String name)
-
-
Method Detail
-
getName
public java.lang.String getName()
- Specified by:
getNamein classjakarta.mail.Folder
-
getFullName
public java.lang.String getFullName()
- Specified by:
getFullNamein classjakarta.mail.Folder
-
getParent
public jakarta.mail.Folder getParent()
- Specified by:
getParentin classjakarta.mail.Folder
-
exists
public boolean exists()
Always true for the folder "INBOX", always false for any other name.- Specified by:
existsin classjakarta.mail.Folder- Returns:
- true for INBOX, false otherwise
-
list
public jakarta.mail.Folder[] list(java.lang.String pattern) throws jakarta.mail.MessagingExceptionAlways throwsMessagingExceptionbecause no POP3 folders can contain subfolders.- Specified by:
listin classjakarta.mail.Folder- Throws:
jakarta.mail.MessagingException- always
-
getSeparator
public char getSeparator()
Always returns a NUL character because POP3 doesn't support a hierarchy.- Specified by:
getSeparatorin classjakarta.mail.Folder- Returns:
- NUL
-
getType
public int getType()
Always returns Folder.HOLDS_MESSAGES.- Specified by:
getTypein classjakarta.mail.Folder- Returns:
- Folder.HOLDS_MESSAGES
-
create
public boolean create(int type) throws jakarta.mail.MessagingExceptionAlways returnsfalse; the POP3 protocol doesn't support creating folders.- Specified by:
createin classjakarta.mail.Folder- Returns:
- false
- Throws:
jakarta.mail.MessagingException
-
hasNewMessages
public boolean hasNewMessages() throws jakarta.mail.MessagingExceptionAlways returnsfalse; the POP3 protocol provides no way to determine when a new message arrives.- Specified by:
hasNewMessagesin classjakarta.mail.Folder- Returns:
- false
- Throws:
jakarta.mail.MessagingException
-
getFolder
public jakarta.mail.Folder getFolder(java.lang.String name) throws jakarta.mail.MessagingExceptionAlways throwsMessagingExceptionbecause no POP3 folders can contain subfolders.- Specified by:
getFolderin classjakarta.mail.Folder- Throws:
jakarta.mail.MessagingException- always
-
delete
public boolean delete(boolean recurse) throws jakarta.mail.MessagingExceptionAlways throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't allow the INBOX to be deleted.- Specified by:
deletein classjakarta.mail.Folder- Throws:
jakarta.mail.MethodNotSupportedException- alwaysjakarta.mail.MessagingException
-
renameTo
public boolean renameTo(jakarta.mail.Folder f) throws jakarta.mail.MessagingExceptionAlways throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't support multiple folders.- Specified by:
renameToin classjakarta.mail.Folder- Throws:
jakarta.mail.MethodNotSupportedException- alwaysjakarta.mail.MessagingException
-
open
public void open(int mode) throws jakarta.mail.MessagingExceptionThrowsFolderNotFoundExceptionunless this folder is named "INBOX".- Specified by:
openin classjakarta.mail.Folder- Throws:
jakarta.mail.FolderNotFoundException- if not INBOXjakarta.mail.AuthenticationFailedException- authentication failuresjakarta.mail.MessagingException- other open failures
-
close
public void close(boolean expunge) throws jakarta.mail.MessagingException- Specified by:
closein classjakarta.mail.Folder- Throws:
jakarta.mail.MessagingException
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin classjakarta.mail.Folder
-
getPermanentFlags
public jakarta.mail.Flags getPermanentFlags()
Always returns an emptyFlagsobject because the POP3 protocol doesn't support any permanent flags.- Specified by:
getPermanentFlagsin classjakarta.mail.Folder- Returns:
- empty Flags object
-
getMessageCount
public int getMessageCount() throws jakarta.mail.MessagingExceptionWill not change while the folder is open because the POP3 protocol doesn't support notification of new messages arriving in open folders.- Specified by:
getMessageCountin classjakarta.mail.Folder- Throws:
jakarta.mail.MessagingException
-
getMessage
public jakarta.mail.Message getMessage(int msgno) throws jakarta.mail.MessagingException- Specified by:
getMessagein classjakarta.mail.Folder- Throws:
jakarta.mail.MessagingException
-
createMessage
protected POP3Message createMessage(jakarta.mail.Folder f, int msgno) throws jakarta.mail.MessagingException
- Throws:
jakarta.mail.MessagingException
-
appendMessages
public void appendMessages(jakarta.mail.Message[] msgs) throws jakarta.mail.MessagingExceptionAlways throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't support appending messages.- Specified by:
appendMessagesin classjakarta.mail.Folder- Throws:
jakarta.mail.MethodNotSupportedException- alwaysjakarta.mail.MessagingException
-
expunge
public jakarta.mail.Message[] expunge() throws jakarta.mail.MessagingExceptionAlways throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't support expunging messages without closing the folder; call theclosemethod with theexpungeargument set totrueinstead.- Specified by:
expungein classjakarta.mail.Folder- Throws:
jakarta.mail.MethodNotSupportedException- alwaysjakarta.mail.MessagingException
-
fetch
public void fetch(jakarta.mail.Message[] msgs, jakarta.mail.FetchProfile fp) throws jakarta.mail.MessagingExceptionPrefetch information about POP3 messages. If the FetchProfile containsUIDFolder.FetchProfileItem.UID, POP3 UIDs for all messages in the folder are fetched using the POP3 UIDL command. If the FetchProfile containsFetchProfile.Item.ENVELOPE, the headers and size of all messages are fetched using the POP3 TOP and LIST commands.- Overrides:
fetchin classjakarta.mail.Folder- Throws:
jakarta.mail.MessagingException
-
getUID
public java.lang.String getUID(jakarta.mail.Message msg) throws jakarta.mail.MessagingExceptionReturn the unique ID string for this message, or null if not available. Uses the POP3 UIDL command.- Parameters:
msg- the message- Returns:
- unique ID string
- Throws:
jakarta.mail.MessagingException- for failures
-
getSize
public int getSize() throws jakarta.mail.MessagingExceptionReturn the size of this folder, as was returned by the POP3 STAT command when this folder was opened.- Returns:
- folder size
- Throws:
java.lang.IllegalStateException- if the folder isn't openjakarta.mail.MessagingException- for other failures
-
getSizes
public int[] getSizes() throws jakarta.mail.MessagingExceptionReturn the sizes of all messages in this folder, as returned by the POP3 LIST command. Each entry in the array corresponds to a message; entry i corresponds to message number i+1.- Returns:
- array of message sizes
- Throws:
java.lang.IllegalStateException- if the folder isn't openjakarta.mail.MessagingException- for other failures- Since:
- JavaMail 1.3.3
-
listCommand
public java.io.InputStream listCommand() throws jakarta.mail.MessagingException, java.io.IOExceptionReturn the raw results of the POP3 LIST command with no arguments.- Returns:
- InputStream containing results
- Throws:
java.lang.IllegalStateException- if the folder isn't openjava.io.IOException- for I/O errors talking to the serverjakarta.mail.MessagingException- for other errors- Since:
- JavaMail 1.3.3
-
finalize
protected void finalize() throws java.lang.ThrowableClose the folder when we're finalized.- Overrides:
finalizein classjakarta.mail.Folder- Throws:
java.lang.Throwable
-
notifyMessageChangedListeners
protected void notifyMessageChangedListeners(int type, jakarta.mail.Message m)- Overrides:
notifyMessageChangedListenersin classjakarta.mail.Folder
-
-