org.springframework.integration.adapter.mail.monitor
Class MailTransportUtils

java.lang.Object
  extended by org.springframework.integration.adapter.mail.monitor.MailTransportUtils

public abstract class MailTransportUtils
extends java.lang.Object

Collection of utility methods to work with Mail transports.

Author:
Arjen Poutsma

Field Summary
private static org.apache.commons.logging.Log logger
           
private static java.util.regex.Pattern SUBJECT_PATTERN
           
private static java.util.regex.Pattern TO_PATTERN
           
 
Constructor Summary
private MailTransportUtils()
           
 
Method Summary
static void closeFolder(javax.mail.Folder folder)
          Close the given JavaMail Folder and ignore any thrown exception.
static void closeFolder(javax.mail.Folder folder, boolean expunge)
          Close the given JavaMail Folder and ignore any thrown exception.
static void closeService(javax.mail.Service service)
          Close the given JavaMail Service and ignore any thrown exception.
static java.lang.String getSubject(java.net.URI uri)
           
static javax.mail.internet.InternetAddress getTo(java.net.URI uri)
           
static java.lang.String toPasswordProtectedString(javax.mail.URLName name)
          Returns a string representation of the given URLName, where the password has been protected.
static java.net.URI toUri(javax.mail.internet.InternetAddress to, java.lang.String subject)
          Converts the given internet address into a mailto URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TO_PATTERN

private static final java.util.regex.Pattern TO_PATTERN

SUBJECT_PATTERN

private static final java.util.regex.Pattern SUBJECT_PATTERN

logger

private static final org.apache.commons.logging.Log logger
Constructor Detail

MailTransportUtils

private MailTransportUtils()
Method Detail

getTo

public static javax.mail.internet.InternetAddress getTo(java.net.URI uri)

getSubject

public static java.lang.String getSubject(java.net.URI uri)

closeService

public static void closeService(javax.mail.Service service)
Close the given JavaMail Service and ignore any thrown exception. This is useful for typical finally blocks in manual JavaMail code.

Parameters:
service - the JavaMail Service to close (may be null)
See Also:
Transport, Store

closeFolder

public static void closeFolder(javax.mail.Folder folder)
Close the given JavaMail Folder and ignore any thrown exception. This is useful for typical finally blocks in manual JavaMail code.

Parameters:
folder - the JavaMail Folder to close (may be null)

closeFolder

public static void closeFolder(javax.mail.Folder folder,
                               boolean expunge)
Close the given JavaMail Folder and ignore any thrown exception. This is useful for typical finally blocks in manual JavaMail code.

Parameters:
folder - the JavaMail Folder to close (may be null)
expunge - whether all deleted messages should be expunged from the folder

toPasswordProtectedString

public static java.lang.String toPasswordProtectedString(javax.mail.URLName name)
Returns a string representation of the given URLName, where the password has been protected.


toUri

public static java.net.URI toUri(javax.mail.internet.InternetAddress to,
                                 java.lang.String subject)
                          throws java.net.URISyntaxException
Converts the given internet address into a mailto URI.

Parameters:
to - the To: address
subject - the subject, may be null
Returns:
a mailto URI
Throws:
java.net.URISyntaxException