Coverage Report - org.mule.routing.filters.RegExFilter
 
Classes in this File Line Coverage Branch Coverage Complexity
RegExFilter
0%
0/12
0%
0/4
1.333
 
 1  
 /*
 2  
  * $Id: RegExFilter.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.routing.filters;
 12  
 
 13  
 import org.mule.umo.UMOFilter;
 14  
 import org.mule.umo.UMOMessage;
 15  
 
 16  
 import java.util.regex.Pattern;
 17  
 
 18  
 /**
 19  
  * <code>RegExFilter</code> is used to match a String argument against a regular
 20  
  * expression.
 21  
  */
 22  
 
 23  
 public class RegExFilter implements UMOFilter, ObjectFilter
 24  
 {
 25  
     private Pattern pattern;
 26  
 
 27  
     public RegExFilter()
 28  
     {
 29  0
         super();
 30  0
     }
 31  
 
 32  
     public RegExFilter(String pattern)
 33  0
     {
 34  0
         this.pattern = Pattern.compile(pattern);
 35  0
     }
 36  
 
 37  
     public boolean accept(UMOMessage message)
 38  
     {
 39  0
         return accept(message.getPayload());
 40  
     }
 41  
 
 42  
     public boolean accept(Object object)
 43  
     {
 44  0
         if (object == null)
 45  
         {
 46  0
             return false;
 47  
         }
 48  
 
 49  0
         return (pattern != null ? pattern.matcher(object.toString()).find() : false);
 50  
     }
 51  
 
 52  
     public String getPattern()
 53  
     {
 54  0
         return (pattern == null ? null : pattern.pattern());
 55  
     }
 56  
 
 57  
     public void setPattern(String pattern)
 58  
     {
 59  0
         this.pattern = (pattern != null ? Pattern.compile(pattern) : null);
 60  0
     }
 61  
 
 62  
 }