1 package org.apache.ojb.broker.util; 2 3 17 18 import java.util.Hashtable ; 19 20 28 public class DoubleHashtable 29 { 30 33 private Hashtable keyTable; 34 35 38 private Hashtable valueTable; 39 40 43 public DoubleHashtable() 44 { 45 keyTable = new Hashtable (); 46 valueTable = new Hashtable (); 47 } 48 49 54 public void put(Object key, Object value) 55 { 56 keyTable.put(key, value); 57 valueTable.put(value, key); 58 } 59 60 65 public Object getValueByKey(Object key) 66 { 67 return keyTable.get(key); 68 } 69 70 75 public Object getKeyByValue(Object value) 76 { 77 return valueTable.get(value); 78 } 79 80 84 public void removeByKey(Object key) 85 { 86 Object value = keyTable.remove(key); 87 if (value != null) 88 { 89 valueTable.remove(value); 90 } 91 } 92 93 97 public void removeByValue(Object value) 98 { 99 Object key = valueTable.remove(value); 100 if (key != null) 101 { 102 keyTable.remove(key); 103 } 104 } 105 106 } 107 | Popular Tags |