org.abstracthorizon.mercury.maildir.uid
Class UIDMaildirMessage

java.lang.Object
  extended by javax.mail.Message
      extended by javax.mail.internet.MimeMessage
          extended by org.abstracthorizon.mercury.maildir.util.MessageBase
              extended by org.abstracthorizon.mercury.maildir.util.LazyParsingMessage
                  extended by org.abstracthorizon.mercury.maildir.MaildirMessage
                      extended by org.abstracthorizon.mercury.maildir.uid.UIDMaildirMessage
All Implemented Interfaces:
FilenameFilter, Comparable<MaildirMessage>, javax.mail.internet.MimePart, javax.mail.Part, FileProvider, UIDMessage

public class UIDMaildirMessage
extends MaildirMessage
implements UIDMessage

UID Maildir message representation.

Messages file name is defined in the following way:

Flags are defined on the way explained in FlagUtilities

Note: If file supplied in one of the constructors doesn't match this file name pattern file is then renamed to match it. Also, if file name matches that pattern but folder's hash code is different (folder's hash code represents UID validity) file is again renamed to proper one.

Author:
Daniel Sendula

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.mail.internet.MimeMessage
javax.mail.internet.MimeMessage.RecipientType
 
Field Summary
 
Fields inherited from class org.abstracthorizon.mercury.maildir.MaildirMessage
baseName, CREATE_FILE_RETRIES, file, fileSize, FLAGS_SEPERATOR, host, infoSeparator, isNew, maildirFolder, randomGenerator
 
Fields inherited from class org.abstracthorizon.mercury.maildir.util.LazyParsingMessage
inputStream, parsed
 
Fields inherited from class javax.mail.internet.MimeMessage
content, contentStream, dh, flags, headers, modified, saved
 
Fields inherited from class javax.mail.Message
expunged, folder, msgnum, session
 
Fields inherited from interface javax.mail.Part
ATTACHMENT, INLINE
 
Constructor Summary
  UIDMaildirMessage(MaildirFolderData folder, File file, int msgnum)
          This constructor creates new message from supplied file.
protected UIDMaildirMessage(MaildirFolderData folder, javax.mail.internet.MimeMessage message, int msgnum)
          Creates new message based on another message.
 
Method Summary
 int compareTo(MaildirMessage o)
          This method compares two messages' uids.
protected  String createFileName(String flags)
          Creates file name using supplied flags.
 boolean equals(Object o)
          This object compares two messages based on UID value.
 UID getUID()
          Returns message's UID object.
 
Methods inherited from class org.abstracthorizon.mercury.maildir.MaildirMessage
accept, baseNameFromFile, closeFile, createFile, expunge, getBaseName, getFile, getFileSize, getReceivedDate, initialise, parse, parseImpl, setFile, setFlags, storeMessage, synchronise
 
Methods inherited from class org.abstracthorizon.mercury.maildir.util.LazyParsingMessage
addFrom, addHeader, addHeaderLine, addRecipient, addRecipients, addRecipients, createInternetHeaders, getAllHeaderLines, getAllHeaders, getAllRecipients, getContent, getContentID, getContentLanguage, getContentMD5, getContentStream, getContentType, getDataHandler, getDescription, getDisposition, getEncoding, getFileName, getFrom, getHeader, getHeader, getInputStream, getLineCount, getMatchingHeaderLines, getMatchingHeaders, getMessageID, getNonMatchingHeaderLines, getNonMatchingHeaders, getRawInputStream, getRecipients, getReplyTo, getSender, getSentDate, getSize, getSubject, isExpunged, isMimeType, isParsed, match, removeHeader, reply, saveChanges, setContent, setContent, setContentID, setContentLanguage, setContentMD5, setDataHandler, setDescription, setDescription, setDisposition, setFileName, setFrom, setFrom, setHeader, setRecipient, setRecipients, setRecipients, setReplyTo, setSender, setSentDate, setSubject, setSubject, setText, setText, updateHeaders, writeTo, writeTo
 
Methods inherited from class org.abstracthorizon.mercury.maildir.util.MessageBase
setMessageNumber
 
Methods inherited from class javax.mail.internet.MimeMessage
createMimeMessage, getFlags, isSet, setText, updateMessageID
 
Methods inherited from class javax.mail.Message
getFolder, getMessageNumber, setExpunged, setFlag
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UIDMaildirMessage

protected UIDMaildirMessage(MaildirFolderData folder,
                            javax.mail.internet.MimeMessage message,
                            int msgnum)
                     throws javax.mail.MessagingException,
                            IOException
Creates new message based on another message. It will create new file for this message in supplied folder.

Parameters:
folder - folder this message belongs to
message - message
msgnum - message number
Throws:
javax.mail.MessagingException
IOException

UIDMaildirMessage

public UIDMaildirMessage(MaildirFolderData folder,
                         File file,
                         int msgnum)
                  throws javax.mail.MessagingException
This constructor creates new message from supplied file. If supplied file doesn't match appropriate format than it is renamed.

Parameters:
folder - folder this message belongs to
file - file
msgnum - message number
Throws:
javax.mail.MessagingException
Method Detail

createFileName

protected String createFileName(String flags)
                         throws javax.mail.MessagingException
Creates file name using supplied flags.

Overrides:
createFileName in class MaildirMessage
Parameters:
flags - flags
Returns:
file name for this message
Throws:
javax.mail.MessagingException

getUID

public UID getUID()
Returns message's UID object.

Specified by:
getUID in interface UIDMessage
Returns:
message's UID object.

equals

public boolean equals(Object o)
This object compares two messages based on UID value.

Overrides:
equals in class Object
Parameters:
o - message to be compared
Returns:
true if both messages have same UID. False is returned if UIDs are different or supplied object is not UID message

compareTo

public int compareTo(MaildirMessage o)
This method compares two messages' uids.

Specified by:
compareTo in interface Comparable<MaildirMessage>
Overrides:
compareTo in class MaildirMessage
Parameters:
o - message to be compared with
Returns:
-1, 0, 1 depending if this message has less, equal or greater UID then supplied. If supplied object is not UID message then -1 is returned.


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.