Class POP3Folder

java.lang.Object
jakarta.mail.Folder
org.eclipse.angus.mail.pop3.POP3Folder
All Implemented Interfaces:
AutoCloseable

public class POP3Folder extends Folder
A POP3 Folder (can only be "INBOX"). See the org.eclipse.angus.mail.pop3 package documentation for further information on the POP3 protocol provider.

  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Description copied from class: Folder
      Returns the name of this Folder.

      This method can be invoked on a closed Folder.

      Specified by:
      getName in class Folder
      Returns:
      name of the Folder
    • getFullName

      public String getFullName()
      Description copied from class: Folder
      Returns 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:
      getFullName in class Folder
      Returns:
      full name of the Folder
    • getParent

      public Folder getParent()
      Description copied from class: Folder
      Returns 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.

      Specified by:
      getParent in class Folder
      Returns:
      Parent folder
    • exists

      public boolean exists()
      Always true for the folder "INBOX", always false for any other name.
      Specified by:
      exists in class Folder
      Returns:
      true for INBOX, false otherwise
      See Also:
    • list

      public Folder[] list(String pattern) throws MessagingException
      Always throws MessagingException because no POP3 folders can contain subfolders.
      Specified by:
      list in class Folder
      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:
    • getSeparator

      public char getSeparator()
      Always returns a NUL character because POP3 doesn't support a hierarchy.
      Specified by:
      getSeparator in class Folder
      Returns:
      NUL
    • getType

      public int getType()
      Always returns Folder.HOLDS_MESSAGES.
      Specified by:
      getType in class Folder
      Returns:
      Folder.HOLDS_MESSAGES
      See Also:
    • create

      public boolean create(int type) throws MessagingException
      Always returns false; the POP3 protocol doesn't support creating folders.
      Specified by:
      create in class Folder
      Parameters:
      type - The type of this folder.
      Returns:
      false
      Throws:
      MessagingException - for failures
      See Also:
    • hasNewMessages

      public boolean hasNewMessages() throws MessagingException
      Always returns false; the POP3 protocol provides no way to determine when a new message arrives.
      Specified by:
      hasNewMessages in class Folder
      Returns:
      false
      Throws:
      FolderNotFoundException - if this folder does not exist.
      MessagingException - for other failures
    • getFolder

      public Folder getFolder(String name) throws MessagingException
      Always throws MessagingException because no POP3 folders can contain subfolders.
      Specified by:
      getFolder in class Folder
      Parameters:
      name - name of the Folder
      Returns:
      Folder object
      Throws:
      MessagingException - always
    • delete

      public boolean delete(boolean recurse) throws MessagingException
      Always throws MethodNotSupportedException because the POP3 protocol doesn't allow the INBOX to be deleted.
      Specified by:
      delete in class Folder
      Parameters:
      recurse - also delete subfolders?
      Returns:
      true if the Folder is deleted successfully
      Throws:
      MethodNotSupportedException - always
      FolderNotFoundException - if this folder does not exist
      MessagingException - for other failures
      See Also:
    • renameTo

      public boolean renameTo(Folder f) throws MessagingException
      Always throws MethodNotSupportedException because the POP3 protocol doesn't support multiple folders.
      Specified by:
      renameTo in class Folder
      Parameters:
      f - a folder representing the new name for this Folder
      Returns:
      true if the Folder is renamed successfully
      Throws:
      MethodNotSupportedException - always
      FolderNotFoundException - if this folder does not exist
      MessagingException - for other failures
      See Also:
    • open

      public void open(int mode) throws MessagingException
      Throws FolderNotFoundException unless this folder is named "INBOX".
      Specified by:
      open in class Folder
      Parameters:
      mode - open the Folder READ_ONLY or READ_WRITE
      Throws:
      FolderNotFoundException - if not INBOX
      AuthenticationFailedException - authentication failures
      MessagingException - other open failures
      See Also:
    • close

      public void close(boolean expunge) throws MessagingException
      Description copied from class: Folder
      Close 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:
      close in class Folder
      Parameters:
      expunge - expunges all deleted messages if this flag is true
      Throws:
      MessagingException - for other failures
      See Also:
    • isOpen

      public boolean isOpen()
      Description copied from class: Folder
      Indicates whether this Folder is in the 'open' state.
      Specified by:
      isOpen in class Folder
      Returns:
      true if this Folder is in the 'open' state.
    • getPermanentFlags

      public Flags getPermanentFlags()
      Always returns an empty Flags object because the POP3 protocol doesn't support any permanent flags.
      Specified by:
      getPermanentFlags in class Folder
      Returns:
      empty Flags object
    • getMessageCount

      public int getMessageCount() throws MessagingException
      Will not change while the folder is open because the POP3 protocol doesn't support notification of new messages arriving in open folders.
      Specified by:
      getMessageCount in class Folder
      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: Folder
      Get 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:
      getMessage in class Folder
      Parameters:
      msgno - the message number
      Returns:
      the Message object
      Throws:
      FolderNotFoundException - if this folder does not exist.
      MessagingException - for other failures
      See Also:
    • createMessage

      protected POP3Message createMessage(Folder f, int msgno) throws MessagingException
      Throws:
      MessagingException
    • appendMessages

      public void appendMessages(Message[] msgs) throws MessagingException
      Always throws MethodNotSupportedException because the POP3 protocol doesn't support appending messages.
      Specified by:
      appendMessages in class Folder
      Parameters:
      msgs - array of Messages to be appended
      Throws:
      MethodNotSupportedException - always
      MessagingException - if the append failed.
      FolderNotFoundException - if this folder does not exist.
    • expunge

      public Message[] expunge() throws MessagingException
      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.
      Specified by:
      expunge in class Folder
      Returns:
      array of expunged Message objects
      Throws:
      MethodNotSupportedException - always
      FolderNotFoundException - if this folder does not exist
      MessagingException - for other failures
      See Also:
    • fetch

      public void fetch(Message[] msgs, FetchProfile fp) throws MessagingException
      Prefetch information about POP3 messages. If the FetchProfile contains 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.
      Overrides:
      fetch in class Folder
      Parameters:
      msgs - fetch items for these messages
      fp - the FetchProfile
      Throws:
      MessagingException - for other failures
    • getUID

      public 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 MessagingException
      Return the size of this folder, as was returned by the POP3 STAT command when this folder was opened.
      Returns:
      folder size
      Throws:
      IllegalStateException - if the folder isn't open
      MessagingException - for other failures
    • getSizes

      public int[] getSizes() throws MessagingException
      Return 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:
      IllegalStateException - if the folder isn't open
      MessagingException - for other failures
      Since:
      JavaMail 1.3.3
    • listCommand

      public InputStream listCommand() throws MessagingException, IOException
      Return the raw results of the POP3 LIST command with no arguments.
      Returns:
      InputStream containing results
      Throws:
      IllegalStateException - if the folder isn't open
      IOException - for I/O errors talking to the server
      MessagingException - for other errors
      Since:
      JavaMail 1.3.3
    • finalize

      protected void finalize() throws Throwable
      Close the folder when we're finalized.
      Overrides:
      finalize in class Folder
      Throws:
      Throwable
    • notifyMessageChangedListeners

      protected void notifyMessageChangedListeners(int type, Message m)
      Description copied from class: Folder
      Notify all MessageChangedListeners. Folder implementations are expected to use this method to broadcast MessageChanged events.

      The 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.

      Overrides:
      notifyMessageChangedListeners in class Folder
      Parameters:
      type - the MessageChangedEvent type
      m - the message that changed