1 13 package com.tonbeller.wcf.param; 14 15 import java.util.Collection ; 16 import java.util.Iterator ; 17 import java.util.Map ; 18 import java.util.Set ; 19 20 35 public class SqlValueMap implements Map { 36 37 private SessionParamPool pool; 38 39 SqlValueMap(SessionParamPool pool) { 40 this.pool = pool; 41 } 42 43 public int size() { 44 return pool.size(); 45 } 46 47 public void clear() { 48 pool.clear(); 49 } 50 51 public boolean isEmpty() { 52 return pool.isEmpty(); 53 } 54 55 public boolean containsKey(Object key) { 56 return pool.getParam(String.valueOf(key)) != null; 57 } 58 59 public boolean containsValue(Object value) { 60 throw new UnsupportedOperationException (); 61 } 62 63 public Collection values() { 64 throw new UnsupportedOperationException (); 65 } 66 67 public void putAll(Map t) { 68 for (Iterator it = t.entrySet().iterator(); it.hasNext();) { 69 Map.Entry e = (Entry) it.next(); 70 this.put(e.getKey(), e.getValue()); 71 } 72 } 73 74 public Set entrySet() { 75 throw new UnsupportedOperationException (); 76 } 77 78 public Set keySet() { 79 throw new UnsupportedOperationException (); 80 } 81 82 public Object get(Object key) { 83 SessionParam p = pool.getParam((String )key); 84 if (p == null) 85 return null; 86 return p.getSqlValue(); 87 } 88 89 public Object remove(Object key) { 90 SessionParam p = (SessionParam) pool.removeParam(String.valueOf(key)); 91 if (p == null) 92 return null; 93 return p.getSqlValue(); 94 } 95 96 public Object put(Object key, Object value) { 97 SessionParam p = (SessionParam) pool.getParam(String.valueOf(key)); 98 if (p == null) 99 p = new SessionParam(); 100 Object ret = p.getSqlValue(); 101 p.setName(String.valueOf(key)); 102 p.setSqlValue(value); 103 pool.setParam(p); 104 return ret; 105 } 106 107 } 108 | Popular Tags |