1 10 11 package org.mule.routing.filters; 12 13 import java.util.regex.Pattern ; 14 15 import org.mule.umo.UMOFilter; 16 import org.mule.umo.UMOMessage; 17 18 22 23 public class RegExFilter implements UMOFilter, ObjectFilter 24 { 25 private Pattern pattern; 26 27 public RegExFilter() 28 { 29 super(); 30 } 31 32 public RegExFilter(String pattern) 33 { 34 this.pattern = Pattern.compile(pattern); 35 } 36 37 public boolean accept(UMOMessage message) 38 { 39 return accept(message.getPayload()); 40 } 41 42 public boolean accept(Object object) 43 { 44 if (object == null) 45 { 46 return false; 47 } 48 49 return (pattern != null ? pattern.matcher(object.toString()).find() : false); 50 } 51 52 public String getPattern() 53 { 54 return (pattern == null ? null : pattern.pattern()); 55 } 56 57 public void setPattern(String pattern) 58 { 59 this.pattern = (pattern != null ? Pattern.compile(pattern) : null); 60 } 61 62 } 63 | Popular Tags |