1 package org.kuali.student.common.ui.client.util;
2
3 import com.google.gwt.user.client.ui.UIObject;
4
5 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 StringBuilder newDebugId = null;
18 if (debugId != null) {
19 //Strip the gwt-debug prefix if it exists
20 if (debugId.startsWith(UIObject.DEBUG_ID_PREFIX)) {
21 debugId = debugId.substring(UIObject.DEBUG_ID_PREFIX.length());
22
23 }
24 newDebugId = new StringBuilder();
25 for (int i = 0; i < debugId.length(); i++) {
26 newDebugId.append(Character.isLetterOrDigit(debugId.charAt(i)) ? debugId.charAt(i) : "-");
27 }
28 return newDebugId.toString();
29 }
30 return null;
31 }
32
33 }