View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
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   * @deprecated Please use VariableResolverUtils
32   */
33  public class StringUtils {
34  
35    private StringUtils() {
36    }
37  
38    /**
39     * @deprecated Use commons-lang StringUtils.capitalize() instead.
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  }