KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > email > filters > MailSubjectRegExFilter


1 /*
2  * $Id: MailSubjectRegExFilter.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.email.filters;
12
13 import javax.mail.Message JavaDoc;
14 import javax.mail.MessagingException JavaDoc;
15
16 import org.mule.routing.filters.RegExFilter;
17
18 /**
19  * <code>MailSubjectRegExFilter</code> applies a regular expression to a Mail
20  * Message subject.
21  */

22 public class MailSubjectRegExFilter extends AbstractMailFilter
23 {
24     private RegExFilter filter = new RegExFilter();
25
26     public boolean accept(Message JavaDoc message)
27     {
28         try
29         {
30             return filter.accept(message.getSubject());
31         }
32         catch (MessagingException JavaDoc e)
33         {
34             logger.warn("Failed to read message subject: " + e.getMessage(), e);
35             return false;
36         }
37     }
38
39     public void setPattern(String JavaDoc pattern)
40     {
41         filter.setPattern(pattern);
42     }
43
44     public String JavaDoc getPattern()
45     {
46         return filter.getPattern();
47     }
48 }
49
Popular Tags