1 package iotpolicy.tree;
3 import java.util.ArrayList;
4 import java.util.HashMap;
9 /** Class RequiresDecl is a data structure for "requires"
10 * declaration section in the policy file.
11 * This section declares the needed interfaces based on
12 * different combinations of capabilities.
14 * @author Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
18 public class RequiresDecl extends Declaration {
21 * A "requires" statement:
22 * requires Camera with VideoRecording, ImageCapture as interface CameraWithCaptureAndData;
24 * In this data structure we will record its new interface name, i.e. CameraWithCaptureAndData
25 * and its required capabilities, i.e. VideoRecording and ImageCapture.
31 private Map<String,List<String>> mapRequires;
36 public RequiresDecl() {
39 mapRequires = new HashMap<String,List<String>>();
43 public RequiresDecl(String _origInt) {
46 mapRequires = new HashMap<String,List<String>>();
51 * addNewInterface() adds a new interface name into the map
53 public void addNewIntface(String newInt) {
55 mapRequires.put(newInt, new ArrayList<String>());
60 * addNewCapability() adds a new capability name into the map
62 public void addNewCapability(String intFace, String newCapab) {
64 List<String> listCapab = mapRequires.get(intFace);
65 listCapab.add(newCapab);
70 * getInterfaces() gets set of interfaces
72 public Set<String> getInterfaces() {
74 return mapRequires.keySet();
79 * getCapabList() gets list of capabilities
81 public List<String> getCapabList(String intFace) {
83 return mapRequires.get(intFace);