private List<String> listMethodTypes; // Method types, e.g. void
private List<List<String>> listMethodParams; // Method parameter names, e.g. A, B
private List<List<String>> listMethodParamTypes; // Method parameter types, e.g. int, int
+ private Map<String,Integer> mapHelperNumMethodId; // Helper method Id, e.g. for callbacks, structs.
+
+ private static int helperMethodIdNum = -9999;
/**
* Class constructors
listMethodTypes = new ArrayList<String>();
listMethodParams = new ArrayList<List<String>>();
listMethodParamTypes = new ArrayList<List<String>>();
+ mapHelperNumMethodId = new HashMap<String,Integer>();
}
listMethodTypes = new ArrayList<String>();
listMethodParams = new ArrayList<List<String>>();
listMethodParamTypes = new ArrayList<List<String>>();
+ mapHelperNumMethodId = new HashMap<String,Integer>();
}
}
+ /**
+ * getMethodNumId() gets Id number for a method
+ */
+ public int getMethodNumId(String method) {
+
+ return listMethods.indexOf(method);
+ }
+
+
+ /**
+ * getHelperMethodNumId() gets Id number for a method
+ */
+ public int getHelperMethodNumId(String method) {
+
+ if (!mapHelperNumMethodId.containsKey(method)) {
+ mapHelperNumMethodId.put(method, helperMethodIdNum++);
+ return mapHelperNumMethodId.get(method);
+ } else {
+ return mapHelperNumMethodId.get(method);
+ }
+ }
+
+
/**
* getMethodIds() gets method identifiers
*/
method + "! Please check your policy file...");
return listMethodParamTypes.get(index);
}
-
-
- public static void main(String[] args) {
-
- InterfaceDecl id = new InterfaceDecl("Camera");
- id.addNewMethod("MethodA(intA,SpeakerB)", "MethodA", "void");
- id.addMethodParam("MethodA", "A", "int");
- id.addMethodParam("MethodA", "B", "int");
- id.addMethodParam("MethodB", "C", "int");
- id.addMethodParam("MethodB", "D", "string");
- id.addMethodParam("MethodC", "E", "string");
- id.addMethodParam("MethodC", "F", "int");
-
- System.out.println("Set of methods: " + id.getMethods().toString());
- System.out.println("Set of params: " + id.getMethodParams("MethodA").toString());
- System.out.println("Set of paramtypes: " + id.getMethodParamTypes("MethodA").toString());
- System.out.println("Set of params: " + id.getMethodParams("MethodB").toString());
- System.out.println("Set of paramtypes: " + id.getMethodParamTypes("MethodB").toString());
- System.out.println("Set of params: " + id.getMethodParams("MethodC").toString());
- System.out.println("Set of paramtypes: " + id.getMethodParamTypes("MethodC").toString());
- }
}