1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.gwe.p2elv2;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.gwe.drivers.fileSystems.staging.FilesStager;
23 import org.gwe.p2elv2.model.PVariable;
24 import org.gwe.utils.security.KeyStore;
25
26
27
28
29
30 public class PStatementContext {
31
32 private ContextVariables systemVars = new ContextVariables(PVariable.SYS_VAR_PREFIX);
33 private ContextVariables runtimeVars = new ContextVariables(PVariable.RUN_VAR_PREFIX);
34
35 private String workspace;
36 private KeyStore keys;
37 private FilesStager stager;
38
39 public PStatementContext(String workspace, KeyStore keys, FilesStager stager) {
40 this.workspace = workspace;
41 this.keys = keys;
42 this.stager = stager;
43 }
44
45 public void addSystemVar(String name, String value) {
46 systemVars.addVar(name, value);
47 }
48
49 public void addRuntimeVar(String name, String value) {
50 runtimeVars.addVar(name, value);
51 }
52
53 public Map<String, String> getSystemVars() {
54 return systemVars;
55 }
56
57 public Map<String, String> getRuntimeVars() {
58 return runtimeVars;
59 }
60
61 public String getWorkspace() {
62 return workspace;
63 }
64
65 public KeyStore getKeys() {
66 return keys;
67 }
68
69 public FilesStager getStager() {
70 return stager;
71 }
72 }
73
74 class ContextVariables extends HashMap<String, String> {
75
76 private String prefix;
77
78 public ContextVariables(String prefix) {
79 this.prefix = prefix + "_";
80 }
81
82 public void addVar(String name, String value) {
83 put(prefix + name, value);
84 }
85 }
86