1 18 19 package org.apache.beehive.controls.system.jdbc; 20 21 import java.sql.ResultSet ; 22 import java.sql.ResultSetMetaData ; 23 import java.sql.SQLException ; 24 import java.util.HashMap ; 25 26 37 public class ResultSetHashMap extends HashMap <String , Object > { 38 39 ResultSetHashMap() { 40 super(); 41 } 42 43 ResultSetHashMap(int size) { 44 super(size); 45 } 46 47 51 ResultSetHashMap(ResultSet rs, String [] keys) throws SQLException { 52 super(); 53 assert keys.length == rs.getMetaData().getColumnCount() + 1; 54 55 for (int i = 1; i < keys.length; i++) { 56 assert keys[i].equals(keys[i].toUpperCase()); 57 super.put(keys[i], rs.getObject(i)); 58 } 59 } 60 61 62 ResultSetHashMap(ResultSet rs) throws SQLException { 63 super(); 64 ResultSetMetaData md = rs.getMetaData(); 65 for (int i = 1; i <= md.getColumnCount(); i++) { 66 super.put(md.getColumnName(i).toUpperCase(), rs.getObject(i)); 67 } 68 } 69 70 71 public boolean containsKey(String key) { 72 return super.containsKey(key.toUpperCase()); 73 } 74 75 76 public Object get(String key) { 77 return super.get(key.toUpperCase()); 78 } 79 80 81 public Object put(String key, Object value) { 82 return super.put(key.toUpperCase(), value); 83 } 84 85 86 public Object remove(String key) { 87 return super.remove(key.toUpperCase()); 88 } 89 } 90 91 | Popular Tags |