Class Folder

  • Direct Known Subclasses:
    POP3Folder

    public abstract class Folder
    extends java.lang.Object
    Folder is an abstract class that represents a folder for mail messages. Subclasses implement protocol specific Folders.
    Since:
    TotalCross 1.13
    • Field Detail

      • store

        protected Store store
      • messagesByUidl

        protected Hashtable messagesByUidl
      • messagesByNumber

        protected Hashtable messagesByNumber
      • expungedMessages

        protected Hashtable expungedMessages
      • messageCount

        protected int messageCount
      • deletedMessageCount

        protected int deletedMessageCount
      • HEADER_BUFFER_SIZE

        public int HEADER_BUFFER_SIZE
      • msgHeaderBuffer

        protected byte[] msgHeaderBuffer
    • Constructor Detail

      • Folder

        protected Folder​(Store store)
        Constructor that takes a Store object.
        Parameters:
        store - the Store that holds this folder
        Since:
        TotalCross 1.13
    • Method Detail

      • open

        public abstract void open()
                           throws MessagingException
        Open this Folder. This method is valid only on Folders that can contain Messages and that are closed.
        Throws:
        MessagingException
        Since:
        TotalCross 1.13
      • getMessageCount

        public int getMessageCount()
                            throws MessagingException
        Get total number of messages in this Folder. This method can be invoked on a closed folder. However, note that for some folder implementations, getting the total message count can be an expensive operation involving actually opening the folder. In such cases, a provider can choose not to support this functionality in the closed state, in which case this method must return -1. Clients invoking this method on a closed folder must be aware that this is a potentially expensive operation. Clients must also be prepared to handle a return value of -1 in this case.
        Returns:
        total number of messages. -1 may be returned by certain implementations if this method is invoked on a closed folder.
        Throws:
        MessagingException
        Since:
        TotalCross 1.13
      • getMessages

        public Message[] getMessages()
                              throws MessagingException
        Get all Message objects from this Folder. Returns an empty array if the folder is empty. Clients can use Message objects (instead of sequence numbers) as references to the messages within a folder; this method supplies the Message objects to the client. Folder implementations are expected to provide light-weight Message objects, which get filled on demand. This implementation invokes uses getMessage() to get Message objects from 1 till the message count.
        Returns:
        array of Message objects, empty array if folder is empty.
        Throws:
        MessagingException
        Since:
        TotalCross 1.13
      • getMessages

        public Message[] getMessages​(int start,
                                     int end)
                              throws MessagingException
        Get the Message objects for message numbers ranging from start through end, both start and end inclusive. Note that message numbers start at 1, not 0. 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. This implementation uses getMessage(index) to obtain the required Message objects. Note that the returned array must contain (end-start+1) Message objects.
        Parameters:
        start -
        end -
        Returns:
        The Message array
        Throws:
        MessagingException
        Since:
        TotalCross 1.13
      • getMessage

        public abstract Message getMessage​(int msgnum)
                                    throws MessagingException
        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.
        Parameters:
        msgnum - the message number
        Returns:
        the Message object
        Throws:
        MessagingException
        Since:
        TotalCross 1.13
      • reset

        public abstract void reset()
                            throws MessagingException
        Reset this session, undoing any operations performed over messages on this folder during this session.
        Throws:
        MessagingException
        Since:
        TotalCross 1.13
      • close

        public void close​(boolean b)
        Close this Folder. This method is valid only on open Folders.
        Parameters:
        b -
        Since:
        TotalCross 1.13