1 package iotpolicy.tree;
3 import java.util.ArrayList;
4 import java.util.HashMap;
10 /** Class EnumDecl is a data structure for enumeration
11 * declaration section in the policy file.
13 * @author Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
17 public class EnumDecl extends Declaration {
20 * A "enum" declaration:
27 * In this data structure we will record its enum name, i.e. Enum
34 // Members of enum (can be more than 1 declaration
35 private Map<String, List<String>> mapEnumMembers;
43 mapEnumMembers = new HashMap<String, List<String>>();
47 public EnumDecl(String _origInt) {
50 mapEnumMembers = new HashMap<String, List<String>>();
55 * addNewMember() adds a new member into the list, e.g. MELON into the list of APPLE, ORANGE, and GRAPE
57 public void addNewMember(String enumType, String newMember) {
59 if (mapEnumMembers.containsKey(enumType)) {
60 // Existing enum declaration
61 List<String> memberList = mapEnumMembers.get(enumType);
62 memberList.add(newMember);
65 List<String> newMemberList = new ArrayList<String>();
66 newMemberList.add(enumType);
67 mapEnumMembers.put(enumType, newMemberList);
73 * getEnumDeclarations() gets list of enum declarations
75 public Set<String> getEnumDeclarations() {
77 return mapEnumMembers.keySet();
82 * getMembers() gets list of enum members
84 public List<String> getMembers(String enumType) {
86 return mapEnumMembers.get(enumType);