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
1 package com.example.lede2;\r
2 \r
3 import android.provider.ContactsContract;\r
4 \r
5 import java.util.ArrayList;\r
6 import java.util.Hashtable;\r
7 import java.util.List;\r
8 import java.util.Set;\r
9 \r
10 /**\r
11  * Created by Brian on 2/28/2018.\r
12  */\r
13     /*hierarchy of this object is dbobject -> dbtypeobject -> dbsubtypeobject\r
14       dbobject holds a hashtable of typeobject and typeobject holds a hashtable of subtypeobject\r
15       structure is similar across all levels, subtype obejct also holds the individual instances */\r
16 public class DatabaseObject {\r
17     private int numTypes;\r
18     Hashtable<String, DatabaseTypeObject> types;\r
19 \r
20     public DatabaseObject(){\r
21         numTypes = 0;\r
22         types = new Hashtable<String, DatabaseTypeObject>();\r
23 \r
24     }\r
25 \r
26     public void addTypeObject(String name, DatabaseTypeObject typeObject){\r
27         if(!types.contains(name)){\r
28             types.put(name, typeObject);\r
29             numTypes++;\r
30         }\r
31     }\r
32     public void deleteTypeObject(String name){\r
33         if(types.contains(name)){\r
34             types.remove(name);\r
35             numTypes--;\r
36         }\r
37     }\r
38     public DatabaseTypeObject getTypeObject(String name){\r
39         return types.get(name);\r
40     }\r
41     public Set<String> getKeySet(){\r
42         return types.keySet();\r
43     }\r
44 }\r