|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.openexchange.mail.mime.converters.MIMEMessageConverter
public final class MIMEMessageConverter
MIMEMessageConverter - Provides several methods to convert instances of MimeMessage to MailMessage in vice versa.
| Method Summary | |
|---|---|
static void |
checkFieldExistence(MailMessage[] mails,
MailField[] fields)
Checks field existence. |
static javax.mail.Message |
convertComposedMailMessage(ComposedMailMessage composedMail)
Converts given instance of ComposedMailMessage into a JavaMail-conform Message object. |
static javax.mail.Flags |
convertMailFlags(int flags)
Converts specified flags bit mask to an instance of Flags. |
static javax.mail.Message |
convertMailMessage(MailMessage mail)
Converts given instance of MailMessage into a JavaMail-conform Message object. |
static javax.mail.Message |
convertMailMessage(MailMessage mail,
boolean clone)
Converts given instance of MailMessage into a JavaMail-conform Message object. |
static javax.mail.Message[] |
convertMailMessages(MailMessage[] mails)
Converts given instances of MailMessage into JavaMail-conform Message objects. |
static javax.mail.Message[] |
convertMailMessages(MailMessage[] mails,
boolean clone)
Converts given instances of MailMessage into JavaMail-conform Message objects. |
static javax.mail.Part |
convertMailPart(MailPart mailPart)
Creates a Part object from given instance of MailPart. |
static MailMessage |
convertMessage(byte[] asciiBytes)
Creates a message data object from given message bytes conform to RFC822. |
static MailMessage |
convertMessage(byte[] asciiBytes,
java.lang.String uid,
java.lang.String fullname,
char separator,
MailField[] fields)
Creates a message data object from given message/rfc822 content filled with desired fields. |
static MailMessage |
convertMessage(javax.mail.internet.MimeMessage msg)
Creates a message data object from given MIME message. |
static MailMessage |
convertMessage(javax.mail.internet.MimeMessage msg,
java.lang.String uid,
java.lang.String fullname,
char separator,
MailField[] fields)
Creates a message data object from given MIME message filled with desired fields. |
static MailMessage[] |
convertMessages(javax.mail.Message[] msgs,
javax.mail.Folder folder,
MailField[] fields,
boolean includeBody)
Converts given array of Message instances to an array of MailMessage instances. |
static MailMessage[] |
convertMessages(javax.mail.Message[] msgs,
MailField[] fields)
Converts given array of Message instances to an array of MailMessage instances. |
static MailMessage[] |
convertMessages(javax.mail.Message[] msgs,
MailField[] fields,
java.lang.String[] headerNames,
boolean includeBody)
Converts given array of Message instances to an array of MailMessage instances. |
static MailPart |
convertPart(byte[] asciiBytes)
Creates a MIME mail part object from given raw bytes. |
static MailPart |
convertPart(javax.mail.Part part)
Creates a MIME mail part object from given MIME part. |
static MailPart |
convertPart(javax.mail.Part part,
boolean enforeSize)
Creates a MIME mail part object from given MIME part. |
static MailMessage |
fillComposedMailMessage(ComposedMailMessage composedMail)
Fills specified instance of ComposedMailMessage with MIMEMessageFiller. |
static javax.mail.internet.InternetAddress[] |
getAddressHeader(java.lang.String addresses)
Gets the address header from given address header value. |
static javax.mail.internet.InternetAddress[] |
getAddressHeader(java.lang.String name,
javax.mail.Message message)
Gets the address headers denoted by specified header name in a safe manner. |
static java.lang.String |
getStringHeader(java.lang.String name,
javax.mail.Message message)
Gets the first header denoted by specified header name and decodes its value to a unicode string if necessary. |
static java.lang.String |
getStringHeader(java.lang.String name,
javax.mail.Message message,
char delimiter)
Gets the headers denoted by specified header name and decodes its value to a unicode string if necessary. |
static java.lang.String |
getSubject(javax.mail.Message message)
Gets the first header denoted by specified header name and decodes its value to a unicode string if necessary. |
static HeaderCollection |
loadHeaders(byte[] bytes)
Parses given headers' byte array into a collection until EOF or 2 subsequent CRLFs occur. |
static HeaderCollection |
loadHeaders(java.io.InputStream inputStream)
Parses given headers' input stream into a collection until EOF or 2 subsequent CRLFs
occur. |
static HeaderCollection |
loadHeaders(java.lang.String messageSrc)
Parses given message source's headers into a collection until EOF or 2 subsequent CRLFs occur. |
static MailMessage |
newMailMessage()
Returns a new instance of MailMessage ready to get filled with header and/or flag information, but not capable to reference
to body content. |
static void |
parseFlags(javax.mail.Flags flags,
MailMessage mailMessage)
Parses specified flags to given mail. |
static int |
parseImportance(java.lang.String importance)
Parses the value of header Importance. |
static void |
parseImportance(java.lang.String importance,
MailMessage mailMessage)
Parses the value of header Importance. |
static void |
parseMimeFlags(int flags,
javax.mail.Message msg)
Parses specified flags to given message. |
static int |
parsePriority(java.lang.String priorityStr)
Parses the value of header X-Priority. |
static void |
parsePriority(java.lang.String priorityStr,
MailMessage mailMessage)
Parses the value of header X-Priority. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static javax.mail.Part convertMailPart(MailPart mailPart)
throws MailException
Part object from given instance of MailPart.
mailPart - The instance of MailPart
Part
MailException
public static javax.mail.Message[] convertMailMessages(MailMessage[] mails)
throws MailException
MailMessage into JavaMail-conform Message objects.
Note: This is just a convenience method that invokes convertMailMessage(MailMessage) for each instance of
MailMessage
mails - The source instances of MailMessage
Message objects.
MailException - If conversion fails
public static javax.mail.Message[] convertMailMessages(MailMessage[] mails,
boolean clone)
throws MailException
MailMessage into JavaMail-conform Message objects.
Note: This is just a convenience method that invokes convertMailMessage(MailMessage) for each instance of
MailMessage
mails - The source instances of MailMessageclone - true to clone message source; otherwise false to return a reference if possible
Message objects.
MailException - If conversion fails
public static javax.mail.Message convertMailMessage(MailMessage mail)
throws MailException
MailMessage into a JavaMail-conform Message object.
mail - The source instance of MailMessage
Message object
MailException - If conversion fails
public static javax.mail.Message convertMailMessage(MailMessage mail,
boolean clone)
throws MailException
MailMessage into a JavaMail-conform Message object.
mail - The source instance of MailMessageclone - true to clone message source; otherwise false to return a reference if possible
Message object
MailException - If conversion fails
public static javax.mail.Message convertComposedMailMessage(ComposedMailMessage composedMail)
throws MailException
ComposedMailMessage into a JavaMail-conform Message object.
composedMail - The source instance of ComposedMailMessage
Message object
MailException - If conversion fails
public static MailMessage fillComposedMailMessage(ComposedMailMessage composedMail)
throws MailException
ComposedMailMessage with MIMEMessageFiller.
composedMail - The composed mail
MailMessage ready for further usage
MailException - If mail cannot be filled.
public static void parseMimeFlags(int flags,
javax.mail.Message msg)
throws javax.mail.MessagingException
flags - The flags to parsemsg - The message to fill
javax.mail.MessagingException - If a messaging error occurs
public static MailMessage[] convertMessages(javax.mail.Message[] msgs,
MailField[] fields)
throws MailException
Message instances to an array of MailMessage instances. The single elements of the array are
expected to be instances of ExtendedMimeMessage; meaning the messages were created through a manual fetch.
Only the fields specified through parameter fields are going to be set
msgs - The source messagesfields - The fields to fill
Message instances
MailException - If conversion failsto convert common instances of {@link Message}
public static MailMessage[] convertMessages(javax.mail.Message[] msgs,
MailField[] fields,
java.lang.String[] headerNames,
boolean includeBody)
throws MailException
Message instances to an array of MailMessage instances. The single elements of the array are
expected to be instances of ExtendedMimeMessage; meaning the messages were created through a manual fetch.
Only the fields specified through parameter fields are going to be set
msgs - The source messagesfields - The fields to fillheaderNames - The header namesincludeBody - Whether to create mail messages with reference to content or not
Message instances
MailException - If conversion fails#convertMessages(Message[], Folder, MailField[])
public static MailMessage[] convertMessages(javax.mail.Message[] msgs,
javax.mail.Folder folder,
MailField[] fields,
boolean includeBody)
throws MailException
Message instances to an array of MailMessage instances.
Only the fields specified through parameter fields are going to be set
msgs - The source messagesfolder - The folder containing source messagesfields - The fields to fillincludeBody - true to include body; otherwise false
Message instances
MailException - If conversion fails
public static void checkFieldExistence(MailMessage[] mails,
MailField[] fields)
mails - The mails to checksfields - The field to check forpublic static MailMessage newMailMessage()
MailMessage ready to get filled with header and/or flag information, but not capable to reference
to body content.
MailMessage
public static MailMessage convertMessage(byte[] asciiBytes)
throws MailException
asciiBytes - The message bytes conform to RFC822
MailMessage
MailException - If conversion fails
public static MailMessage convertMessage(javax.mail.internet.MimeMessage msg)
throws MailException
msg - The MIME message
MailMessage containing the attributes from given MIME message
MailException - If conversion fails
public static MailMessage convertMessage(byte[] asciiBytes,
java.lang.String uid,
java.lang.String fullname,
char separator,
MailField[] fields)
throws MailException
message/rfc822 content filled with desired fields.
asciiBytes - The message/rfc822 contentuid - The UID or -1fullname - The folder's fullnameseparator - The folder's separatorfields - The desired fields to fill
MailMessage filled with desired fields
MailException - If conversion fails
public static MailMessage convertMessage(javax.mail.internet.MimeMessage msg,
java.lang.String uid,
java.lang.String fullname,
char separator,
MailField[] fields)
throws MailException
msg - The MIME messageuid - The UID or nullfullname - The folder fullnameseparator - The folder separator characterfields - The desired fields to fill
MailMessage filled with desired fields
MailException - If conversion fails
public static MailPart convertPart(byte[] asciiBytes)
throws MailException
asciiBytes - The raw bytes
MailException - If creating MIME mail part object fails
public static MailPart convertPart(javax.mail.Part part)
throws MailException
part - The part
MailPart containing the attributes from given part
MailException
public static MailPart convertPart(javax.mail.Part part,
boolean enforeSize)
throws MailException
part - The partenforeSize - true to ensure size is set in returned mail part; otherwise false. If set given part's
input stream is examined which might unnecessarily load data from backend.
MailPart containing the attributes from given part
MailExceptionpublic static javax.mail.Flags convertMailFlags(int flags)
Flags.
flags - The flags bit mask
Flags
public static void parseFlags(javax.mail.Flags flags,
MailMessage mailMessage)
throws MailException
flags to given mail.
flags - The flags to parsemailMessage - The mail to apply the flags to
MailException - If a mail error occurs
public static HeaderCollection loadHeaders(java.io.InputStream inputStream)
throws java.io.IOException
input stream into a collection until EOF or 2 subsequent CRLFs
occur.
This is a convenience method that delegates to loadHeaders(byte[]).
inputStream - The headers' input stream
collection.
java.io.IOException - If an I/O error occurs.public static HeaderCollection loadHeaders(byte[] bytes)
byte array into a collection until EOF or 2 subsequent CRLFs occur.
This is a convenience method that delegates to loadHeaders(String).
bytes - The headers' byte array
collection.public static HeaderCollection loadHeaders(java.lang.String messageSrc)
collection until EOF or 2 subsequent CRLFs occur.
messageSrc - The message source
collection.
public static java.lang.String getSubject(javax.mail.Message message)
throws javax.mail.MessagingException
"=?UTF-8?Q?=C3=BCber?=" is decoded to "über"
name - The header namemessage - The message providing the header
javax.mail.MessagingException - If a messaging error occurs
public static java.lang.String getStringHeader(java.lang.String name,
javax.mail.Message message)
throws javax.mail.MessagingException
"=?UTF-8?Q?=C3=BCber?=" is decoded to "über"
name - The header namemessage - The message providing the header
javax.mail.MessagingException - If a messaging error occurs
public static java.lang.String getStringHeader(java.lang.String name,
javax.mail.Message message,
char delimiter)
throws javax.mail.MessagingException
"=?UTF-8?Q?=C3=BCber?=" is decoded to "über"
name - The header namemessage - The message providing the headerdelimiter - The delimiter character if message contains multiple header values; set to '\0' to only consider first
one
javax.mail.MessagingException - If a messaging error occurs
public static javax.mail.internet.InternetAddress[] getAddressHeader(java.lang.String name,
javax.mail.Message message)
throws javax.mail.MessagingException
If strict parsing of address headers yields a AddressException, then a plain-text version is generated to display broken
address header as it is.
name - The address header namemessage - The message providing the address header
InternetAddress instances
javax.mail.MessagingException - If a messaging error occurspublic static javax.mail.internet.InternetAddress[] getAddressHeader(java.lang.String addresses)
addresses - The address header value
public static void parsePriority(java.lang.String priorityStr,
MailMessage mailMessage)
X-Priority.
priorityStr - The header valuemailMessage - The mail message to fill
public static void parseImportance(java.lang.String importance,
MailMessage mailMessage)
Importance.
importance - The header valuemailMessage - The mail message to fillpublic static int parsePriority(java.lang.String priorityStr)
X-Priority.
priorityStr - The header valuepublic static int parseImportance(java.lang.String importance)
Importance.
importance - The header value
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||