KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > snapper > parsers > TextFilter


1 package org.enhydra.snapper.parsers;
2
3 public class TextFilter {
4       public static final char CH07 = (char) 7;
5       public static final char CH10 = (char) 10;
6       public static final char CH13 = (char) 13;
7       public static final char[] DEFAULT_FORBIDDEN_CHARACTERS =
8         { CH07, CH10, CH13 };
9       public static final char SPACE = (char) 32;
10
11       public static String JavaDoc filterForbiddenCharacters (
12         String JavaDoc s, char[] forbidden) {
13         if (s == null || s.trim().length() <= 0) return s;
14           for (int i = 0; i<forbidden.length; i++) {
15             char c = forbidden[i];
16             s = s.replace (c, SPACE);
17           }
18           return s;
19           
20         }
21       }
Popular Tags