Module jakarta.mail

Class MessageCache


  • public class MessageCache
    extends java.lang.Object
    A cache of IMAPMessage objects along with the mapping from message number to IMAP sequence number. All operations on this object are protected by the messageCacheLock in IMAPFolder.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addMessages​(int count, int newSeqNum)
      Add count messages to the cache.
      void expungeMessage​(int seqnum)
      Expunge the message with the given sequence number.
      IMAPMessage getMessage​(int msgnum)
      Get the message object for the indicated message number.
      IMAPMessage getMessageBySeqnum​(int seqnum)
      Get the message object for the indicated sequence number.
      IMAPMessage[] removeExpungedMessages()
      Remove all the expunged messages from the array, returning a list of removed message objects.
      IMAPMessage[] removeExpungedMessages​(Message[] msgs)
      Remove expunged messages in msgs from the array, returning a list of removed message objects.
      int seqnumOf​(int msgnum)
      Return the sequence number for the given message number.
      int size()
      Size of cache.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • size

        public int size()
        Size of cache.
        Returns:
        the size of the cache
      • getMessage

        public IMAPMessage getMessage​(int msgnum)
        Get the message object for the indicated message number. If the message object hasn't been created, create it.
        Parameters:
        msgnum - the message number
        Returns:
        the message
      • getMessageBySeqnum

        public IMAPMessage getMessageBySeqnum​(int seqnum)
        Get the message object for the indicated sequence number. If the message object hasn't been created, create it. Return null if there's no message with that sequence number.
        Parameters:
        seqnum - the sequence number of the message
        Returns:
        the message
      • expungeMessage

        public void expungeMessage​(int seqnum)
        Expunge the message with the given sequence number.
        Parameters:
        seqnum - the sequence number of the message to expunge
      • removeExpungedMessages

        public IMAPMessage[] removeExpungedMessages()
        Remove all the expunged messages from the array, returning a list of removed message objects.
        Returns:
        the removed messages
      • removeExpungedMessages

        public IMAPMessage[] removeExpungedMessages​(Message[] msgs)
        Remove expunged messages in msgs from the array, returning a list of removed message objects. All messages in msgs must be IMAPMessage objects from this folder.
        Parameters:
        msgs - the messages
        Returns:
        the removed messages
      • addMessages

        public void addMessages​(int count,
                                int newSeqNum)
        Add count messages to the cache. newSeqNum is the sequence number of the first message added.
        Parameters:
        count - the number of messges
        newSeqNum - sequence number of first message
      • seqnumOf

        public int seqnumOf​(int msgnum)
        Return the sequence number for the given message number.
        Parameters:
        msgnum - the message number
        Returns:
        the sequence number