}
// Map the map of interface-methods to the original interface
mapInt2NewInts.put(origInt, mapNewIntMethods);
-
-/* for (String origint : mapInt2NewInts.keySet()) {
-
- System.out.println("Original Interface: " + origint);
- Map<String,Set<String>> mapNewInt = mapInt2NewInts.get(origint);
- for (String intf : mapNewInt.keySet()) {
-
- System.out.println("\tNew Interface: " + intf);
- Set<String> methods = mapNewInt.get(intf);
- for (String meth : methods) {
-
- System.out.println("\t\tMethod: " + meth);
- }
- }
- }*/
}
int index = listCapabs.indexOf(cap);
return listMethods.get(index);
}
-
-
- public static void main(String[] args) {
-
- CapabilityDecl cd = new CapabilityDecl("Camera");
- cd.addNewCapability("ImageCapture");
- cd.addNewDescription("ImageCapture", "The quick brown fox jumps over the smart dog");
- cd.addNewDescription("ImageCapture", "ImageCapture capability");
- cd.addNewMethod("ImageCapture", "MethodA");
- cd.addNewMethod("ImageCapture", "MethodC");
- cd.addNewMethod("ImageCapture", "MethodD");
-
- cd.addNewCapability("VideoRecording");
- cd.addNewDescription("VideoRecording", "The quick brown fox jumps over the smart dog");
- cd.addNewDescription("VideoRecording", "VideoRecording ");
- cd.addNewMethod("VideoRecording", "MethodE");
- cd.addNewMethod("VideoRecording", "MethodF");
-
- System.out.println("Set of capabilities: " + cd.getCapabilities().toString());
- System.out.println("Set of descriptions: " + cd.getDescriptions("VideoRecording").toString());
- System.out.println("Set of methods: " + cd.getMethods("VideoRecording").toString());
- System.out.println("Set of descriptions: " + cd.getDescriptions("ImageCapture").toString());
- System.out.println("Set of methods: " + cd.getMethods("ImageCapture").toString());
- }
}
--- /dev/null
+package iotpolicy.tree;
+
+/** Abstract class Declaration is a parent class of InterfaceDecl,
+ * CapabilityDecl, and RequiresDecl
+ *
+ * @author Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
+ * @version 1.0
+ * @since 2016-09-30
+ */
+public abstract class Declaration {
+
+ /**
+ * Class properties
+ */
+ private String origInt;
+
+ /**
+ * Class constructors
+ */
+ public Declaration() {
+
+ origInt = null;
+ }
+
+
+ public Declaration(String _origInt) {
+
+ origInt = _origInt;
+ }
+}
+
--- /dev/null
+package iotpolicy.tree;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/** Abstract class Declaration is a parent class of InterfaceDecl,
+ * CapabilityDecl, and RequiresDecl
+ *
+ * @author Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
+ * @version 1.0
+ * @since 2016-09-30
+ */
+public class DeclarationHandler {
+
+ /**
+ * Class properties
+ */
+ private Map<String,Declaration> mapInt2IntfaceDecl;
+ private Map<String,Declaration> mapInt2CapabDecl;
+ private Map<String,Declaration> mapInt2ReqDecl;
+
+ /**
+ * Class constructors
+ */
+ public DeclarationHandler() {
+
+ mapInt2IntfaceDecl = new HashMap<String,Declaration>();
+ mapInt2CapabDecl = new HashMap<String,Declaration>();
+ mapInt2ReqDecl = new HashMap<String,Declaration>();
+ }
+
+
+ /**
+ * Setters/adders
+ */
+ public void addInterfaceDecl(String origInt, Declaration intDecl) {
+
+ mapInt2IntfaceDecl.put(origInt, intDecl);
+ }
+
+
+ public void addCapabilityDecl(String origInt, Declaration capDecl) {
+
+ mapInt2CapabDecl.put(origInt, capDecl);
+ }
+
+
+ public void addRequiresDecl(String origInt, Declaration reqDecl) {
+
+ mapInt2ReqDecl.put(origInt, reqDecl);
+ }
+
+
+ /**
+ * Getters
+ */
+ public Declaration getInterfaceDecl(String origInt) {
+
+ return mapInt2IntfaceDecl.get(origInt);
+ }
+
+
+ public Declaration getCapabilityDecl(String origInt) {
+
+ return mapInt2CapabDecl.get(origInt);
+ }
+
+
+ public Declaration getRequiresDecl(String origInt) {
+
+ return mapInt2ReqDecl.get(origInt);
+ }
+}
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());
- }
}
return mapRequires.get(intFace);
}
-
-
- public static void main(String[] args) {
-
- RequiresDecl rd = new RequiresDecl("Camera");
- rd.addNewIntface("CameraWithCaptureAndData");
- rd.addNewCapability("CameraWithCaptureAndData", "ImageCapture");
- rd.addNewCapability("CameraWithCaptureAndData", "VideoRecording");
-
- System.out.println("Set of interfaces: " + rd.getInterfaces().toString());
- System.out.println("Set of capabilities: " + rd.getCapabList("CameraWithCaptureAndData").toString());
-
- rd.addNewIntface("CameraWithCaptureAndRecording");
- rd.addNewCapability("CameraWithCaptureAndRecording", "ImageCapture");
- rd.addNewCapability("CameraWithCaptureAndRecording", "BackupData");
-
- System.out.println("Set of interfaces: " + rd.getInterfaces().toString());
- System.out.println("Set of capabilities: " + rd.getCapabList("CameraWithCaptureAndData").toString());
- System.out.println("Set of capabilities: " + rd.getCapabList("CameraWithCaptureAndData").toString());
- }
}