KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jzonic > jlo > filter > TextFilter


1 /*
2  * TextFilter.java
3  *
4  * Created on 28. August 2003, 22:09
5  */

6
7 package org.jzonic.jlo.filter;
8
9 import java.util.Map JavaDoc;
10 /**
11  * This is a simple text filter. The filter will check
12  * if the given expression appears in the message. The
13  * filter is not case sensitive
14  *
15  * @author Andreas Mecky andreasmecky@yahoo.de
16  */

17 public class TextFilter implements LogFilter {
18     
19     private String JavaDoc expression;
20     
21     public TextFilter() {
22     }
23     
24     public boolean match(String JavaDoc message) {
25         if ( message != null ) {
26             String JavaDoc tmp = message.toUpperCase();
27             if ( tmp.indexOf(expression) != -1 ) {
28                 return true;
29             }
30         }
31         return false;
32     }
33     
34     public void setParameters(Map JavaDoc parameter) {
35         if ( parameter.containsKey("expression") ) {
36             expression = (String JavaDoc)parameter.get("expression");
37             expression = expression.toUpperCase();
38         }
39     }
40     
41 }
42
Popular Tags