01: package org.drools.base;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05: import java.util.Map.Entry;
06:
07: import org.drools.spi.GlobalResolver;
08:
09: public class MapGlobalResolver implements GlobalResolver {
10:
11: private static final long serialVersionUID = 400L;
12:
13: private final Map map;
14:
15: public MapGlobalResolver() {
16: this .map = new HashMap();
17: }
18:
19: public MapGlobalResolver(Map map) {
20: this .map = map;
21: }
22:
23: public Object resolveGlobal(String identifier) {
24: return this .map.get(identifier);
25: }
26:
27: public void setGlobal(String identifier, Object value) {
28: this .map.put(identifier, value);
29: }
30:
31: public Entry[] getGlobals() {
32: return (Entry[]) this .map.entrySet().toArray(
33: new Entry[this.map.size()]);
34: }
35:
36: }
|