The final version for lede-gui (the phone app for device registration)
[iot2.git] / others / lede-gui / src / main / java / com / example / lede2 / DatabaseObject.java
diff --git a/others/lede-gui/src/main/java/com/example/lede2/DatabaseObject.java b/others/lede-gui/src/main/java/com/example/lede2/DatabaseObject.java
new file mode 100644 (file)
index 0000000..b49de7b
--- /dev/null
@@ -0,0 +1,44 @@
+package com.example.lede2;\r
+\r
+import android.provider.ContactsContract;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Hashtable;\r
+import java.util.List;\r
+import java.util.Set;\r
+\r
+/**\r
+ * Created by Brian on 2/28/2018.\r
+ */\r
+    /*hierarchy of this object is dbobject -> dbtypeobject -> dbsubtypeobject\r
+      dbobject holds a hashtable of typeobject and typeobject holds a hashtable of subtypeobject\r
+      structure is similar across all levels, subtype obejct also holds the individual instances */\r
+public class DatabaseObject {\r
+    private int numTypes;\r
+    Hashtable<String, DatabaseTypeObject> types;\r
+\r
+    public DatabaseObject(){\r
+        numTypes = 0;\r
+        types = new Hashtable<String, DatabaseTypeObject>();\r
+\r
+    }\r
+\r
+    public void addTypeObject(String name, DatabaseTypeObject typeObject){\r
+        if(!types.contains(name)){\r
+            types.put(name, typeObject);\r
+            numTypes++;\r
+        }\r
+    }\r
+    public void deleteTypeObject(String name){\r
+        if(types.contains(name)){\r
+            types.remove(name);\r
+            numTypes--;\r
+        }\r
+    }\r
+    public DatabaseTypeObject getTypeObject(String name){\r
+        return types.get(name);\r
+    }\r
+    public Set<String> getKeySet(){\r
+        return types.keySet();\r
+    }\r
+}\r