public final class MessageWriter
extends java.lang.Object
MessageWriter
- Writes MailMessage
instances as JSON stringsModifier and Type | Class and Description |
---|---|
static interface |
MessageWriter.MailFieldWriter |
Modifier and Type | Method and Description |
---|---|
static long |
addUserTimezone(long time,
java.util.TimeZone timeZone)
Adds the user time zone offset to given date time
|
static org.json.JSONArray |
getAddressesAsArray(javax.mail.internet.InternetAddress[] addrs)
Convert an array of
InternetAddress instances into a JSON-Array conforming to:
[["The Personal", "someone@somewhere.com"], ...] |
static MessageWriter.MailFieldWriter[] |
getHeaderFieldWriter(java.lang.String[] headers)
Gets writers for specified header names.
|
static MessageWriter.MailFieldWriter[] |
getMailFieldWriter(MailListField[] fields)
Generates appropriate field writers for given mail fields
|
static org.json.JSONObject |
writeMailMessage(int accountId,
MailMessage mail,
DisplayMode displayMode,
boolean embedded,
com.openexchange.session.Session session,
UserSettingMail settings)
Writes whole mail as a JSON object.
|
static org.json.JSONObject |
writeMailMessage(int accountId,
MailMessage mail,
DisplayMode displayMode,
boolean embedded,
com.openexchange.session.Session session,
UserSettingMail settings,
java.util.Collection<com.openexchange.exception.OXException> warnings,
boolean token,
int tokenTimeout)
Writes whole mail as a JSON object.
|
static org.json.JSONObject |
writeMailMessage(int accountId,
MailMessage mail,
DisplayMode displayMode,
boolean embedded,
com.openexchange.session.Session session,
UserSettingMail settings,
java.util.Collection<com.openexchange.exception.OXException> warnings,
boolean token,
int tokenTimeout,
MimeFilter mimeFilter)
Writes whole mail as a JSON object.
|
static org.json.JSONObject |
writeMailMessage(int accountId,
MailMessage mail,
DisplayMode displayMode,
boolean embedded,
com.openexchange.session.Session session,
UserSettingMail settings,
java.util.Collection<com.openexchange.exception.OXException> warnings,
boolean token,
int tokenTimeout,
MimeFilter mimeFilter,
java.util.TimeZone optTimeZone,
boolean exactLength)
Writes whole mail as a JSON object.
|
static org.json.JSONObject |
writeRawMailMessage(int accountId,
MailMessage mail)
Writes raw mail as a JSON object.
|
static org.json.JSONObject |
writeStructure(int accountId,
MailMessage mail,
long maxSize)
Writes specified mail's structure as a JSON object.
|
public static org.json.JSONObject writeStructure(int accountId, MailMessage mail, long maxSize) throws com.openexchange.exception.OXException
Optionally a prepared version can be returned, this includes following actions:
To: =?iso-8859-1?q?Keld_J=F8rn?= <keld@xyz.dk>
"personal"
and an "address"
field"type"
and a "params"
fieldaccountId
- The mail's account IDmail
- The mail to writemaxSize
- The allowed max. sizecom.openexchange.exception.OXException
- If writing structure failspublic static org.json.JSONObject writeMailMessage(int accountId, MailMessage mail, DisplayMode displayMode, boolean embedded, com.openexchange.session.Session session, UserSettingMail settings) throws com.openexchange.exception.OXException
accountId
- The account IDmail
- The mail to writedisplayMode
- The display modesession
- The sessionsettings
- The user's mail settings used for writing message; if null
the settings are going to be fetched from
storage, thus no request-specific preparations will take place.warnings
- A container for possible warningscom.openexchange.exception.OXException
- If writing message failspublic static org.json.JSONObject writeMailMessage(int accountId, MailMessage mail, DisplayMode displayMode, boolean embedded, com.openexchange.session.Session session, UserSettingMail settings, java.util.Collection<com.openexchange.exception.OXException> warnings, boolean token, int tokenTimeout) throws com.openexchange.exception.OXException
accountId
- The account IDmail
- The mail to writedisplayMode
- The display modesession
- The sessionsettings
- The user's mail settings used for writing message; if null
the settings are going to be fetched from
storage, thus no request-specific preparations will take place.warnings
- A container for possible warningstokenTimeout
- com.openexchange.exception.OXException
- If writing message failspublic static org.json.JSONObject writeMailMessage(int accountId, MailMessage mail, DisplayMode displayMode, boolean embedded, com.openexchange.session.Session session, UserSettingMail settings, java.util.Collection<com.openexchange.exception.OXException> warnings, boolean token, int tokenTimeout, MimeFilter mimeFilter) throws com.openexchange.exception.OXException
accountId
- The account IDmail
- The mail to writedisplayMode
- The display modesession
- The sessionsettings
- The user's mail settings used for writing message; if null
the settings are going to be fetched from
storage, thus no request-specific preparations will take place.warnings
- A container for possible warningstokenTimeout
- mimeFilter
- The MIME filtercom.openexchange.exception.OXException
- If writing message failspublic static org.json.JSONObject writeMailMessage(int accountId, MailMessage mail, DisplayMode displayMode, boolean embedded, com.openexchange.session.Session session, UserSettingMail settings, java.util.Collection<com.openexchange.exception.OXException> warnings, boolean token, int tokenTimeout, MimeFilter mimeFilter, java.util.TimeZone optTimeZone, boolean exactLength) throws com.openexchange.exception.OXException
accountId
- The account IDmail
- The mail to writedisplayMode
- The display modesession
- The sessionsettings
- The user's mail settings used for writing message; if null
the settings are going to be fetched from
storage, thus no request-specific preparations will take place.warnings
- A container for possible warningstokenTimeout
- mimeFilter
- The MIME filtercom.openexchange.exception.OXException
- If writing message failspublic static org.json.JSONObject writeRawMailMessage(int accountId, MailMessage mail) throws com.openexchange.exception.OXException
accountId
- The account IDmail
- The mail to writenull
if message's text body parts exceed max. sizecom.openexchange.exception.OXException
- If writing message failspublic static MessageWriter.MailFieldWriter[] getMailFieldWriter(MailListField[] fields)
fields
- The mail fields to writeMessageWriter.MailFieldWriter
public static MessageWriter.MailFieldWriter[] getHeaderFieldWriter(java.lang.String[] headers)
headers
- The header namespublic static long addUserTimezone(long time, java.util.TimeZone timeZone)
time
- The date timetimeZone
- The time zonepublic static org.json.JSONArray getAddressesAsArray(javax.mail.internet.InternetAddress[] addrs)
InternetAddress
instances into a JSON-Array conforming to:
[["The Personal", "someone@somewhere.com"], ...]