com.openexchange.mail.dataobjects
Class CompositeMailMessage

java.lang.Object
  extended by com.openexchange.mail.dataobjects.MailPart
      extended by com.openexchange.mail.dataobjects.MailMessage
          extended by com.openexchange.mail.dataobjects.CompositeMailMessage
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public final class CompositeMailMessage
extends MailMessage

CompositeMailMessage - Extends the common MailMessage class by the possibility to add extra parts to an existing MailMessage instance whose MIME type is multipart/*

Author:
Thorben Betten
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.openexchange.mail.dataobjects.MailMessage
COLOR_LABEL_NONE, COLOR_LABEL_PREFIX, COLOR_LABEL_PREFIX_OLD, FLAG_ANSWERED, FLAG_DELETED, FLAG_DRAFT, FLAG_FLAGGED, FLAG_FORWARDED, FLAG_READ_ACK, FLAG_RECENT, FLAG_SEEN, FLAG_SPAM, FLAG_USER, PRIORITY_HIGH, PRIORITY_HIGHEST, PRIORITY_LOW, PRIORITY_LOWEST, PRIORITY_NORMAL, USER_FORWARDED, USER_READ_ACK
 
Fields inherited from class com.openexchange.mail.dataobjects.MailPart
NO_ENCLOSED_PARTS
 
Constructor Summary
CompositeMailMessage(MailMessage delegate)
          Constructor
 
Method Summary
 void addAdditionalParts(MailPart mailPart)
          Appends the specified mail part
 boolean containsRecentCount()
           
 java.lang.Object getContent()
          Returns the part's content as a Java object dependent on underlying implementation.
 javax.activation.DataHandler getDataHandler()
          Returns an appropriate DataHandler for this mail part.
 int getEnclosedCount()
          Gets the number of enclosed mail parts.
 MailPart getEnclosedMailPart(int index)
          Gets the mail part located at given index.
 java.io.InputStream getInputStream()
          Returns an input stream for this part.
 java.lang.String getMailId()
          Gets the implementation-specific unique ID of this mail in its mail folder.
 java.util.Date getReceivedDateDirect()
          Gets the received date directly which represents the internal timestamp set by mail server on arrival.
 int getRecentCount()
          Gets the number of recent mails in associated folder.
 int getUnreadMessages()
          Gets the number of unread messages
 boolean hasHeaders(java.lang.String... names)
          Checks if this part contains all of specified headers.
 void loadContent()
          Ensures that the part's content is loaded, thus this part is independent of the original.
 void prepareForCaching()
          Prepares this mail part to be put into cache; meaning to release all kept resources
 MailPart removeAdditionalParts(int index)
          Removes the mail part at the specified position.
 void removeRecentCount()
          Removes the recent count.
 void setMailId(java.lang.String id)
          Sets the implementation-specific unique mail ID of this mail in its mail folder.
 void setRecentCount(int recentCount)
          Sets the number of recent mails in associated folder.
 void setUnreadMessages(int unreadMessages)
          Sets the number of unread messages
 void writeTo(java.io.OutputStream out)
          Writes complete part's data into given output stream
 
Methods inherited from class com.openexchange.mail.dataobjects.MailMessage
addBcc, addBcc, addCc, addCc, addFrom, addFrom, addTo, addTo, addUserFlag, addUserFlags, clone, containsAccountId, containsAccountName, containsAppendVCard, containsBcc, containsCc, containsColorLabel, containsDispositionNotification, containsFlags, containsFolder, containsFrom, containsHasAttachment, containsPrevSeen, containsPriority, containsReceivedDate, containsSentDate, containsSubject, containsThreadLevel, containsTo, containsUserFlags, getAccountId, getAccountName, getBcc, getCc, getColorLabel, getColorLabelIntValue, getColorLabelStringValue, getDispositionNotification, getFlags, getFolder, getFrom, getMailPath, getPriority, getReceivedDate, getSentDate, getSubject, getThreadLevel, getTo, getUserFlags, hasAttachment, isAnswered, isAppendVCard, isColorLabel, isDeleted, isDraft, isFlagged, isForwarded, isPrevSeen, isReadAcknowledgment, isRecent, isSeen, isSpam, isUser, parseColorLabel, removeAccountId, removeAccountName, removeAppendVCard, removeBcc, removeCc, removeColorLabel, removeDispositionNotification, removeFlags, removeFolder, removeFrom, removeHasAttachment, removePrevSeen, removePriority, removeReceivedDate, removeSentDate, removeSubject, removeThreadLevel, removeTo, removeUserFlags, setAccountId, setAccountName, setAppendVCard, setColorLabel, setDispositionNotification, setFlag, setFlags, setFolder, setHasAttachment, setPrevSeen, setPriority, setReceivedDate, setSentDate, setSubject, setThreadLevel
 
Methods inherited from class com.openexchange.mail.dataobjects.MailPart
addHeader, addHeaders, containsContentDisposition, containsContentId, containsContentType, containsFileName, containsHeader, containsHeaders, containsMsgref, containsSequenceId, containsSize, getContentDisposition, getContentId, getContentType, getFileName, getFirstHeader, getHeader, getHeader, getHeader, getHeaders, getHeadersIterator, getHeadersSize, getMatchingHeaders, getMsgref, getNonMatchingHeaders, getSequenceId, getSize, getSource, getSourceBytes, hasEnclosedParts, removeContentDisposition, removeContentId, removeContentType, removeFileName, removeHeader, removeHeaders, removeMsgref, removeSequenceId, removeSize, setContentDisposition, setContentDisposition, setContentId, setContentType, setContentType, setFileName, setMsgref, setSequenceId, setSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeMailMessage

public CompositeMailMessage(MailMessage delegate)
                     throws MailException
Constructor

Parameters:
delegate - The delegate mail
Throws:
MailException - If invocation of MailPart.getEnclosedCount() fails
Method Detail

addAdditionalParts

public void addAdditionalParts(MailPart mailPart)
Appends the specified mail part

Parameters:
mailPart - The mail part to add

removeAdditionalParts

public MailPart removeAdditionalParts(int index)
Removes the mail part at the specified position. Shifts any subsequent mail parts to the left (subtracts one from their indices). Returns the mail part that was removed.

Parameters:
index - The index
Returns:
The mail part that was removed.

getContent

public java.lang.Object getContent()
                            throws MailException
Description copied from class: MailPart
Returns the part's content as a Java object dependent on underlying implementation.
This method is not applicable if part's MIME type is multipart/*

Specified by:
getContent in class MailPart
Returns:
The content as a Java object or null if not applicable
Throws:
MailException - If content cannot be returned as a Java object

getDataHandler

public javax.activation.DataHandler getDataHandler()
                                            throws MailException
Description copied from class: MailPart
Returns an appropriate DataHandler for this mail part.
This method is not applicable if part's MIME type is multipart/*

Specified by:
getDataHandler in class MailPart
Returns:
an appropriate DataHandler or null if not applicable
Throws:
MailException - If an appropriate DataHandler cannot be returned

getEnclosedCount

public int getEnclosedCount()
                     throws MailException
Description copied from class: MailPart
Gets the number of enclosed mail parts.
This method is only applicable if part's MIME type is multipart/*

Specified by:
getEnclosedCount in class MailPart
Returns:
The number of enclosed mail parts or MailPart.NO_ENCLOSED_PARTS if not applicable
Throws:
MailException
See Also:
MailPart.NO_ENCLOSED_PARTS

getEnclosedMailPart

public MailPart getEnclosedMailPart(int index)
                             throws MailException
Description copied from class: MailPart
Gets the mail part located at given index.
This method is only applicable if part's MIME type is multipart/*

Specified by:
getEnclosedMailPart in class MailPart
Parameters:
index - The index of desired mail part or null if not applicable
Returns:
The mail part
Throws:
MailException

getInputStream

public java.io.InputStream getInputStream()
                                   throws MailException
Description copied from class: MailPart
Returns an input stream for this part.
This method is not applicable if part's MIME type is multipart/*

Specified by:
getInputStream in class MailPart
Returns:
An input stream for this part or null if not applicable
Throws:
MailException - If no input stream could be returned

loadContent

public void loadContent()
                 throws MailException
Description copied from class: MailPart
Ensures that the part's content is loaded, thus this part is independent of the original.

This method is intended for mailing systems that read the contents stepwise on demand. If dealing with such a mail part with its underlying connection closed, the part's content is no more accessible. Otherwise this method may be implemented with an empty body.

Moreover the loaded content is no more discarded when MailPart.prepareForCaching() is invoked.

Specified by:
loadContent in class MailPart
Throws:
MailException - If loading part's content fails

prepareForCaching

public void prepareForCaching()
Description copied from class: MailPart
Prepares this mail part to be put into cache; meaning to release all kept resources

Specified by:
prepareForCaching in class MailPart

getMailId

public java.lang.String getMailId()
Description copied from class: MailMessage
Gets the implementation-specific unique ID of this mail in its mail folder. The ID returned by this method is used in storages to refer to a mail.

Note If ID is numeric, max. 52 bits may be used in returned value which implies a max. allowed value of 4503599627370495.

Specified by:
getMailId in class MailMessage
Returns:
The ID of this mail or null if not available.

setMailId

public void setMailId(java.lang.String id)
Description copied from class: MailMessage
Sets the implementation-specific unique mail ID of this mail in its mail folder. The ID returned by this method is used in storages to refer to a mail.

Note If ID is numeric, max. 52 bits may be used in specified value which implies a max. allowed value of 4503599627370495.

Specified by:
setMailId in class MailMessage
Parameters:
id - The mail ID or null to indicate its absence

getUnreadMessages

public int getUnreadMessages()
Description copied from class: MailMessage
Gets the number of unread messages

Specified by:
getUnreadMessages in class MailMessage
Returns:
The number of unread messages

setUnreadMessages

public void setUnreadMessages(int unreadMessages)
Description copied from class: MailMessage
Sets the number of unread messages

Specified by:
setUnreadMessages in class MailMessage
Parameters:
unreadMessages - The number of unread messages

hasHeaders

public boolean hasHeaders(java.lang.String... names)
Description copied from class: MailPart
Checks if this part contains all of specified headers.

Overrides:
hasHeaders in class MailPart
Parameters:
names - The names of the headers to check
Returns:
true if this part contains all of specified headers; otherwise false

getReceivedDateDirect

public java.util.Date getReceivedDateDirect()
Description copied from class: MailMessage
Gets the received date directly which represents the internal timestamp set by mail server on arrival.

Overrides:
getReceivedDateDirect in class MailMessage
Returns:
The received date

getRecentCount

public int getRecentCount()
Description copied from class: MailMessage
Gets the number of recent mails in associated folder.

Overrides:
getRecentCount in class MailMessage
Returns:
The recent count

containsRecentCount

public boolean containsRecentCount()
Overrides:
containsRecentCount in class MailMessage
Returns:
true if number of recent mails is set; otherwise false

removeRecentCount

public void removeRecentCount()
Description copied from class: MailMessage
Removes the recent count.

Overrides:
removeRecentCount in class MailMessage

setRecentCount

public void setRecentCount(int recentCount)
Description copied from class: MailMessage
Sets the number of recent mails in associated folder.

Overrides:
setRecentCount in class MailMessage
Parameters:
recentCount - The recent count

writeTo

public void writeTo(java.io.OutputStream out)
             throws MailException
Description copied from class: MailPart
Writes complete part's data into given output stream

Overrides:
writeTo in class MailPart
Parameters:
out - The output stream to write to
Throws:
MailException - If writing to output stream fails