[FEATURE] Added InterfaceMap getter

This commit is contained in:
Jeroen Ketelaar
2019-04-30 13:10:01 -05:00
parent 7bc146b5cb
commit f74038c121
3 changed files with 26 additions and 3 deletions
@@ -7,12 +7,13 @@ import org.parabot.core.asm.wrappers.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
/** /**
* Parses an XML files which injects the hooks and other bytecode manipulation * Parses a structured format file which injects the hooks and other bytecode manipulation
* methods * methods
* *
* @author Everel * @author Everel, JKetelaar
*/ */
public abstract class HookParser { public abstract class HookParser {
@@ -22,6 +23,8 @@ public abstract class HookParser {
public abstract Interface[] getInterfaces(); public abstract Interface[] getInterfaces();
public abstract Map<String, String> getInterfaceMap();
public abstract Super[] getSupers(); public abstract Super[] getSupers();
public abstract Getter[] getGetters(); public abstract Getter[] getGetters();
@@ -12,7 +12,10 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* @author Dane * Parses a JSON file which injects the hooks and other bytecode manipulation
* methods
*
* @author Dane, JKetelaar
*/ */
public class JSONHookParser extends HookParser { public class JSONHookParser extends HookParser {
private JSONObject root; private JSONObject root;
@@ -71,6 +74,11 @@ public class JSONHookParser extends HookParser {
return null; return null;
} }
@Override
public Map<String, String> getInterfaceMap() {
return this.interfaces;
}
@Override @Override
public Super[] getSupers() { public Super[] getSupers() {
JSONArray a = (JSONArray) root.get("supers"); JSONArray a = (JSONArray) root.get("supers");
@@ -13,7 +13,14 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
/**
* Parses an XML file which injects the hooks and other bytecode manipulation
* methods
*
* @author JKetelaar
*/
public class XMLHookParser extends HookParser { public class XMLHookParser extends HookParser {
private Document doc; private Document doc;
private HashMap<String, String> interfaceMap; private HashMap<String, String> interfaceMap;
@@ -119,6 +126,11 @@ public class XMLHookParser extends HookParser {
return interfaceList.toArray(new Interface[interfaceList.size()]); return interfaceList.toArray(new Interface[interfaceList.size()]);
} }
@Override
public Map<String, String> getInterfaceMap() {
return this.interfaceMap;
}
@Override @Override
public Super[] getSupers() { public Super[] getSupers() {
final NodeList interfaceRootList = doc.getElementsByTagName("supers"); final NodeList interfaceRootList = doc.getElementsByTagName("supers");