1 6 7 package org.jzonic.jlo.filter; 8 9 import gnu.regexp.RE; 10 import gnu.regexp.REMatch; 11 12 import java.util.Map ; 13 19 public class RegExFilter implements LogFilter { 20 21 private String expression; 22 23 public RegExFilter() { 24 } 25 26 public boolean match(String message) { 27 if ( message != null && expression != null ) { 28 try { 29 RE re = new RE(expression,RE.REG_ICASE); 30 REMatch[] matches = re.getAllMatches(message); 31 if ( matches.length > 0 ) { 32 return true; 33 } 34 } 35 catch (Exception e) { 36 } 38 } 39 return false; 40 } 41 42 public void setParameters(Map parameter) { 43 if ( parameter.containsKey("expression") ) { 44 expression = (String )parameter.get("expression"); 45 } 46 } 47 48 } 49 | Popular Tags |