- java.lang.Object
-
- javax.mail.Folder
-
- com.sun.mail.pop3.POP3Folder
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class POP3Folder extends Folder
A POP3 Folder (can only be "INBOX"). See the com.sun.mail.pop3 package documentation for further information on the POP3 protocol provider.- Author:
- Bill Shannon, John Mani (ported to the javax.mail APIs)
-
-
Field Summary
-
Fields inherited from class javax.mail.Folder
HOLDS_FOLDERS, HOLDS_MESSAGES, mode, READ_ONLY, READ_WRITE
-
-
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(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(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.Message[]expunge()Always throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't support expunging messages without closing the folder; call theclosemethod with theexpungeargument set totrueinstead.voidfetch(Message[] msgs, FetchProfile fp)Prefetch information about POP3 messages.protected voidfinalize()Close the folder when we're finalized.FoldergetFolder(java.lang.String name)Always throwsMessagingExceptionbecause no POP3 folders can contain subfolders.java.lang.StringgetFullName()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()FoldergetParent()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(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()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, Message m)voidopen(int mode)ThrowsFolderNotFoundExceptionunless this folder is named "INBOX".booleanrenameTo(Folder f)Always throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't support multiple folders.-
Methods inherited from class javax.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
-
getFullName
public java.lang.String getFullName()
- Specified by:
getFullNamein classFolder
-
exists
public boolean exists()
Always true for the folder "INBOX", always false for any other name.
-
list
public Folder[] list(java.lang.String pattern) throws MessagingException
Always throwsMessagingExceptionbecause no POP3 folders can contain subfolders.- Specified by:
listin classFolder- Throws:
MessagingException- always
-
getSeparator
public char getSeparator()
Always returns a NUL character because POP3 doesn't support a hierarchy.- Specified by:
getSeparatorin classFolder- Returns:
- NUL
-
getType
public int getType()
Always returns Folder.HOLDS_MESSAGES.
-
create
public boolean create(int type) throws MessagingExceptionAlways returnsfalse; the POP3 protocol doesn't support creating folders.- Specified by:
createin classFolder- Returns:
- false
- Throws:
MessagingException
-
hasNewMessages
public boolean hasNewMessages() throws MessagingExceptionAlways returnsfalse; the POP3 protocol provides no way to determine when a new message arrives.- Specified by:
hasNewMessagesin classFolder- Returns:
- false
- Throws:
MessagingException
-
getFolder
public Folder getFolder(java.lang.String name) throws MessagingException
Always throwsMessagingExceptionbecause no POP3 folders can contain subfolders.- Specified by:
getFolderin classFolder- Throws:
MessagingException- always
-
delete
public boolean delete(boolean recurse) throws MessagingExceptionAlways throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't allow the INBOX to be deleted.- Specified by:
deletein classFolder- Throws:
MethodNotSupportedException- alwaysMessagingException
-
renameTo
public boolean renameTo(Folder f) throws MessagingException
Always throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't support multiple folders.- Specified by:
renameToin classFolder- Throws:
MethodNotSupportedException- alwaysMessagingException
-
open
public void open(int mode) throws MessagingExceptionThrowsFolderNotFoundExceptionunless this folder is named "INBOX".- Specified by:
openin classFolder- Throws:
FolderNotFoundException- if not INBOXAuthenticationFailedException- authentication failuresMessagingException- other open failures
-
close
public void close(boolean expunge) throws MessagingException- Specified by:
closein classFolder- Throws:
MessagingException
-
getPermanentFlags
public Flags getPermanentFlags()
Always returns an emptyFlagsobject because the POP3 protocol doesn't support any permanent flags.- Specified by:
getPermanentFlagsin classFolder- Returns:
- empty Flags object
-
getMessageCount
public int getMessageCount() throws 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 classFolder- Throws:
MessagingException
-
getMessage
public Message getMessage(int msgno) throws MessagingException
- Specified by:
getMessagein classFolder- Throws:
MessagingException
-
createMessage
protected POP3Message createMessage(Folder f, int msgno) throws MessagingException
- Throws:
MessagingException
-
appendMessages
public void appendMessages(Message[] msgs) throws MessagingException
Always throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't support appending messages.- Specified by:
appendMessagesin classFolder- Throws:
MethodNotSupportedException- alwaysMessagingException
-
expunge
public Message[] expunge() throws MessagingException
Always throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't support expunging messages without closing the folder; call theclosemethod with theexpungeargument set totrueinstead.- Specified by:
expungein classFolder- Throws:
MethodNotSupportedException- alwaysMessagingException
-
fetch
public void fetch(Message[] msgs, FetchProfile fp) throws MessagingException
Prefetch 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 classFolder- Throws:
MessagingException
-
getUID
public java.lang.String getUID(Message msg) throws MessagingException
Return 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:
MessagingException- for failures
-
getSize
public int getSize() throws 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 openMessagingException- for other failures
-
getSizes
public int[] getSizes() throws 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 openMessagingException- for other failures- Since:
- JavaMail 1.3.3
-
listCommand
public java.io.InputStream listCommand() throws 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 serverMessagingException- for other errors- Since:
- JavaMail 1.3.3
-
finalize
protected void finalize() throws java.lang.ThrowableClose the folder when we're finalized.
-
notifyMessageChangedListeners
protected void notifyMessageChangedListeners(int type, Message m)- Overrides:
notifyMessageChangedListenersin classFolder
-
-