org.apache.james.mailbox.util
Class MessageResultImpl

java.lang.Object
  extended by org.apache.james.mailbox.util.MessageResultImpl
All Implemented Interfaces:
java.lang.Comparable<MessageResult>, Headers, MessageResult

public class MessageResultImpl
extends java.lang.Object
implements MessageResult

Bean based implementation.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.james.mailbox.MessageResult
MessageResult.FetchGroup, MessageResult.Header, MessageResult.MimePath
 
Constructor Summary
MessageResultImpl()
           
MessageResultImpl(long uid)
           
MessageResultImpl(long uid, javax.mail.Flags flags)
           
 
Method Summary
 int compareTo(MessageResult that)
           
 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.List<MessageResult.Header> getHeaders()
           
 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> headers()
          Gets headers for the message.
 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.
 void setBody(Content messageBody)
           
 void setBodyContent(MessageResult.MimePath path, Content content)
           
 void setFlags(javax.mail.Flags flags)
           
 void setFullContent(Content fullMessage)
           
 void setFullContent(MessageResult.MimePath path, Content content)
           
 void setHeaders(java.util.List<MessageResult.Header> headers)
           
 void setHeaders(MessageResult.MimePath path, java.util.Iterator<MessageResult.Header> headers)
           
 void setInternalDate(java.util.Date internalDate)
           
 void setMimeBodyContent(MessageResult.MimePath path, Content content)
           
 void setMimeDescriptor(MimeDescriptor mimeDescriptor)
           
 void setMimeHeaders(MessageResult.MimePath path, java.util.Iterator<MessageResult.Header> 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)
Method Detail

getUid

public long getUid()
Description copied from interface: MessageResult
Return the uid of the message which the MessageResult belongs to

Specified by:
getUid in interface MessageResult
Returns:
uid

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 long getSize()
Description copied from interface: MessageResult
Return the size in bytes

Specified by:
getSize in interface MessageResult
Returns:
size

setFlags

public void setFlags(javax.mail.Flags flags)

compareTo

public int compareTo(MessageResult that)
Specified by:
compareTo in interface java.lang.Comparable<MessageResult>

setSize

public void setSize(int size)

setInternalDate

public void setInternalDate(java.util.Date internalDate)

headers

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

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

getHeaders

public java.util.List<MessageResult.Header> getHeaders()

setHeaders

public void setHeaders(java.util.List<MessageResult.Header> headers)

getFullContent

public final 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(Content fullMessage)

getBody

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

getMimeBody

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

getFullContent

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

iterateHeaders

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

iterateMimeHeaders

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

setBodyContent

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

setMimeBodyContent

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

setFullContent

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

setHeaders

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

setMimeHeaders

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

setMimeDescriptor

public void setMimeDescriptor(MimeDescriptor mimeDescriptor)

getMimeDescriptor

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


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