Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DebugIdUtils |
|
| 6.0;6 |
1 | package org.kuali.student.common.ui.client.util; | |
2 | ||
3 | import com.google.gwt.user.client.ui.UIObject; | |
4 | ||
5 | 0 | public class DebugIdUtils { |
6 | ||
7 | ||
8 | /** | |
9 | * Converts a String to a WebDriver safe debug ID by replacing all non-digit, non-letter (including Unicode characters) with a dash('-') character. | |
10 | * Please note that space characters (' ') will also be replaced by a dash character. | |
11 | * This also strips the 'gwt-debug' prefix if it exists. | |
12 | * | |
13 | * @param debugId The existing debugId. | |
14 | * @return The converted string debug ID. | |
15 | */ | |
16 | public static String createWebDriverSafeDebugId(String debugId) { | |
17 | 0 | StringBuilder newDebugId = null; |
18 | 0 | if (debugId != null) { |
19 | //Strip the gwt-debug prefix if it exists | |
20 | 0 | if (debugId.startsWith(UIObject.DEBUG_ID_PREFIX)) { |
21 | 0 | debugId = debugId.substring(UIObject.DEBUG_ID_PREFIX.length()); |
22 | ||
23 | } | |
24 | 0 | newDebugId = new StringBuilder(); |
25 | 0 | for (int i = 0; i < debugId.length(); i++) { |
26 | 0 | newDebugId.append(Character.isLetterOrDigit(debugId.charAt(i)) ? debugId.charAt(i) : "-"); |
27 | } | |
28 | 0 | return newDebugId.toString(); |
29 | } | |
30 | 0 | return null; |
31 | } | |
32 | ||
33 | } |