1 /**
2 * Copyright 2005-2014 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.kns.util;
17
18 import org.apache.commons.lang.NumberUtils;
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.rice.core.api.util.collect.CollectionUtils;
21
22 import java.util.Enumeration;
23
24 /**
25 * Utility for that is used along with the tableRenderPagingBanner.tag.
26 *
27 * @author Kuali Rice Team (rice.collab@kuali.org)
28 *
29 * @deprecated Only used in KNS classes, use KRAD.
30 */
31 @Deprecated
32 public final class PagingBannerUtils {
33
34 /** do not call. */
35 private PagingBannerUtils() {
36 throw new UnsupportedOperationException("do not call");
37 }
38
39 /**
40 * find the number string in a method to call parameter with the following format parameterPrefix.1 or
41 * parameterPrefix.1.bleh
42 *
43 * @param paramPrefix the
44 * @param parameterNames the parameter names.
45 * @return the numerical value or -1
46 */
47 public static int getNumbericalValueAfterPrefix(String paramPrefix, Enumeration<String> parameterNames) {
48
49 for (String parameterName : CollectionUtils.toIterable(parameterNames)) {
50 if (parameterName.startsWith(paramPrefix)) {
51 parameterName = WebUtils.endsWithCoordinates(parameterName) ? parameterName : parameterName + ".x";
52 String numberStr = StringUtils.substringBetween(parameterName, paramPrefix, ".");
53 if (NumberUtils.isDigits(numberStr)) {
54 return Integer.parseInt(numberStr);
55 }
56 }
57 }
58
59 return -1;
60 }
61
62 /**
63 * same as method above except for use when it is not feasible to use ordinals to identify columns -- for example,
64 * if dynamic attributes may be used
65 */
66 public static String getStringValueAfterPrefix(String paramPrefix, Enumeration<String> parameterNames) {
67 for (String parameterName : CollectionUtils.toIterable(parameterNames)) {
68 if (parameterName.startsWith(paramPrefix)) {
69 parameterName = WebUtils.endsWithCoordinates(parameterName) ? parameterName : parameterName + ".x";
70 return StringUtils.substringBetween(parameterName, paramPrefix, ".");
71 }
72 }
73
74 return "";
75 }
76 }