01: package com.ibatis.sqlmap.engine.mapping.result;
02:
03: import com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate;
04:
05: import java.util.Map;
06: import java.util.HashMap;
07: import java.util.Iterator;
08:
09: /**
10: * Created by IntelliJ IDEA.
11: * User: cbegin
12: * Date: May 13, 2005
13: * Time: 11:11:05 PM
14: * To change this template use File | Settings | File Templates.
15: */
16: public class Discriminator {
17:
18: private SqlMapExecutorDelegate delegate;
19: private ResultMapping resultMapping;
20: private Map subMaps;
21:
22: public Discriminator(SqlMapExecutorDelegate delegate,
23: ResultMapping resultMapping) {
24: this .delegate = delegate;
25: this .resultMapping = resultMapping;
26: }
27:
28: public void setResultMapping(ResultMapping resultMapping) {
29: this .resultMapping = resultMapping;
30: }
31:
32: public ResultMapping getResultMapping() {
33: return resultMapping;
34: }
35:
36: public void addSubMap(String discriminatorValue,
37: String resultMapName) {
38: if (subMaps == null) {
39: subMaps = new HashMap();
40: }
41: subMaps.put(discriminatorValue, resultMapName);
42: }
43:
44: public ResultMap getSubMap(String s) {
45: return (ResultMap) subMaps.get(s);
46: }
47:
48: public void bindSubMaps() {
49: if (subMaps != null) {
50: Iterator keys = subMaps.keySet().iterator();
51: while (keys.hasNext()) {
52: Object key = keys.next();
53: Object id = subMaps.get(key);
54: if (id instanceof String) {
55: subMaps
56: .put(key, delegate
57: .getResultMap((String) id));
58: }
59: }
60: }
61: }
62:
63: }
|