Merge pull request #299 from Parabot/feature/interface-map-getter

[FEATURE] Added InterfaceMap getter
This commit is contained in:
Jeroen Ketelaar
2019-04-30 15:39:06 -05:00
committed by GitHub
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.Collections;
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
*
* @author Everel
* @author Everel, JKetelaar
*/
public abstract class HookParser {
@@ -22,6 +23,8 @@ public abstract class HookParser {
public abstract Interface[] getInterfaces();
public abstract Map<String, String> getInterfaceMap();
public abstract Super[] getSupers();
public abstract Getter[] getGetters();
@@ -12,7 +12,10 @@ import java.util.HashMap;
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 {
private JSONObject root;
@@ -71,6 +74,11 @@ public class JSONHookParser extends HookParser {
return null;
}
@Override
public Map<String, String> getInterfaceMap() {
return this.interfaces;
}
@Override
public Super[] getSupers() {
JSONArray a = (JSONArray) root.get("supers");
@@ -13,7 +13,14 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.util.ArrayList;
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 {
private Document doc;
private HashMap<String, String> interfaceMap;
@@ -119,6 +126,11 @@ public class XMLHookParser extends HookParser {
return interfaceList.toArray(new Interface[interfaceList.size()]);
}
@Override
public Map<String, String> getInterfaceMap() {
return this.interfaceMap;
}
@Override
public Super[] getSupers() {
final NodeList interfaceRootList = doc.getElementsByTagName("supers");