1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.xulux.utils;
17
18
19
20
21
22 public class StringUtils {
23
24
25
26
27
28
29
30
31
32 public static String replace(String value, String replace, char c) {
33 if (value.indexOf(replace) == -1) {
34 return value;
35 }
36 StringBuffer sb = new StringBuffer();
37 for (int i = 0; i < value.length(); i++) {
38 boolean replaceIt = false;
39 for (int j = 0; j < replace.length(); j++) {
40 if (value.charAt(i+j) == replace.charAt(j)) {
41 replaceIt = true;
42 } else {
43 replaceIt = false;
44 break;
45 }
46 }
47 if (replaceIt) {
48 sb.append(c);
49 i+=replace.length()-1;
50 } else {
51 sb.append(value.charAt(i));
52 }
53 }
54 return sb.toString();
55 }
56
57
58
59
60
61
62 public static String capitalize(String constraint) {
63 if (constraint == null || constraint.length() == 0) {
64 return constraint;
65 }
66 constraint = constraint.toLowerCase();
67 StringBuffer buffer = new StringBuffer();
68 buffer.append(Character.toUpperCase(constraint.charAt(0)));
69 buffer.append(constraint.substring(1));
70 return buffer.toString();
71 }
72
73 }