1 | package org.etsi.t3q.visitor; |
---|
2 | |
---|
3 | import java.util.ArrayList; |
---|
4 | import java.util.HashMap; |
---|
5 | import java.util.Iterator; |
---|
6 | |
---|
7 | import de.ugoe.cs.swe.trex.core.analyzer.rfparser.TTCN3ParserTokenTypes; |
---|
8 | |
---|
9 | public abstract class AbstractModuleContentsChecker { |
---|
10 | |
---|
11 | private HashMap<String, ArrayList<Integer>> permissibleModuleContentsMap; |
---|
12 | |
---|
13 | public AbstractModuleContentsChecker() { |
---|
14 | this.permissibleModuleContentsMap = new HashMap<String, ArrayList<Integer>>(); |
---|
15 | } |
---|
16 | |
---|
17 | protected void addPermissibleListForModuleID(String moduleIDSubstring, |
---|
18 | ArrayList<Integer> permissibleTypesList) { |
---|
19 | this.permissibleModuleContentsMap.put(moduleIDSubstring, |
---|
20 | permissibleTypesList); |
---|
21 | } |
---|
22 | |
---|
23 | public boolean typePermittedInRestrictedModule(String moduleRestriction, Integer type){ |
---|
24 | boolean permitted = false; |
---|
25 | if (this.permissibleModuleContentsMap.get(moduleRestriction).contains(type) || (type == TTCN3ParserTokenTypes.ImportDef)){ |
---|
26 | permitted = true; |
---|
27 | } |
---|
28 | return permitted; |
---|
29 | } |
---|
30 | |
---|
31 | public String checkModuleIDForRestrictions(String moduleID){ |
---|
32 | String moduleRestriction = null; |
---|
33 | Iterator<String> moduleRestrictionIterator = this.permissibleModuleContentsMap.keySet().iterator(); |
---|
34 | while (moduleRestrictionIterator.hasNext()){ |
---|
35 | String moduleRestrictionEntry = moduleRestrictionIterator.next(); |
---|
36 | if (moduleID.contains(moduleRestrictionEntry)){ |
---|
37 | if (moduleRestriction!=null){ |
---|
38 | //TODO: throw a warning that multiple restrictions are used |
---|
39 | } |
---|
40 | moduleRestriction = moduleRestrictionEntry; |
---|
41 | } |
---|
42 | } |
---|
43 | return moduleRestriction; |
---|
44 | } |
---|
45 | } |
---|