Cleaning up; Adding new files
authorrtrimana <rtrimana@uci.edu>
Fri, 30 Sep 2016 22:43:02 +0000 (15:43 -0700)
committerrtrimana <rtrimana@uci.edu>
Fri, 30 Sep 2016 22:43:02 +0000 (15:43 -0700)
iotjava/iotpolicy/IoTCompiler.java
iotjava/iotpolicy/tree/CapabilityDecl.java
iotjava/iotpolicy/tree/Declaration.java [new file with mode: 0644]
iotjava/iotpolicy/tree/DeclarationHandler.java [new file with mode: 0644]
iotjava/iotpolicy/tree/InterfaceDecl.java
iotjava/iotpolicy/tree/RequiresDecl.java

index acd0a62602240c74e5e577316ec2a5d38d034a01..79202c4bc640163b387fe5bb04f13ef5d20c626c 100644 (file)
@@ -245,21 +245,6 @@ public class IoTCompiler {
                }
                // 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);
-                               }
-                       }
-               }*/
        }
 
 
index a55f30a04f6dd77ad4b475f578183552259b325a..7b2f923a823f162403d4cf34e5e14f1795541c4b 100644 (file)
@@ -112,28 +112,4 @@ public class CapabilityDecl extends Declaration {
                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());
-       }
 }
diff --git a/iotjava/iotpolicy/tree/Declaration.java b/iotjava/iotpolicy/tree/Declaration.java
new file mode 100644 (file)
index 0000000..ee2d9c8
--- /dev/null
@@ -0,0 +1,31 @@
+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;
+       }
+}
+
diff --git a/iotjava/iotpolicy/tree/DeclarationHandler.java b/iotjava/iotpolicy/tree/DeclarationHandler.java
new file mode 100644 (file)
index 0000000..0b8089f
--- /dev/null
@@ -0,0 +1,73 @@
+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);
+       }
+}
index 15893e314a9b4f15a9084b89fb3accba608cb1fd..2cd1d54347a498b9d5ade16d04615dd5e8fe2682 100644 (file)
@@ -183,25 +183,4 @@ public class InterfaceDecl extends Declaration {
                                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());
-       }
 }
index 417015598731c73e022226818c2ea12f51535b29..b058716af1a781f93f4bd19761fe67c6adcd56fb 100644 (file)
@@ -82,24 +82,4 @@ public class RequiresDecl extends Declaration {
 
                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());
-       }
 }