1 | package de.uka.ipd.sdq.simucomframework.variables.userdata; |
2 | |
3 | import java.util.ArrayList; |
4 | import java.util.List; |
5 | |
6 | import org.apache.log4j.Logger; |
7 | |
8 | import de.uka.ipd.sdq.simucomframework.variables.stackframe.SimulatedStackframe; |
9 | |
10 | |
11 | public class UserData { |
12 | |
13 | List<UserDataEntry> userData = new ArrayList<UserDataEntry>(); |
14 | |
15 | private static Logger logger = |
16 | Logger.getLogger(SimulatedStackframe.class.getName()); |
17 | |
18 | public UserData(){ |
19 | |
20 | } |
21 | |
22 | public void addUserData(String variableName, String assemblyContextID, Object value){ |
23 | userData.add(new UserDataEntry(variableName, assemblyContextID, value)); |
24 | } |
25 | |
26 | public void overwriteParametersForAssemblyContext(String assemblyContext, SimulatedStackframe<Object> currentStackframe){ |
27 | |
28 | for (UserDataEntry userDataEntry : userData) { |
29 | if (assemblyContext.equals(userDataEntry.getAssemblyContextID())){ |
30 | currentStackframe.addValue(userDataEntry.getVariableName(), userDataEntry.getValue()); |
31 | logger.info("Storing variable "+userDataEntry.getVariableName()+" for AssemblyContext "+userDataEntry.getAssemblyContextID()); |
32 | } |
33 | } |
34 | |
35 | |
36 | } |
37 | |
38 | |
39 | } |
40 | |
41 | class UserDataEntry { |
42 | |
43 | private String variableName; |
44 | private String assemblyContextID; |
45 | |
46 | private Object value; |
47 | |
48 | public UserDataEntry(String assemblyContextID, String variableName, |
49 | Object value) { |
50 | super(); |
51 | this.variableName = variableName; |
52 | this.assemblyContextID = assemblyContextID; |
53 | this.value = value; |
54 | } |
55 | |
56 | public String getVariableName() { |
57 | return variableName; |
58 | } |
59 | |
60 | public String getAssemblyContextID() { |
61 | return assemblyContextID; |
62 | } |
63 | |
64 | public Object getValue() { |
65 | return value; |
66 | } |
67 | |
68 | } |