com.openexchange.messaging
Class SimpleMessagingMessage

java.lang.Object
  extended by com.openexchange.messaging.SimpleMessagingMessage
All Implemented Interfaces:
MessagingBodyPart, MessagingContent, MessagingMessage, MessagingPart, java.io.Serializable

public class SimpleMessagingMessage
extends java.lang.Object
implements MessagingMessage, MessagingBodyPart

SimpleMessagingMessage

Author:
Francisco Laguna
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.openexchange.messaging.MessagingMessage
FLAG_ANSWERED, FLAG_DELETED, FLAG_DRAFT, FLAG_FLAGGED, FLAG_FORWARDED, FLAG_READ_ACK, FLAG_RECENT, FLAG_SEEN, FLAG_SPAM, FLAG_USER, USER_FORWARDED, USER_READ_ACK
 
Fields inherited from interface com.openexchange.messaging.MessagingPart
ATTACHMENT, INLINE
 
Fields inherited from interface com.openexchange.messaging.MessagingPart
ATTACHMENT, INLINE
 
Constructor Summary
SimpleMessagingMessage()
           
 
Method Summary
 int getColorLabel()
          Gets the color label.
 MessagingContent getContent()
          Gets the content.
 ContentType getContentType()
          Gets the Content-Type header of this part's content.
 java.lang.String getDisposition()
          Gets the disposition.
 java.lang.String getFileName()
          Get the filename associated with this part, if possible.
 MessagingHeader getFirstHeader(java.lang.String name)
          Gets the first header value associated with specified name or null if not present
 int getFlags()
          Gets the flag bitmask.
 java.lang.String getFolder()
          Gets the folder fullname.
 java.util.Collection<MessagingHeader> getHeader(java.lang.String name)
          Gets the header associated with specified name or null if not present
 java.util.Map<java.lang.String,java.util.Collection<MessagingHeader>> getHeaders()
          Gets the headers as an unmodifiable Map.
 java.lang.String getId()
          Gets the identifier.
 MultipartContent getParent()
          Gets the multipart parent.
 java.lang.String getPicture()
          Gets the URL to use as a picture for this message.
 long getReceivedDate()
          Gets the received date (storage's internal time stamp).
 java.lang.String getSectionId()
          Gets the section identifier.
 long getSize()
          Get the size of this part in bytes.
 int getThreadLevel()
          Get the thread level of this message.
 java.lang.String getUrl()
          Gets the URL associated with this message, if possible.
 java.util.Collection<java.lang.String> getUserFlags()
          Gets the user flags.
 void putHeader(MessagingHeader header)
           
 void setColorLabel(int colorLabel)
           
 void setContent(byte[] bytes)
           
 void setContent(MessagingBodyPart... parts)
           
 void setContent(java.lang.String content)
           
 void setContentReference(java.lang.String string)
           
 void setContentType(ContentType contentType)
           
 void setDisposition(java.lang.String disposition)
           
 void setFileName(java.lang.String fileName)
           
 void setFlags(int flags)
           
 void setFolder(java.lang.String folder)
           
 void setHeaders(java.util.Map<java.lang.String,java.util.Collection<MessagingHeader>> headers)
           
 void setId(java.lang.String id)
           
 void setParent(MultipartContent parent)
           
 void setPicture(java.lang.String picture)
           
 void setReceivedDate(long receivedDate)
           
 void setSectionId(java.lang.String sectionId)
           
 void setSize(long size)
           
 void setThreadLevel(int threadLevel)
           
 void setUrl(java.lang.String url)
           
 void setUserFlags(java.util.Collection<java.lang.String> userFlags)
           
 void writeTo(java.io.OutputStream os)
          Writes this part's bytes to given output stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleMessagingMessage

public SimpleMessagingMessage()
Method Detail

getColorLabel

public int getColorLabel()
Description copied from interface: MessagingMessage
Gets the color label.

Specified by:
getColorLabel in interface MessagingMessage
Returns:
The color label

getFlags

public int getFlags()
Description copied from interface: MessagingMessage
Gets the flag bitmask.

Specified by:
getFlags in interface MessagingMessage
Returns:
The flag bitmask

getFolder

public java.lang.String getFolder()
Description copied from interface: MessagingMessage
Gets the folder fullname.

Specified by:
getFolder in interface MessagingMessage
Returns:
The folder fullname or null if not available

getReceivedDate

public long getReceivedDate()
Description copied from interface: MessagingMessage
Gets the received date (storage's internal time stamp).

Specified by:
getReceivedDate in interface MessagingMessage
Returns:
The received date or -1 if not available

getUserFlags

public java.util.Collection<java.lang.String> getUserFlags()
Description copied from interface: MessagingMessage
Gets the user flags.

Specified by:
getUserFlags in interface MessagingMessage
Returns:
The user flags or null if none available

getContent

public MessagingContent getContent()
                            throws MessagingException
Description copied from interface: MessagingPart
Gets the content.

Specified by:
getContent in interface MessagingPart
Returns:
The content
Throws:
MessagingException - If content cannot be returned

getDisposition

public java.lang.String getDisposition()
                                throws MessagingException
Description copied from interface: MessagingPart
Gets the disposition.

The disposition describes how the part should be presented (see RFC 2183). The return value should be compared case-insensitive. For example:

 String disposition = part.getDisposition();
 if (disposition == null || MessagingPart.ATTACHMENT.equalsIgnoreCase(disposition))
  // treat as attachment if not first part
 

Specified by:
getDisposition in interface MessagingPart
Returns:
The disposition of this part, or null if unknown
Throws:
MessagingException - If disposition cannot be returned
See Also:
MessagingPart.ATTACHMENT, MessagingPart.INLINE

getFileName

public java.lang.String getFileName()
                             throws MessagingException
Description copied from interface: MessagingPart
Get the filename associated with this part, if possible.

Useful if this part represents an "attachment" that was loaded from a file. The filename will usually be a simple name, not including directory components.

Specified by:
getFileName in interface MessagingPart
Returns:
The filename to associate with this part
Throws:
MessagingException - If filename cannot be returned

getFirstHeader

public MessagingHeader getFirstHeader(java.lang.String name)
                               throws MessagingException
Description copied from interface: MessagingPart
Gets the first header value associated with specified name or null if not present

Specified by:
getFirstHeader in interface MessagingPart
Parameters:
name - The header name
Returns:
The first header value associated with specified name or null if not present
Throws:
MessagingException - If header cannot be returned

getHeader

public java.util.Collection<MessagingHeader> getHeader(java.lang.String name)
Description copied from interface: MessagingPart
Gets the header associated with specified name or null if not present

Specified by:
getHeader in interface MessagingPart
Parameters:
name - The header name
Returns:
The header associated with specified name or null if not present

getHeaders

public java.util.Map<java.lang.String,java.util.Collection<MessagingHeader>> getHeaders()
Description copied from interface: MessagingPart
Gets the headers as an unmodifiable Map.

Specified by:
getHeaders in interface MessagingPart
Returns:
The headers as an unmodifiable Map.

getSectionId

public java.lang.String getSectionId()
Description copied from interface: MessagingPart
Gets the section identifier.

Specified by:
getSectionId in interface MessagingPart
Returns:
The section identifier or null if top level

getSize

public long getSize()
Description copied from interface: MessagingPart
Get the size of this part in bytes. Return -1 if the size cannot be determined.

Specified by:
getSize in interface MessagingPart
Returns:
The size of this part or -1

getThreadLevel

public int getThreadLevel()
Description copied from interface: MessagingMessage
Get the thread level of this message.

Specified by:
getThreadLevel in interface MessagingMessage
Returns:
The thread level of this message

writeTo

public void writeTo(java.io.OutputStream os)
             throws java.io.IOException,
                    MessagingException
Description copied from interface: MessagingPart
Writes this part's bytes to given output stream. The bytes are typically an aggregation of the headers and appropriately encoded content bytes.

The bytes are typically used for transport.

Specified by:
writeTo in interface MessagingPart
Throws:
java.io.IOException - If an I/O error occurs
MessagingException - If an error occurs fetching the data to be written

setColorLabel

public void setColorLabel(int colorLabel)

setFlags

public void setFlags(int flags)

setFolder

public void setFolder(java.lang.String folder)

setReceivedDate

public void setReceivedDate(long receivedDate)

setUserFlags

public void setUserFlags(java.util.Collection<java.lang.String> userFlags)

setDisposition

public void setDisposition(java.lang.String disposition)

setFileName

public void setFileName(java.lang.String fileName)

setHeaders

public void setHeaders(java.util.Map<java.lang.String,java.util.Collection<MessagingHeader>> headers)

putHeader

public void putHeader(MessagingHeader header)

setSectionId

public void setSectionId(java.lang.String sectionId)

setContent

public void setContent(java.lang.String content)

setSize

public void setSize(long size)

setThreadLevel

public void setThreadLevel(int threadLevel)

setContent

public void setContent(byte[] bytes)

setContent

public void setContent(MessagingBodyPart... parts)

getParent

public MultipartContent getParent()
                           throws MessagingException
Description copied from interface: MessagingBodyPart
Gets the multipart parent.

Specified by:
getParent in interface MessagingBodyPart
Returns:
The multipart parent
Throws:
MessagingException - If multipart parent cannot be returned

setParent

public void setParent(MultipartContent parent)

getContentType

public ContentType getContentType()
                           throws MessagingException
Description copied from interface: MessagingPart
Gets the Content-Type header of this part's content. null is returned if the Content-Type header could not be determined.

Specified by:
getContentType in interface MessagingPart
Returns:
The Content-Type header of this part
Throws:
MessagingException - If content type cannot be returned

setContentType

public void setContentType(ContentType contentType)

getId

public java.lang.String getId()
Description copied from interface: MessagingMessage
Gets the identifier.

Specified by:
getId in interface MessagingMessage
Returns:
The identifier or null if not available

setId

public void setId(java.lang.String id)

getPicture

public java.lang.String getPicture()
Description copied from interface: MessagingMessage
Gets the URL to use as a picture for this message. Typically represents the source or author.

Specified by:
getPicture in interface MessagingMessage

setPicture

public void setPicture(java.lang.String picture)

setUrl

public void setUrl(java.lang.String url)

getUrl

public java.lang.String getUrl()
                        throws MessagingException
Description copied from interface: MessagingMessage
Gets the URL associated with this message, if possible.

This is useful for RSS messages as they contain links to their origin messages or feeds.

Specified by:
getUrl in interface MessagingMessage
Returns:
Gets the URL associated with this message.
Throws:
MessagingException - If no URL can be returned.

setContentReference

public void setContentReference(java.lang.String string)