1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.util;
21
22 import org.apache.myfaces.tobago.internal.util.Deprecation;
23 import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
24
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.Locale;
28 import java.util.StringTokenizer;
29
30
31
32
33 public class StringUtils {
34
35 private StringUtils() {
36 }
37
38
39
40
41 @Deprecated
42 public static String firstToUpperCase(String string) {
43 if (Deprecation.LOG.isWarnEnabled()) {
44 Deprecation.LOG.warn("use commons-lang please");
45 }
46 if (string == null) {
47 return null;
48 }
49 switch (string.length()) {
50 case 0:
51 return string;
52 case 1:
53 return string.toUpperCase(Locale.ENGLISH);
54 default:
55 return string.substring(0, 1).toUpperCase(Locale.ENGLISH) + string.substring(1);
56 }
57 }
58
59 public static List<Integer> parseIntegerList(String integerList)
60 throws NumberFormatException {
61 List<Integer> list = new ArrayList<Integer>();
62
63 StringTokenizer tokenizer = new StringTokenizer(integerList, ", ");
64 while (tokenizer.hasMoreElements()) {
65 String token = tokenizer.nextToken().trim();
66 if (token.length() > 0) {
67 list.add(new Integer(token));
68 }
69 }
70
71 return list;
72 }
73
74 public static <T> String toString(List<T> list) {
75 StringBuilder buffer = new StringBuilder(",");
76 for (T t : list) {
77 buffer.append(t);
78 buffer.append(",");
79 }
80 return buffer.toString();
81 }
82
83 @Deprecated
84 public static String escapeAccessKeyIndicator(String label) {
85 if (Deprecation.LOG.isWarnEnabled()) {
86 Deprecation.LOG.warn(label);
87 }
88 return org.apache.commons.lang.StringUtils.replace(label,
89 String.valueOf(LabelWithAccessKey.INDICATOR), LabelWithAccessKey.ESCAPED_INDICATOR);
90 }
91
92 }