Class POP3Folder
- 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.
-
-
Field Summary
-
Fields inherited from class javax.mail.Folder
HOLDS_FOLDERS, HOLDS_MESSAGES, READ_ONLY, READ_WRITE
-
-
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)Close this Folder.booleancreate(int type)Always returnsfalse; the POP3 protocol doesn't support creating folders.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.FoldergetFolder(java.lang.String name)Always throwsMessagingExceptionbecause no POP3 folders can contain subfolders.java.lang.StringgetFullName()Returns the full name of this Folder.MessagegetMessage(int msgno)Get the Message object corresponding to the given message number.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()Returns the name of this Folder.FoldergetParent()Returns the parent folder of this folder.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()Indicates whether this Folder is in the 'open' state.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.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, removeConnectionListener, removeFolderListener, removeMessageChangedListener, removeMessageCountListener, search, search, setFlags, setFlags, setFlags, setSubscribed, toString
-
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from class:FolderReturns the name of this Folder.This method can be invoked on a closed Folder.
-
getFullName
public java.lang.String getFullName()
Description copied from class:FolderReturns the full name of this Folder. If the folder resides under the root hierarchy of this 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:
getFullNamein classFolder- Returns:
- full name of the Folder
-
getParent
public Folder getParent()
Description copied from class:FolderReturns the parent folder of this folder. This method can be invoked on a closed Folder. If this folder is the top of a folder hierarchy, this method returns null.Note that since Folder objects are not cached, invoking this method returns a new distinct Folder object.
-
exists
public boolean exists()
Always true for the folder "INBOX", always false for any other name.- Specified by:
existsin classFolder- Returns:
- true for INBOX, false otherwise
- See Also:
Folder.create(int)
-
list
public Folder[] list(java.lang.String pattern) throws MessagingException
Always throwsMessagingExceptionbecause no POP3 folders can contain subfolders.- Specified by:
listin classFolder- Parameters:
pattern- the match pattern- Returns:
- array of matching Folder objects. An empty array is returned if no matching Folders exist.
- Throws:
MessagingException- always- See Also:
Folder.listSubscribed(java.lang.String)
-
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.- Specified by:
getTypein classFolder- Returns:
- Folder.HOLDS_MESSAGES
- See Also:
Folder.HOLDS_FOLDERS,Folder.HOLDS_MESSAGES
-
create
public boolean create(int type) throws MessagingExceptionAlways returnsfalse; the POP3 protocol doesn't support creating folders.- Specified by:
createin classFolder- Parameters:
type- The type of this folder.- Returns:
- false
- Throws:
MessagingException- for failures- See Also:
Folder.HOLDS_FOLDERS,Folder.HOLDS_MESSAGES,FolderEvent
-
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:
FolderNotFoundException- if this folder does not exist.MessagingException- for other failures
-
getFolder
public Folder getFolder(java.lang.String name) throws MessagingException
Always throwsMessagingExceptionbecause no POP3 folders can contain subfolders.- Specified by:
getFolderin classFolder- Parameters:
name- name of the Folder- Returns:
- Folder object
- 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- Parameters:
recurse- also delete subfolders?- Returns:
- true if the Folder is deleted successfully
- Throws:
MethodNotSupportedException- alwaysFolderNotFoundException- if this folder does not existMessagingException- for other failures- See Also:
FolderEvent
-
renameTo
public boolean renameTo(Folder f) throws MessagingException
Always throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't support multiple folders.- Specified by:
renameToin classFolder- Parameters:
f- a folder representing the new name for this Folder- Returns:
- true if the Folder is renamed successfully
- Throws:
MethodNotSupportedException- alwaysFolderNotFoundException- if this folder does not existMessagingException- for other failures- See Also:
FolderEvent
-
open
public void open(int mode) throws MessagingExceptionThrowsFolderNotFoundExceptionunless this folder is named "INBOX".- Specified by:
openin classFolder- Parameters:
mode- open the Folder READ_ONLY or READ_WRITE- Throws:
FolderNotFoundException- if not INBOXAuthenticationFailedException- authentication failuresMessagingException- other open failures- See Also:
Folder.READ_ONLY,Folder.READ_WRITE,Folder.getType(),ConnectionEvent
-
close
public void close(boolean expunge) throws MessagingExceptionDescription copied from class:FolderClose this Folder. This method is valid only on open Folders.A 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.
- Specified by:
closein classFolder- Parameters:
expunge- expunges all deleted messages if this flag is true- Throws:
MessagingException- for other failures- See Also:
ConnectionEvent
-
isOpen
public boolean isOpen()
Description copied from class:FolderIndicates whether this Folder is in the 'open' state.
-
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- Returns:
- total number of messages. -1 may be returned by certain implementations if this method is invoked on a closed folder.
- Throws:
FolderNotFoundException- if this folder does not exist.MessagingException- for other failures
-
getMessage
public Message getMessage(int msgno) throws MessagingException
Description copied from class:FolderGet the Message object corresponding to the given message number. A Message object's message number is the relative position of this Message in its Folder. Messages are numbered starting at 1 through the total number of message in the folder. Note that the message number for a particular Message can change during a session if other messages in the Folder are deleted and the Folder is expunged.Message 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.
- Specified by:
getMessagein classFolder- Parameters:
msgno- the message number- Returns:
- the Message object
- Throws:
FolderNotFoundException- if this folder does not exist.MessagingException- for other failures- See Also:
Folder.getMessageCount(),Folder.fetch(javax.mail.Message[], javax.mail.FetchProfile)
-
appendMessages
public void appendMessages(Message[] msgs) throws MessagingException
Always throwsMethodNotSupportedExceptionbecause the POP3 protocol doesn't support appending messages.- Specified by:
appendMessagesin classFolder- Parameters:
msgs- array of Messages to be appended- Throws:
MethodNotSupportedException- alwaysFolderNotFoundException- if this folder does not exist.MessagingException- if the append failed.
-
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- Returns:
- array of expunged Message objects
- Throws:
MethodNotSupportedException- alwaysFolderNotFoundException- if this folder does not existMessagingException- for other failures- See Also:
Message.isExpunged(),MessageCountEvent
-
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- Parameters:
msgs- fetch items for these messagesfp- the FetchProfile- Throws:
MessagingException- for other failures
-
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
-
-