1 package info.ejava.examples.ejb.interceptor.normalizer;
2
3 public class NormalizerBase {
4
5
6
7
8
9
10 public String normalizeName(String name) {
11 if (name==null) { return null; }
12
13 StringBuilder normalizedString = new StringBuilder();
14 for (String tok: name.split("\\s")) {
15 if (normalizedString.length() > 0) {
16 normalizedString.append(" ");
17 }
18 normalizedString.append(tok.substring(0, 1).toUpperCase());
19 if (tok.length() > 1) {
20 normalizedString.append(toLower(tok.substring(1)));
21 }
22 }
23 return normalizedString.toString();
24 }
25
26
27 public String toUpper(String value) {
28 if (value==null) { return null; }
29 return value.toUpperCase().trim();
30 }
31
32 public String toLower(String value) {
33 if (value==null) { return null; }
34 return value.toLowerCase().trim();
35 }
36 }