Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/iot2
[iot2.git] / iotjava / iotpolicy / tree / DeclarationHandler.java
1 package iotpolicy.tree;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 /** Abstract class Declaration is a parent class of InterfaceDecl,
7  *  CapabilityDecl, and RequiresDecl
8  *
9  * @author      Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
10  * @version     1.0
11  * @since       2016-09-30
12  */
13 public class DeclarationHandler {
14
15         /**
16          * Class properties
17          */
18         private Map<String,Declaration> mapInt2IntfaceDecl;
19         private Map<String,Declaration> mapInt2CapabDecl;
20         private Map<String,Declaration> mapInt2ReqDecl;
21         private Map<String,Declaration> mapInt2EnumDecl;
22         private Map<String,Declaration> mapInt2StructDecl;
23
24         /**
25          * Class constructors
26          */
27         public DeclarationHandler() {
28
29                 mapInt2IntfaceDecl = new HashMap<String,Declaration>();
30                 mapInt2CapabDecl = new HashMap<String,Declaration>();
31                 mapInt2ReqDecl = new HashMap<String,Declaration>();
32                 mapInt2EnumDecl = new HashMap<String,Declaration>();
33                 mapInt2StructDecl = new HashMap<String,Declaration>();
34         }
35
36
37         /**
38          * Setters/adders
39          */
40         public void addInterfaceDecl(String origInt, Declaration intDecl) {
41
42                 mapInt2IntfaceDecl.put(origInt, intDecl);
43         }
44
45
46         public void addCapabilityDecl(String origInt, Declaration capDecl) {
47
48                 mapInt2CapabDecl.put(origInt, capDecl);
49         }
50
51
52         public void addRequiresDecl(String origInt, Declaration reqDecl) {
53
54                 mapInt2ReqDecl.put(origInt, reqDecl);
55         }
56
57
58         public void addEnumDecl(String origInt, Declaration enumDecl) {
59
60                 mapInt2EnumDecl.put(origInt, enumDecl);
61         }
62
63
64         public void addStructDecl(String origInt, Declaration structDecl) {
65
66                 mapInt2StructDecl.put(origInt, structDecl);
67         }
68
69
70         /**
71          * Getters
72          */
73         public Declaration getInterfaceDecl(String origInt) {
74
75                 return mapInt2IntfaceDecl.get(origInt);
76         }
77
78
79         public Declaration getCapabilityDecl(String origInt) {
80
81                 return mapInt2CapabDecl.get(origInt);
82         }
83
84
85         public Declaration getRequiresDecl(String origInt) {
86
87                 return mapInt2ReqDecl.get(origInt);
88         }
89
90
91         public Declaration getEnumDecl(String origInt) {
92
93                 return mapInt2EnumDecl.get(origInt);
94         }
95
96
97         public Declaration getStructDecl(String origInt) {
98
99                 return mapInt2StructDecl.get(origInt);
100         }
101 }