org.apache.james.mailboxmanager.impl
Class MessageResultImpl

java.lang.Object
  extended by org.apache.james.mailboxmanager.impl.MessageResultImpl
All Implemented Interfaces:
java.lang.Comparable, Headers, MessageResult

public class MessageResultImpl
extends java.lang.Object
implements MessageResult

Bean based implementation. getIncludedResults() is updated when setters are called.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.james.mailboxmanager.MessageResult
MessageResult.Content, MessageResult.FetchGroup, MessageResult.Header, MessageResult.MimeDescriptor, MessageResult.MimePath
 
Constructor Summary
MessageResultImpl()
           
MessageResultImpl(long uid)
           
MessageResultImpl(long uid, javax.mail.Flags flags)
           
MessageResultImpl(MessageResult result)
           
 
Method Summary
 int compareTo(java.lang.Object o)
           
 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.
 java.util.List getHeaders()
           
 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()
           
 javax.mail.internet.MimeMessage getMimeMessage()
           
 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.
 void setBody(MessageResult.Content messageBody)
           
 void setBodyContent(MessageResult.MimePath path, MessageResult.Content content)
           
 void setFlags(javax.mail.Flags flags)
           
 void setFullContent(MessageResult.Content fullMessage)
           
 void setFullContent(MessageResult.MimePath path, MessageResult.Content content)
           
 void setHeaders(java.util.List headers)
           
 void setHeaders(MessageResult.MimePath path, java.util.Iterator headers)
           
 void setInternalDate(java.util.Date internalDate)
           
 void setMimeBodyContent(MessageResult.MimePath path, MessageResult.Content content)
           
 void setMimeDescriptor(MessageResult.MimeDescriptor mimeDescriptor)
           
 void setMimeHeaders(MessageResult.MimePath path, java.util.Iterator headers)
           
 void setSize(int size)
           
 void setUid(long uid)
           
 java.lang.String toString()
          Renders suitably for logging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MessageResultImpl

public MessageResultImpl(long uid)

MessageResultImpl

public MessageResultImpl()

MessageResultImpl

public MessageResultImpl(long uid,
                         javax.mail.Flags flags)

MessageResultImpl

public MessageResultImpl(MessageResult result)
                  throws MailboxManagerException
Throws:
MailboxManagerException
Method Detail

getIncludedResults

public MessageResult.FetchGroup getIncludedResults()
Description copied from interface: MessageResult
Gets the results set.

Specified by:
getIncludedResults in interface MessageResult
Returns:
bitwise indication of result set
See Also:
MessageResultUtils.isIncluded(MessageResult, int)

getMimeMessage

public javax.mail.internet.MimeMessage getMimeMessage()

getUid

public long getUid()
Specified by:
getUid in interface MessageResult

getUidValidity

public long getUidValidity()
Specified by:
getUidValidity in interface MessageResult

getInternalDate

public java.util.Date getInternalDate()
Description copied from interface: MessageResult

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()?

Specified by:
getInternalDate in interface MessageResult

getFlags

public javax.mail.Flags getFlags()
Description copied from interface: MessageResult
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.

Specified by:
getFlags in interface MessageResult

setUid

public void setUid(long uid)

getSize

public int getSize()
Specified by:
getSize in interface MessageResult

setFlags

public void setFlags(javax.mail.Flags flags)

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

setSize

public void setSize(int size)

setInternalDate

public void setInternalDate(java.util.Date internalDate)

headers

public java.util.Iterator headers()
Description copied from interface: Headers
Gets headers for the message.

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

getHeaders

public java.util.List getHeaders()

setHeaders

public void setHeaders(java.util.List headers)

getFullContent

public final MessageResult.Content getFullContent()
Description copied from interface: MessageResult
Gets the full message including headers and body. The message data should have normalised line endings (CRLF).

Specified by:
getFullContent in interface MessageResult
Returns:
Content, or or null if MessageResult.FetchGroup.FULL_CONTENT has not been included in the results

setFullContent

public final void setFullContent(MessageResult.Content fullMessage)

getBody

public final MessageResult.Content getBody()
Description copied from interface: MessageResult
Gets the body of the message excluding headers. The message data should have normalised line endings (CRLF).

Specified by:
getBody in interface MessageResult
Returns:
Content, or or null if MessageResult.FetchGroup.FULL_CONTENT has not been included in the results

setBody

public final void setBody(MessageResult.Content messageBody)

toString

public java.lang.String toString()
Renders suitably for logging.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this object.

getBody

public MessageResult.Content getBody(MessageResult.MimePath path)
                              throws MailboxManagerException
Description copied from interface: MessageResult
Gets the body of the given mime part.

Specified by:
getBody in interface MessageResult
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

public MessageResult.Content getMimeBody(MessageResult.MimePath path)
                                  throws MailboxManagerException
Description copied from interface: MessageResult
Gets the body of the given mime part.

Specified by:
getMimeBody in interface MessageResult
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

getFullContent

public MessageResult.Content getFullContent(MessageResult.MimePath path)
                                     throws MailboxManagerException
Description copied from interface: MessageResult
Gets the full content of the given mime part.

Specified by:
getFullContent in interface MessageResult
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

iterateHeaders

public java.util.Iterator iterateHeaders(MessageResult.MimePath path)
                                  throws MailboxManagerException
Description copied from interface: MessageResult
Iterates the message headers for the given part in a multipart message.

Specified by:
iterateHeaders in interface MessageResult
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

public java.util.Iterator iterateMimeHeaders(MessageResult.MimePath path)
                                      throws MailboxManagerException
Description copied from interface: MessageResult
Iterates the MIME headers for the given part in a multipart message.

Specified by:
iterateMimeHeaders in interface MessageResult
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

setBodyContent

public void setBodyContent(MessageResult.MimePath path,
                           MessageResult.Content content)

setMimeBodyContent

public void setMimeBodyContent(MessageResult.MimePath path,
                               MessageResult.Content content)

setFullContent

public void setFullContent(MessageResult.MimePath path,
                           MessageResult.Content content)

setHeaders

public void setHeaders(MessageResult.MimePath path,
                       java.util.Iterator headers)

setMimeHeaders

public void setMimeHeaders(MessageResult.MimePath path,
                           java.util.Iterator headers)

setMimeDescriptor

public void setMimeDescriptor(MessageResult.MimeDescriptor mimeDescriptor)

getMimeDescriptor

public MessageResult.MimeDescriptor getMimeDescriptor()
Specified by:
getMimeDescriptor in interface MessageResult


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