P15GEN2\59518
2024-05-29 d4210c7c4b04abde20037ea8aa0f54ef8a2649aa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package fr.opensagres.xdocreport.template.freemarker.internal;
 
import java.util.HashMap;
import java.util.Map;
 
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
 
import foundation.dao.PackageStringMap;
import fr.opensagres.xdocreport.template.IContext;
import fr.opensagres.xdocreport.template.utils.TemplateUtils;
 
public class XDocFreemarkerContext implements IContext {
    
    protected static Logger logger;
    private Map<String, Object> contextMap;
    private Map<String, String> dataMap;
 
    static {
        logger = LogManager.getLogger(XDocFreemarkerContext.class);
    }
    
    public XDocFreemarkerContext() {
        this(new HashMap<String, Object>());
    }
 
    public XDocFreemarkerContext(Map<String, Object> contextMap) {
        this.contextMap = contextMap;
    }
 
    public Object put(String key, Object value) {
        Object result = TemplateUtils.putContextForDottedKey(this, key, value);
        
        if (result == null) {
            return this.contextMap.put(key, value);
        }
        
        return result;
    }
 
    public Object get(String key) {
        Object result = this.contextMap.get(key);
        
        if (result != null) {
            return result;
        }
        
        if (dataMap == null || key.startsWith("__")) {
            return null;
        }
        
        int pos = key.indexOf(PackageStringMap.Spliter);
        if (pos > 0) {
            result = dataMap.get(key);
        }
        
        return result;
    }
 
    public void putMap(Map<String, Object> contextMap) {
        this.contextMap.putAll(contextMap);
    }
 
    public Map<String, Object> getContextMap() {
        return this.contextMap;
    }
 
    public void setDataMap(Map<String, String> dataMap) {
        this.dataMap = dataMap;
    }
    
}