org.apache.james.mailbox
Interface MessageResult

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

public interface MessageResult
extends java.lang.Comparable<MessageResult>, 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.FetchGroup
          Indicates the results fetched.
static interface MessageResult.Header
          A header.
static interface MessageResult.MimePath
          Describes a path within a multipart MIME message.
 
Method Summary
 Content getBody()
          Gets the body of the message excluding headers.
 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.
 Content getFullContent()
          Gets the full message including headers and body.
 Content getFullContent(MessageResult.MimePath path)
          Gets the full content of the given mime part.
 java.util.Date getInternalDate()
           IMAP defines this as the time when the message has arrived to the server (by smtp).
 Content getMimeBody(MessageResult.MimePath path)
          Gets the body of the given mime part.
 MimeDescriptor getMimeDescriptor()
           
 long getSize()
          Return the size in bytes
 long getUid()
          Return the uid of the message which the MessageResult belongs to
 java.util.Iterator<MessageResult.Header> iterateHeaders(MessageResult.MimePath path)
          Iterates the message headers for the given part in a multipart message.
 java.util.Iterator<MessageResult.Header> iterateMimeHeaders(MessageResult.MimePath path)
          Iterates the MIME headers for the given part in a multipart message.
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface org.apache.james.mailbox.Headers
headers
 

Method Detail

getMimeDescriptor

MimeDescriptor getMimeDescriptor()
                                 throws MailboxException
Throws:
MailboxException

getUid

long getUid()
Return the uid of the message which the MessageResult belongs to

Returns:
uid

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 MailboxException
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:
MailboxException

getSize

long getSize()
Return the size in bytes

Returns:
size

iterateHeaders

java.util.Iterator<MessageResult.Header> iterateHeaders(MessageResult.MimePath path)
                                                        throws MailboxException
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:
MailboxException

iterateMimeHeaders

java.util.Iterator<MessageResult.Header> iterateMimeHeaders(MessageResult.MimePath path)
                                                            throws MailboxException
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:
MailboxException

getFullContent

Content getFullContent()
                       throws MailboxException
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:
MailboxException

getFullContent

Content getFullContent(MessageResult.MimePath path)
                       throws MailboxException
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:
MailboxException

getBody

Content getBody()
                throws MailboxException
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:
MailboxException

getBody

Content getBody(MessageResult.MimePath path)
                throws MailboxException
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:
MailboxException

getMimeBody

Content getMimeBody(MessageResult.MimePath path)
                    throws MailboxException
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:
MailboxException


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