1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package net.sf.sail.core.activity.model;
25
26 import java.util.Map;
27
28 import javax.script.SimpleNamespace;
29
30 public class ScopeNamespace
31 extends SimpleNamespace
32 {
33 protected ScopeNamespace parentScope;
34
35 public ScopeNamespace(ScopeNamespace parent, Map map)
36 {
37 super(map);
38 parentScope = parent;
39 }
40
41 public ScopeNamespace(ScopeNamespace parent)
42 {
43 super();
44 setParent(parent);
45 }
46
47 public ScopeNamespace(Map map)
48 {
49 super(map);
50 }
51
52 public ScopeNamespace()
53 {
54 super();
55 }
56
57 public void setParent(ScopeNamespace parent)
58 {
59 parentScope = parent;
60 }
61
62 protected Object scopeFind(Object key, Object value)
63 {
64 Object oldValue = super.get(key);
65 if (oldValue == null)
66 {
67 if (parentScope != null)
68 oldValue = parentScope.scopeFind(key, value);
69 }
70 else
71 {
72 if (value != null)
73 oldValue = super.put(key, value);
74 }
75 return oldValue;
76 }
77
78 @Override
79 public Object get(Object key)
80 {
81 return scopeFind(key, null);
82 }
83 }