Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
MailSubjectRegExFilter |
|
| 1.6666666666666667;1.667 |
1 | /* | |
2 | * $Id: MailSubjectRegExFilter.java 7976 2007-08-21 14:26:13Z dirk.olmes $ | |
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 CPAL v1.0 | |
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 org.mule.routing.filters.RegExFilter; | |
14 | ||
15 | import javax.mail.Message; | |
16 | import javax.mail.MessagingException; | |
17 | ||
18 | /** | |
19 | * <code>MailSubjectRegExFilter</code> applies a regular expression to a Mail | |
20 | * Message subject. | |
21 | */ | |
22 | 0 | public class MailSubjectRegExFilter extends AbstractMailFilter |
23 | { | |
24 | 0 | private RegExFilter filter = new RegExFilter(); |
25 | ||
26 | public boolean accept(Message message) | |
27 | { | |
28 | try | |
29 | { | |
30 | 0 | return filter.accept(message.getSubject()); |
31 | } | |
32 | 0 | catch (MessagingException e) |
33 | { | |
34 | 0 | logger.warn("Failed to read message subject: " + e.getMessage(), e); |
35 | 0 | return false; |
36 | } | |
37 | } | |
38 | ||
39 | public void setPattern(String pattern) | |
40 | { | |
41 | 0 | filter.setPattern(pattern); |
42 | 0 | } |
43 | ||
44 | public String getPattern() | |
45 | { | |
46 | 0 | return filter.getPattern(); |
47 | } | |
48 | } |