com.openexchange.mail.parser.handlers
Class InlineContentHandler

java.lang.Object
  extended by com.openexchange.mail.parser.handlers.InlineContentHandler
All Implemented Interfaces:
MailMessageHandler

public final class InlineContentHandler
extends java.lang.Object
implements MailMessageHandler

InlineContentHandler - Finds matching inline parts to given content IDs

Author:
Thorben Betten

Constructor Summary
InlineContentHandler(java.util.List<java.lang.String> cids)
          Constructor
 
Method Summary
 java.util.Map<java.lang.String,MailPart> getInlineContents()
          Gets the found inline contents corresponding to given content IDs.
 boolean handleAttachment(MailPart part, boolean isInline, java.lang.String baseContentType, java.lang.String fileName, java.lang.String id)
          Handle an attachment part (any non-inline parts and file attachments)
 boolean handleBccRecipient(javax.mail.internet.InternetAddress[] recipientAddrs)
          Handle the 'Bcc' recipient message header
 boolean handleCcRecipient(javax.mail.internet.InternetAddress[] recipientAddrs)
          Handle the 'Cc' recipient message header
 boolean handleColorLabel(int colorLabel)
          Handle message's color label
 boolean handleContentId(java.lang.String contentId)
          Handle content id
 boolean handleDispositionNotification(javax.mail.internet.InternetAddress dispositionNotificationTo, boolean seen)
          Handle message's disposition notification
 boolean handleFrom(javax.mail.internet.InternetAddress[] fromAddrs)
          Handle the 'From' message header
 boolean handleHeaders(int size, java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> iter)
          Handle those message headers which cannot be handled through a handleXXX method
 boolean handleImagePart(MailPart part, java.lang.String imageCIDArg, java.lang.String baseContentType, boolean isInline, java.lang.String fileName, java.lang.String id)
          Handle an image part (image/*)
 boolean handleInlineHtml(java.lang.String htmlContent, ContentType contentType, long size, java.lang.String fileName, java.lang.String id)
          Handle a html inline part (text/html)
 boolean handleInlinePlainText(java.lang.String plainTextContent, ContentType contentType, long size, java.lang.String fileName, java.lang.String id)
          Handle a plain text inline part (either text/plain or text/enriched)
 boolean handleInlineUUEncodedAttachment(UUEncodedPart part, java.lang.String id)
          Handle a UUEncoded file attachment inline part
 boolean handleInlineUUEncodedPlainText(java.lang.String decodedTextContent, ContentType contentType, int size, java.lang.String fileName, java.lang.String id)
          Handle a UUEncoded plain text inline part
 void handleMessageEnd(MailMessage mail)
          Perform some optional finishing operations
 boolean handleMsgRef(java.lang.String msgRef)
          Handle referenced mail
 boolean handleMultipart(MailPart mp, int bodyPartCount, java.lang.String id)
          Handle a multipart (multipart/*)
 boolean handleNestedMessage(MailPart mailPart, java.lang.String id)
          Handle a nested message (message/rfc822) Get the message via: MailMessage nestedMail = (MailMessage) mailPart.getContent();
 boolean handlePriority(int priority)
          Handle message's priority
 boolean handleReceivedDate(java.util.Date receivedDate)
          Handle message's received date
 boolean handleSentDate(java.util.Date sentDate)
          Handle message's sent date
 boolean handleSpecialPart(MailPart part, java.lang.String baseContentType, java.lang.String fileName, java.lang.String id)
          Handle special parts.
 boolean handleSubject(java.lang.String subject)
          Handle message's subject
 boolean handleSystemFlags(int flags)
          Handle message's system flags (//SEEN, //ANSWERED, ...)
 boolean handleToRecipient(javax.mail.internet.InternetAddress[] recipientAddrs)
          Handle the 'To' recipient message header
 boolean handleUserFlags(java.lang.String[] userFlags)
          Handle message's user flags
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InlineContentHandler

public InlineContentHandler(java.util.List<java.lang.String> cids)
Constructor

Parameters:
cids - The content IDs of the inline parts
Method Detail

getInlineContents

public java.util.Map<java.lang.String,MailPart> getInlineContents()
Gets the found inline contents corresponding to given content IDs. Those inline content which could not be found are set to null.

Returns:
The found inline contents

handleAttachment

public boolean handleAttachment(MailPart part,
                                boolean isInline,
                                java.lang.String baseContentType,
                                java.lang.String fileName,
                                java.lang.String id)
                         throws MailException
Description copied from interface: MailMessageHandler
Handle an attachment part (any non-inline parts and file attachments)

Specified by:
handleAttachment in interface MailMessageHandler
Throws:
MailException

handleBccRecipient

public boolean handleBccRecipient(javax.mail.internet.InternetAddress[] recipientAddrs)
                           throws MailException
Description copied from interface: MailMessageHandler
Handle the 'Bcc' recipient message header

Specified by:
handleBccRecipient in interface MailMessageHandler
Throws:
MailException

handleCcRecipient

public boolean handleCcRecipient(javax.mail.internet.InternetAddress[] recipientAddrs)
                          throws MailException
Description copied from interface: MailMessageHandler
Handle the 'Cc' recipient message header

Specified by:
handleCcRecipient in interface MailMessageHandler
Throws:
MailException

handleColorLabel

public boolean handleColorLabel(int colorLabel)
                         throws MailException
Description copied from interface: MailMessageHandler
Handle message's color label

Specified by:
handleColorLabel in interface MailMessageHandler
Throws:
MailException

handleContentId

public boolean handleContentId(java.lang.String contentId)
                        throws MailException
Description copied from interface: MailMessageHandler
Handle content id

Specified by:
handleContentId in interface MailMessageHandler
Throws:
MailException

handleDispositionNotification

public boolean handleDispositionNotification(javax.mail.internet.InternetAddress dispositionNotificationTo,
                                             boolean seen)
                                      throws MailException
Description copied from interface: MailMessageHandler
Handle message's disposition notification

Specified by:
handleDispositionNotification in interface MailMessageHandler
seen - TODO
Throws:
MailException

handleFrom

public boolean handleFrom(javax.mail.internet.InternetAddress[] fromAddrs)
                   throws MailException
Description copied from interface: MailMessageHandler
Handle the 'From' message header

Specified by:
handleFrom in interface MailMessageHandler
Throws:
MailException

handleHeaders

public boolean handleHeaders(int size,
                             java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> iter)
                      throws MailException
Description copied from interface: MailMessageHandler
Handle those message headers which cannot be handled through a handleXXX method

Specified by:
handleHeaders in interface MailMessageHandler
Parameters:
size - The iterator's size or -1 to use Iterator.hasNext() instead
iter - The header iterator
Returns:
true to continue parsing; otherwise false
Throws:
MailException

handleImagePart

public boolean handleImagePart(MailPart part,
                               java.lang.String imageCIDArg,
                               java.lang.String baseContentType,
                               boolean isInline,
                               java.lang.String fileName,
                               java.lang.String id)
                        throws MailException
Description copied from interface: MailMessageHandler
Handle an image part (image/*)

Specified by:
handleImagePart in interface MailMessageHandler
Throws:
MailException

handleInlineHtml

public boolean handleInlineHtml(java.lang.String htmlContent,
                                ContentType contentType,
                                long size,
                                java.lang.String fileName,
                                java.lang.String id)
                         throws MailException
Description copied from interface: MailMessageHandler
Handle a html inline part (text/html)

Specified by:
handleInlineHtml in interface MailMessageHandler
Throws:
MailException

handleInlinePlainText

public boolean handleInlinePlainText(java.lang.String plainTextContent,
                                     ContentType contentType,
                                     long size,
                                     java.lang.String fileName,
                                     java.lang.String id)
                              throws MailException
Description copied from interface: MailMessageHandler
Handle a plain text inline part (either text/plain or text/enriched)

Specified by:
handleInlinePlainText in interface MailMessageHandler
Throws:
MailException

handleInlineUUEncodedAttachment

public boolean handleInlineUUEncodedAttachment(UUEncodedPart part,
                                               java.lang.String id)
                                        throws MailException
Description copied from interface: MailMessageHandler
Handle a UUEncoded file attachment inline part

Specified by:
handleInlineUUEncodedAttachment in interface MailMessageHandler
Throws:
MailException

handleInlineUUEncodedPlainText

public boolean handleInlineUUEncodedPlainText(java.lang.String decodedTextContent,
                                              ContentType contentType,
                                              int size,
                                              java.lang.String fileName,
                                              java.lang.String id)
                                       throws MailException
Description copied from interface: MailMessageHandler
Handle a UUEncoded plain text inline part

Specified by:
handleInlineUUEncodedPlainText in interface MailMessageHandler
Throws:
MailException

handleMessageEnd

public void handleMessageEnd(MailMessage mail)
                      throws MailException
Description copied from interface: MailMessageHandler
Perform some optional finishing operations

Specified by:
handleMessageEnd in interface MailMessageHandler
Throws:
MailException

handleMsgRef

public boolean handleMsgRef(java.lang.String msgRef)
                     throws MailException
Description copied from interface: MailMessageHandler
Handle referenced mail

Specified by:
handleMsgRef in interface MailMessageHandler
Throws:
MailException

handleMultipart

public boolean handleMultipart(MailPart mp,
                               int bodyPartCount,
                               java.lang.String id)
                        throws MailException
Description copied from interface: MailMessageHandler
Handle a multipart (multipart/*)

Specified by:
handleMultipart in interface MailMessageHandler
Throws:
MailException

handleNestedMessage

public boolean handleNestedMessage(MailPart mailPart,
                                   java.lang.String id)
                            throws MailException
Description copied from interface: MailMessageHandler
Handle a nested message (message/rfc822)

Get the message via:

 
 MailMessage nestedMail = (MailMessage) mailPart.getContent();
 

Specified by:
handleNestedMessage in interface MailMessageHandler
Throws:
MailException

handlePriority

public boolean handlePriority(int priority)
                       throws MailException
Description copied from interface: MailMessageHandler
Handle message's priority

Specified by:
handlePriority in interface MailMessageHandler
Throws:
MailException

handleReceivedDate

public boolean handleReceivedDate(java.util.Date receivedDate)
                           throws MailException
Description copied from interface: MailMessageHandler
Handle message's received date

Specified by:
handleReceivedDate in interface MailMessageHandler
Throws:
MailException

handleSentDate

public boolean handleSentDate(java.util.Date sentDate)
                       throws MailException
Description copied from interface: MailMessageHandler
Handle message's sent date

Specified by:
handleSentDate in interface MailMessageHandler
Throws:
MailException

handleSpecialPart

public boolean handleSpecialPart(MailPart part,
                                 java.lang.String baseContentType,
                                 java.lang.String fileName,
                                 java.lang.String id)
                          throws MailException
Description copied from interface: MailMessageHandler
Handle special parts. A special part is either of MIME type message/delivery-status, message/disposition-notification, text/rfc822-headers, text/x-vcard, text/vcard, text/calendar or text/x-vCalendar

Specified by:
handleSpecialPart in interface MailMessageHandler
Throws:
MailException

handleSubject

public boolean handleSubject(java.lang.String subject)
                      throws MailException
Description copied from interface: MailMessageHandler
Handle message's subject

Specified by:
handleSubject in interface MailMessageHandler
Throws:
MailException

handleSystemFlags

public boolean handleSystemFlags(int flags)
                          throws MailException
Description copied from interface: MailMessageHandler
Handle message's system flags (//SEEN, //ANSWERED, ...)

Specified by:
handleSystemFlags in interface MailMessageHandler
Throws:
MailException

handleToRecipient

public boolean handleToRecipient(javax.mail.internet.InternetAddress[] recipientAddrs)
                          throws MailException
Description copied from interface: MailMessageHandler
Handle the 'To' recipient message header

Specified by:
handleToRecipient in interface MailMessageHandler
Throws:
MailException

handleUserFlags

public boolean handleUserFlags(java.lang.String[] userFlags)
                        throws MailException
Description copied from interface: MailMessageHandler
Handle message's user flags

Specified by:
handleUserFlags in interface MailMessageHandler
Throws:
MailException