core: move 'escape' method to string utils
This commit is contained in:
@@ -15,7 +15,7 @@ import jadx.core.dex.instructions.args.SSAVar;
|
||||
import jadx.core.dex.instructions.mods.ConstructorInsn;
|
||||
import jadx.core.dex.nodes.InsnNode;
|
||||
import jadx.core.dex.nodes.MethodNode;
|
||||
import jadx.core.utils.Utils;
|
||||
import jadx.core.utils.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -165,7 +165,7 @@ public class NameGen {
|
||||
return vName;
|
||||
}
|
||||
}
|
||||
return Utils.escape(type.toString());
|
||||
return StringUtils.escape(type.toString());
|
||||
}
|
||||
|
||||
private static String fromName(String name) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import jadx.core.dex.trycatch.ExceptionHandler;
|
||||
import jadx.core.utils.BlockUtils;
|
||||
import jadx.core.utils.InsnUtils;
|
||||
import jadx.core.utils.RegionUtils;
|
||||
import jadx.core.utils.StringUtils;
|
||||
import jadx.core.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -100,7 +101,7 @@ public class DotGraphVisitor extends AbstractVisitor {
|
||||
dot.startLine('}');
|
||||
dot.startLine();
|
||||
|
||||
String fileName = Utils.escape(mth.getMethodInfo().getShortId())
|
||||
String fileName = StringUtils.escape(mth.getMethodInfo().getShortId())
|
||||
+ (useRegions ? ".regions" : "")
|
||||
+ (rawInsn ? ".raw" : "")
|
||||
+ ".dot";
|
||||
|
||||
@@ -61,4 +61,38 @@ public class StringUtils {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static String escape(String str) {
|
||||
int len = str.length();
|
||||
StringBuilder sb = new StringBuilder(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
char c = str.charAt(i);
|
||||
switch (c) {
|
||||
case '.':
|
||||
case '/':
|
||||
case ';':
|
||||
case '$':
|
||||
case ' ':
|
||||
case ',':
|
||||
case '<':
|
||||
sb.append('_');
|
||||
break;
|
||||
|
||||
case '[':
|
||||
sb.append('A');
|
||||
break;
|
||||
|
||||
case ']':
|
||||
case '>':
|
||||
case '?':
|
||||
case '*':
|
||||
break;
|
||||
|
||||
default:
|
||||
sb.append(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,40 +26,6 @@ public class Utils {
|
||||
return 'L' + obj.replace('.', '/') + ';';
|
||||
}
|
||||
|
||||
public static String escape(String str) {
|
||||
int len = str.length();
|
||||
StringBuilder sb = new StringBuilder(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
char c = str.charAt(i);
|
||||
switch (c) {
|
||||
case '.':
|
||||
case '/':
|
||||
case ';':
|
||||
case '$':
|
||||
case ' ':
|
||||
case ',':
|
||||
case '<':
|
||||
sb.append('_');
|
||||
break;
|
||||
|
||||
case '[':
|
||||
sb.append('A');
|
||||
break;
|
||||
|
||||
case ']':
|
||||
case '>':
|
||||
case '?':
|
||||
case '*':
|
||||
break;
|
||||
|
||||
default:
|
||||
sb.append(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String listToString(Iterable<?> list) {
|
||||
if (list == null) {
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user