IT-KIMI_SHI\SINOIT.KIMI
2018-06-01 521993214708c66a5498bd669c94a661c11484b2
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
package frame.persist;
 
import java.util.HashMap;
import java.util.Map;
 
import frame.util.Util;
 
public class NamedSQLContainer {
 
    private static NamedSQLContainer instance;
    private Map<String, Map<String, NamedSQL>> contionalSQLMap;
    
    
    private NamedSQLContainer() {
        contionalSQLMap = new HashMap<String, Map<String, NamedSQL>>();
    }
    
    public synchronized static NamedSQLContainer getInstance() {
        if (instance == null) {
            instance = new NamedSQLContainer();
        }
        
        return instance;
    }
    
    public NamedSQL get(String name, String condtion) {
        if (name == null) {
            return null;
        }
        
        if (Util.isEmptyStr(condtion)) {
            condtion = "empty";
        }
        
        Map<String, NamedSQL> sqlmap = contionalSQLMap.get(condtion.toLowerCase());
        if(sqlmap == null){
            return null;
        }
        return sqlmap.get(name.toLowerCase());
    }
    
    public void append(NamedSQL namedSQL, String condition) {
        if (namedSQL == null) {
            return;
        }
        
        //1.
        String name = namedSQL.getName();
        if (name == null) {
            return;
        }
        
        //2.
        if (Util.isEmptyStr(condition)) {
            condition = "empty";
        }
        condition = condition.toLowerCase();
        
        //3.
        Map<String, NamedSQL> sqlmap = contionalSQLMap.get(condition);
 
        if (sqlmap == null) {
            sqlmap = new HashMap<String, NamedSQL>();
            contionalSQLMap.put(condition, sqlmap);
        }
        
        //4.
        sqlmap.put(name.toLowerCase(), namedSQL);
    }
 
}