Class MboxFolder


  • public class MboxFolder
    extends Folder
    The folder class implementing a UNIX mbox-format mailbox.
    Author:
    Chris Burdess
    • Constructor Detail

      • MboxFolder

        protected MboxFolder​(Store store,
                             java.io.File file,
                             boolean inbox)
        Constructor.
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns the name of this folder.
        Specified by:
        getName in class Folder
      • getFullName

        public java.lang.String getFullName()
        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.
        Specified by:
        getFullName in class Folder
      • open

        public void open​(int mode)
                  throws MessagingException
        Opens this folder. If the folder is opened for writing, a lock must be acquired on the mbox. If this fails a MessagingException is thrown.
        Specified by:
        open in class Folder
        Parameters:
        mode - open the Folder READ_ONLY or READ_WRITE
        Throws:
        MessagingException - if a messaging error occurred
      • decodeFrom

        public static java.lang.String decodeFrom​(java.lang.String line)
        Returns the specified line with any From_ line encoding removed.
      • close

        public void close​(boolean expunge)
                   throws MessagingException
        Closes this folder.
        Specified by:
        close in class Folder
        Parameters:
        expunge - if the folder is to be expunged before it is closed
        Throws:
        MessagingException - if a messaging error occurred
      • fromLine

        protected java.lang.String fromLine​(MboxMessage message)
                                     throws MessagingException
        Returns the From_ line for the specified mbox message. If this does not already exist(the message was appended to the folder since it was last opened), we will attempt to generate a suitable From_ line for it.
        Throws:
        MessagingException
      • isOpen

        public boolean isOpen()
        Indicates whether this folder is open.
        Specified by:
        isOpen in class Folder
      • getPermanentFlags

        public Flags getPermanentFlags()
        Returns the permanent flags for this folder.
        Specified by:
        getPermanentFlags in class Folder
      • appendMessages

        public void appendMessages​(Message[] m)
                            throws MessagingException
        Appends messages to this folder. Only MimeMessages within the array will be appended, as we don't know how to retrieve internet content for other kinds.
        Specified by:
        appendMessages in class Folder
        Parameters:
        m - an array of messages to be appended
        Throws:
        FolderNotFoundException - if this folder does not exist
        MessagingException - if the append operation failed
      • acquireLock

        public boolean acquireLock()
        Locks this mailbox. This uses a dotlock-like mechanism - see createNewFile(). If the directory containing the mbox folder is not writable, we will not be able to open the mbox for writing either.
      • releaseLock

        public boolean releaseLock()
        Unlocks this mailbox. This deletes any associated lockfile if it exists. It returns false if an existing lockfile could not be deleted.