org.apache.james.mailboxmanager
Interface MessageResult

All Superinterfaces:
java.lang.Comparable, Headers
All Known Implementing Classes:
MessageResultImpl

public interface MessageResult
extends java.lang.Comparable, Headers

Used to get specific informations about a Message without dealing with a MimeMessage instance. Demanded information can be requested by binary combining the constants.

I came to the Idea of the MessageResult because there are many possible combinations of different requests (uid, msn, MimeMessage, Flags).

e.g. I want to have all uids, msns and flags of all messages. (a common IMAP operation) Javamail would do it that way:

  1. get all Message objects (Message[])
  2. call Message.getMessageNumber()
  3. call Message.getFlags()
  4. call Folder.getUid(Message)

This means creating a lazy-loading MimeMessage instance.
So why don't call getMessages(MessageResult.UID | MessageResult.MSN | MessageResult.FLAGS)? This would leave a lot of room for the implementation to optimize


Nested Class Summary
static interface MessageResult.Content
          IMAP needs to know the size of the content before it starts to write it out.
static interface MessageResult.FetchGroup
          Indicates the results fetched.
static interface MessageResult.Header
          A header.
static interface MessageResult.MimeDescriptor
           
static interface MessageResult.MimePath
          Describes a path within a multipart MIME message.
 
Method Summary
 MessageResult.Content getBody()
          Gets the body of the message excluding headers.
 MessageResult.Content getBody(MessageResult.MimePath path)
          Gets the body of the given mime part.
 javax.mail.Flags getFlags()
          TODO optional, to be decided
maybe this is a good thing because IMAP often requests only the Flags and this way we don't need to create a lazy-loading MimeMessage instance just for the Flags.
 MessageResult.Content getFullContent()
          Gets the full message including headers and body.
 MessageResult.Content getFullContent(MessageResult.MimePath path)
          Gets the full content of the given mime part.
 MessageResult.FetchGroup getIncludedResults()
          Gets the results set.
 java.util.Date getInternalDate()
           IMAP defines this as the time when the message has arrived to the server (by smtp).
 MessageResult.Content getMimeBody(MessageResult.MimePath path)
          Gets the body of the given mime part.
 MessageResult.MimeDescriptor getMimeDescriptor()
           
 int getSize()
           
 long getUid()
           
 long getUidValidity()
           
 java.util.Iterator headers()
          Gets headers for the message.
 java.util.Iterator iterateHeaders(MessageResult.MimePath path)
          Iterates the message headers for the given part in a multipart message.
 java.util.Iterator iterateMimeHeaders(MessageResult.MimePath path)
          Iterates the MIME headers for the given part in a multipart message.
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getIncludedResults

MessageResult.FetchGroup getIncludedResults()
Gets the results set.

Returns:
bitwise indication of result set
See Also:
MessageResultUtils.isIncluded(MessageResult, int)

getMimeDescriptor

MessageResult.MimeDescriptor getMimeDescriptor()
                                               throws MailboxManagerException
Throws:
MailboxManagerException

getUid

long getUid()

getUidValidity

long getUidValidity()

getInternalDate

java.util.Date getInternalDate()

IMAP defines this as the time when the message has arrived to the server (by smtp). Clients are also allowed to set the internalDate on apppend.

Is this Mail.getLastUpdates() for James delivery? Should we use MimeMessage.getReceivedDate()?


getFlags

javax.mail.Flags getFlags()
                          throws MailboxManagerException
TODO optional, to be decided
maybe this is a good thing because IMAP often requests only the Flags and this way we don't need to create a lazy-loading MimeMessage instance just for the Flags.

Throws:
MailboxManagerException

getSize

int getSize()

headers

java.util.Iterator headers()
                           throws MailboxManagerException
Gets headers for the message.

Specified by:
headers in interface Headers
Returns:
Header Iterator, or null if MessageResult.FetchGroup.HEADERS was not fetched
Throws:
MailboxManagerException

iterateHeaders

java.util.Iterator iterateHeaders(MessageResult.MimePath path)
                                  throws MailboxManagerException
Iterates the message headers for the given part in a multipart message.

Parameters:
path - describing the part's position within a multipart message
Returns:
Header Iterator, or null when FetchGroup#mimeHeaders() does not include the index and when the mime part cannot be found
Throws:
MailboxManagerException

iterateMimeHeaders

java.util.Iterator iterateMimeHeaders(MessageResult.MimePath path)
                                      throws MailboxManagerException
Iterates the MIME headers for the given part in a multipart message.

Parameters:
path - describing the part's position within a multipart message
Returns:
Header Iterator, or null when FetchGroup#mimeHeaders() does not include the index and when the mime part cannot be found
Throws:
MailboxManagerException

getFullContent

MessageResult.Content getFullContent()
                                     throws MailboxManagerException
Gets the full message including headers and body. The message data should have normalised line endings (CRLF).

Returns:
Content, or or null if MessageResult.FetchGroup.FULL_CONTENT has not been included in the results
Throws:
MailboxManagerException

getFullContent

MessageResult.Content getFullContent(MessageResult.MimePath path)
                                     throws MailboxManagerException
Gets the full content of the given mime part.

Parameters:
path - describes the part
Returns:
Content, or null when FetchGroup#mimeBodies() did not been include the given index and when the mime part cannot be found
Throws:
MailboxManagerException

getBody

MessageResult.Content getBody()
                              throws MailboxManagerException
Gets the body of the message excluding headers. The message data should have normalised line endings (CRLF).

Returns:
Content, or or null if MessageResult.FetchGroup.FULL_CONTENT has not been included in the results
Throws:
MailboxManagerException

getBody

MessageResult.Content getBody(MessageResult.MimePath path)
                              throws MailboxManagerException
Gets the body of the given mime part.

Parameters:
path - describes the part
Returns:
Content, or null when FetchGroup#mimeBodies() did not been include the given index and when the mime part cannot be found
Throws:
MailboxManagerException

getMimeBody

MessageResult.Content getMimeBody(MessageResult.MimePath path)
                                  throws MailboxManagerException
Gets the body of the given mime part.

Parameters:
path - describes the part
Returns:
Content, or null when FetchGroup#mimeBodies() did not been include the given index and when the mime part cannot be found
Throws:
MailboxManagerException


Copyright © 2002-2008 The Apache Software Foundation. All Rights Reserved.