io.imqa.injector.MappingTable Maven / Gradle / Ivy
package io.imqa.injector;
import java.util.HashMap;
import io.imqa.injector.util.Logger;
public class MappingTable {
HashMap map = new HashMap<>();
public void parse(String mappingTxt) {
String[] firstLine;
String classKey = "";
MapValue classMapValue;
for (String line : mappingTxt.split("\n")) {
if (line.indexOf(":") > 0) {
if(line.indexOf("->") > 0){
firstLine = line.replace(" ", "").split("->");
// String[] packageSplited = firstLine[0].split("\\.");
classMapValue = new MapValue(firstLine[0], firstLine[1]);
classKey = firstLine[1].replace(":", "").replace("\r","");
map.put(classKey, classMapValue);
}
}else{
if(line.indexOf("->") > 0){
String[] methodLine = line.split("->");
String methodValue = methodLine[0];
methodValue = methodValue.trim(); // 앞뒤 공백제거
methodValue = methodValue.split(" ")[1];
methodValue = methodValue.split("\\(")[0];
//log.warn("parseStr", parseStr[1]);
String methodKey = methodLine[1].replace(" ", "").replace("\r","");
//log.warn("method key ", subkey);
map.get(classKey).methods.put(methodKey, methodValue);
// map.put(firstMapKey)
}
}
}
}
public HashMap getMappingTable() {
return map;
}
public class MapValue {
public String className;
public String raw;
public HashMap methods;
public MapValue(String raw, String className) {
this.raw = raw;
this.className = className;
}
}
}