1 package com.ibatis.sqlmap.engine.mapping.result; 2 3 import com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate; 4 5 import java.util.Map ; 6 import java.util.HashMap ; 7 import java.util.Iterator ; 8 9 16 public class Discriminator { 17 18 private SqlMapExecutorDelegate delegate; 19 private ResultMapping resultMapping; 20 private Map subMaps; 21 22 public Discriminator(SqlMapExecutorDelegate delegate, ResultMapping resultMapping) { 23 this.delegate = delegate; 24 this.resultMapping = resultMapping; 25 } 26 27 public void setResultMapping(ResultMapping resultMapping) { 28 this.resultMapping = resultMapping; 29 } 30 31 public ResultMapping getResultMapping() { 32 return resultMapping; 33 } 34 35 public void addSubMap(String discriminatorValue, String resultMapName) { 36 if (subMaps == null) { 37 subMaps = new HashMap (); 38 } 39 subMaps.put(discriminatorValue, resultMapName); 40 } 41 42 public ResultMap getSubMap(String s) { 43 return (ResultMap) subMaps.get(s); 44 } 45 46 public void bindSubMaps() { 47 if (subMaps != null) { 48 Iterator keys = subMaps.keySet().iterator(); 49 while (keys.hasNext()) { 50 Object key = keys.next(); 51 Object id = subMaps.get(key); 52 if(id instanceof String ) { 53 subMaps.put(key, delegate.getResultMap((String )id)); 54 } 55 } 56 } 57 } 58 59 } 60 | Popular Tags |