Class MailEventImpl

  • All Implemented Interfaces:
    Event, MailEvent

    public class MailEventImpl
    extends AbstractEvent
    implements MailEvent
    An event for mails, that is, an event is produced and sent as soon as a mail is stored to a specific folder.
    This event source terminates as soon as an event has been handled. However, since it polls, one has to ensure that a handled message is deleted or moved to another folder. Otherwise the source will create another event for the message.
    • Field Detail

      • message

        protected final javax.mail.Message message
        The message for which the event has been created.
      • recipients

        protected final String[] recipients
        All the recipients of the message.
      • senders

        protected final String[] senders
        The senders of the message.
      • subject

        protected final String subject
        The subject of the message.
      • receivedDate

        protected final Date receivedDate
        The date the message has been received (if it has been received and not been sent or stored as draft).
      • sentDate

        protected final Date sentDate
        The date the message has been sent (if it has been sent and not been received or stored as draft).
      • content

        protected final String content
        The string content of the message if the content is a string. Otherwise this will be null.
    • Constructor Detail

      • MailEventImpl

        public MailEventImpl​(URI[] managerURI,
                             String eventType,
                             String sourceType,
                             String sourceID,
                             javax.mail.Message message,
                             Logger logger)
                      throws javax.mail.MessagingException,
                             IOException
        Creates a new event for the designated message.
        Parameters:
        managerURI - The URIs of the service (event manager) creating the event.
        eventType - The type of the event.
        sourceType - The type of the source of this event.
        sourceID - The ID of the source of this event.
        message - The message of the event.
        logger - The logger in case an encoding of an addresses is not supported.
        Throws:
        javax.mail.MessagingException - If retrieving the required data from the message fails, a MessagingException will be thrown.
        IOException - Retrieving the (complex) content of the message may thrown an IOException.
    • Method Detail

      • getAllRecipients

        public String[] getAllRecipients()
        Gets the recipients (mail addresses) of the mail that caused this event. In case there are no recipients (yet), an emtpy array will be returned.
        Specified by:
        getAllRecipients in interface MailEvent
        Returns:
        The recipients (mail addresses) of the mail that caused this event.
      • getSenders

        public String[] getSenders()
        Description copied from interface: MailEvent
        Gets the senders (mail addresses) of the mail that caused this event. In case there are no senders (yet), an emtpy array will be returned.
        Specified by:
        getSenders in interface MailEvent
        Returns:
        The senders (mail addresses) of the mail that caused this event.
      • getSubject

        public String getSubject()
        Description copied from interface: MailEvent
        Gets the subject of the mail that caused this event. In case there is no subject (yet), null will be returned.
        Specified by:
        getSubject in interface MailEvent
        Returns:
        The subject of the mail that caused this event.
      • getReceivedDate

        public Date getReceivedDate()
        Description copied from interface: MailEvent
        Gets the date the mail that caused this event has been received. In case this mail has not been received (for instance it is a draft), null will be returned.
        Specified by:
        getReceivedDate in interface MailEvent
        Returns:
        The date the mail that caused this event has been received.
      • getSentDate

        public Date getSentDate()
        Description copied from interface: MailEvent
        Gets the date the mail that caused this event has been sent. In case this mail has not been sent (for instance it is a draft), null will be returned.
        Specified by:
        getSentDate in interface MailEvent
        Returns:
        The date the mail that caused this event has been sent.
      • getStringContent

        public String getStringContent()
        Description copied from interface: MailEvent
        Gets the string content of the mail that caused this event. In case there is no string content (yet), null will be returned.
        Specified by:
        getStringContent in interface MailEvent
        Returns:
        The string content of the mail that caused this event.
      • getMessage

        public javax.mail.Message getMessage()
        Description copied from interface: MailEvent
        Gets the message (mail) that caused this event.
        Important: Only change this message if you consume this event!
        Specified by:
        getMessage in interface MailEvent
        Returns:
        The message (mail) that caused this event.