Coverage Report - org.mule.transport.email.filters.MailSubjectRegExFilter
 
Classes in this File Line Coverage Branch Coverage Complexity
MailSubjectRegExFilter
0%
0/14
0%
0/6
2.2
 
 1  
 /*
 2  
  * $Id: MailSubjectRegExFilter.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.transport.email.filters;
 12  
 
 13  
 import org.mule.routing.filters.RegExFilter;
 14  
 import org.mule.util.ClassUtils;
 15  
 
 16  
 import javax.mail.Message;
 17  
 import javax.mail.MessagingException;
 18  
 
 19  
 /**
 20  
  * <code>MailSubjectRegExFilter</code> applies a regular expression to a Mail
 21  
  * Message subject.
 22  
  */
 23  0
 public class MailSubjectRegExFilter extends AbstractMailFilter
 24  
 {
 25  0
     private RegExFilter filter = new RegExFilter();
 26  
 
 27  
     public boolean accept(Message message)
 28  
     {
 29  
         try
 30  
         {
 31  0
             return filter.accept(message.getSubject());
 32  
         }
 33  0
         catch (MessagingException e)
 34  
         {
 35  0
             logger.warn("Failed to read message subject: " + e.getMessage(), e);
 36  0
             return false;
 37  
         }
 38  
     }
 39  
 
 40  
     public void setExpression(String pattern)
 41  
     {
 42  0
         filter.setPattern(pattern);
 43  0
     }
 44  
 
 45  
     public String getExpression()
 46  
     {
 47  0
         return filter.getPattern();
 48  
     }
 49  
 
 50  
     public boolean equals(Object obj)
 51  
     {
 52  0
         if (this == obj) return true;
 53  0
         if (obj == null || getClass() != obj.getClass()) return false;
 54  
 
 55  0
         final MailSubjectRegExFilter other = (MailSubjectRegExFilter) obj;
 56  0
         return ClassUtils.equal(filter, other.filter);
 57  
     }
 58  
 
 59  
     public int hashCode()
 60  
     {
 61  0
         return ClassUtils.hash(new Object[]{this.getClass(), filter});
 62  
     }
 63  
 }