Holger's Java API

## com.antelmann.net.mail
Class MessageEntry

    java.lang.Object
      com.antelmann.db.AbstractDBEntry
          com.antelmann.net.mail.MessageEntry

All Implemented Interfaces:
  Timed, DBEntry, Wrapped<javax.mail.Message>, Serializable

    public class MessageEntry

extends AbstractDBEntry
implements Timed, Wrapped<javax.mail.Message>

A wrapper around a Message object that allows for database storage and serialization. Note that overriding classes must implement `readObject(java.io.ObjectInputStream)` and `writeObject(java.io.ObjectOutputStream)` in order to support serialization (without using default read/write - you will have to use reflection to do the entire thing).

Since:
  06.10.2016, 17:24:47
Author:
  holger
See Also:
  `serialize()`, `unwrap()`, `Misc.setValue(Object, String, Object)`, `AbstractDBEntry.id`, Serialized Form

Field Summary

Fields inherited from interface com.antelmann.calendar.Timed
`COMPARATOR, DATE_EXTRACTOR`

Fields inherited from interface com.antelmann.db.DBEntry
`ENTRY_FLAVOR, ENTRY_LIST_FLAVOR`

Constructor Summary
`` `MessageEntry(byte[] data)`
`` `MessageEntry(InputStream in)`
`` `MessageEntry(javax.mail.Message msg)`
`` `MessageEntry(MessageEntry entry)`
`protected` `MessageEntry(Object id, InputStream in)` used by `MessageEntryMapper`; calls `check()`
`` `MessageEntry(Object id, javax.mail.Message msg)`

Method Summary
`protected void` `check()` checks whether the ID is consistent w/ the message id
`static javax.mail.Message` `createMessage(InputStream in)`
`void` `exportEML(OutputStream out)`
`static String` `extractID(javax.mail.Message msg)`
`static String` `getAddressString(javax.mail.Address[] list)`
`int` `getAttachmentCount()`
`String` `getFromString()`
`String` `getRecipientString(javax.mail.Message.RecipientType rt)` if rt is null, all recipients are used
`long` `getTime()`
`String` `hashContent()`
`void` `serialize()` writes the full message to binary form, so that it is fully available even though an underlying Folder may have been closed.
`javax.mail.Message` `unwrap()` Note that the return value may refer to a different instance after `serialize()` was called!

Methods inherited from class com.antelmann.db.AbstractDBEntry
`equals, getID, hashCode, hashEntry, sameEntry, toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### MessageEntry

    public MessageEntry(MessageEntry entry)

### MessageEntry

    public MessageEntry(javax.mail.Message msg)
                 throws IOException,
                        javax.mail.MessagingException

Throws:
  `IOException`
  `javax.mail.MessagingException`

### MessageEntry

    public MessageEntry(byte[] data)
                 throws javax.mail.MessagingException,
                        IOException

Throws:
  `javax.mail.MessagingException`
  `IOException`

### MessageEntry

    public MessageEntry(InputStream in)
                 throws javax.mail.MessagingException,
                        IOException

Throws:
  `javax.mail.MessagingException`
  `IOException`

### MessageEntry

    protected MessageEntry(Object id,
                           InputStream in)
                    throws javax.mail.MessagingException,
                           IOException

  used by `MessageEntryMapper`; calls `check()`

  Throws:
    `javax.mail.MessagingException`
    `IOException`

### MessageEntry

    public MessageEntry(Object id,
                        javax.mail.Message msg)

Method Detail

### check

    protected void check()
                  throws IllegalArgumentException,
                         javax.mail.MessagingException

  checks whether the ID is consistent w/ the message id

  Throws:
    `IllegalArgumentException`
    `javax.mail.MessagingException`

### serialize

    public void serialize()
                   throws IOException,
                          javax.mail.MessagingException

  writes the full message to binary form, so that it is fully available even though an underlying Folder may have been closed. Use this for Messages retrieved from a `Folder` before you close the same, so that the full data is maintained independently. NOTE: After this method is called, the return value of `unwrap()` REFERS TO A DIFFERENT INSTANCE now as a previous call to the same method! This is because `unwrap()` will reconstruct a new Message instance from binary data after `serialize()` was called. Also, the original Folder (that gets lost during serialization) is replaced with a `LocalSerializedFolderWrapper`, so that some useful information is maintained even after serialization.

  Throws:
    `IOException`
    `javax.mail.MessagingException`

### unwrap

    public javax.mail.Message unwrap()

  Note that the return value may refer to a different instance after `serialize()` was called!

  Specified by:
    `unwrap` in interface `Wrapped<javax.mail.Message>`
  See Also:
    `serialize()`

### getTime

    public long getTime()

  Specified by:
    `getTime` in interface `Timed`

### getRecipientString

    public String getRecipientString(javax.mail.Message.RecipientType rt)
                              throws javax.mail.MessagingException

  if rt is null, all recipients are used

  Throws:
    `javax.mail.MessagingException`

### getFromString

    public String getFromString()
                         throws javax.mail.MessagingException

  Throws:
    `javax.mail.MessagingException`

### hashContent

    public String hashContent()
                       throws IOException,
                              javax.mail.MessagingException

  Throws:
    `IOException`
    `javax.mail.MessagingException`

### getAttachmentCount

    public int getAttachmentCount()
                           throws javax.mail.MessagingException,
                                  IOException

  Throws:
    `javax.mail.MessagingException`
    `IOException`

### exportEML

    public void exportEML(OutputStream out)
                   throws IOException,
                          javax.mail.MessagingException

  Throws:
    `IOException`
    `javax.mail.MessagingException`

### getAddressString

    public static String getAddressString(javax.mail.Address[] list)

### extractID

    public static String extractID(javax.mail.Message msg)
                            throws javax.mail.MessagingException

  Throws:
    `javax.mail.MessagingException`

### createMessage

    public static javax.mail.Message createMessage(InputStream in)
                                            throws javax.mail.MessagingException

  Throws:
    `javax.mail.MessagingException`

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads