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  
24  import java.util.ArrayList;
25  import java.util.List;
26  import java.util.Locale;
27  import java.util.StringTokenizer;
28  
29  /**
30   * @deprecated Please use VariableResolverUtils
31   */
32  public class StringUtils {
33  
34    private StringUtils() {
35    }
36  
37    /**
38     * @deprecated Use commons-lang StringUtils.capitalize() instead.
39     */
40    @Deprecated
41    public static String firstToUpperCase(final String string) {
42      if (Deprecation.LOG.isWarnEnabled()) {
43        Deprecation.LOG.warn("use commons-lang please");
44      }
45      if (string == null) {
46        return null;
47      }
48      switch (string.length()) {
49        case 0:
50          return string;
51        case 1:
52          return string.toUpperCase(Locale.ENGLISH);
53        default:
54          return string.substring(0, 1).toUpperCase(Locale.ENGLISH) + string.substring(1);
55      }
56    }
57  
58    public static List<Integer> parseIntegerList(final String integerList)
59        throws NumberFormatException {
60      final List<Integer> list = new ArrayList<Integer>();
61  
62      final StringTokenizer tokenizer = new StringTokenizer(integerList, ", ");
63      while (tokenizer.hasMoreElements()) {
64        final String token = tokenizer.nextToken().trim();
65        if (token.length() > 0) {
66          list.add(new Integer(token));
67        }
68      }
69  
70      return list;
71    }
72  
73    public static <T> String toString(final List<T> list) {
74      final StringBuilder buffer = new StringBuilder(",");
75      for (final T t : list) {
76        buffer.append(t);
77        buffer.append(",");
78      }
79      return buffer.toString();
80    }
81  }