TextUtil.java
2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.granite.taskmanagement.impl.utils;
public class TextUtil {
public static final String[] STANDARD_LABEL_CHAR_MAPPING = new String[]{"_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "-", "_", "_", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "_", "_", "_", "_", "_", "_", "_", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "_", "_", "_", "_", "_", "_", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "_", "_", "_", "_", "_", "_", "f", "_", "_", "_", "fi", "fi", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "y", "_", "_", "_", "_", "i", "c", "p", "o", "v", "_", "s", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "a", "a", "a", "a", "ae", "a", "ae", "c", "e", "e", "e", "e", "i", "i", "i", "i", "d", "n", "o", "o", "o", "o", "oe", "x", "o", "u", "u", "u", "ue", "y", "b", "ss", "a", "a", "a", "a", "ae", "a", "ae", "c", "e", "e", "e", "e", "i", "i", "i", "i", "o", "n", "o", "o", "o", "o", "oe", "_", "o", "u", "u", "u", "ue", "y", "b", "y"};
private TextUtil() {
}
public static boolean isEmpty(String aString) {
return aString == null || aString.trim().length() == 0;
}
public static String createValidName(String title) {
return TextUtil.createValidName(title, STANDARD_LABEL_CHAR_MAPPING);
}
public static String createValidName(String title, String[] labelCharMapping) {
char[] chrs = title.toCharArray();
StringBuilder name = new StringBuilder(chrs.length);
boolean prevEscaped = false;
for (int idx = 0; idx < title.length() && name.length() < 64; ++idx) {
char c = title.charAt(idx);
String repl = "_";
if (c >= '\u0000' && c < labelCharMapping.length) {
repl = labelCharMapping[c];
}
if (repl.equals("_")) {
if (!prevEscaped && name.length() < 16) {
name.append('_');
}
prevEscaped = true;
continue;
}
name.append(repl);
prevEscaped = false;
}
return name.toString();
}
}