1 17 18 package org.apache.geronimo.transaction; 19 20 import java.util.Map ; 21 import java.util.HashMap ; 22 import java.util.Collection ; 23 24 29 public final class DoubleKeyedHashMap { 30 private final Map map = new HashMap (); 31 32 public Object put(Object key1, Object key2, Object value) { 33 return map.put(new Key(key1, key2), value); 34 } 35 36 public Object get(Object key1, Object key2) { 37 return map.get(new Key(key1, key2)); 38 } 39 40 public Object remove(Object key1, Object key2) { 41 return map.remove(new Key(key1, key2)); 42 } 43 44 public Collection values() { 45 return map.values(); 46 } 47 48 public void clear() { 49 map.clear(); 50 } 51 52 public boolean isEmpty() { 53 return map.isEmpty(); 54 } 55 56 private final static class Key { 57 private final Object part1; 58 private final Object part2; 59 60 public Key(Object part1, Object part2) { 61 this.part1 = part1; 62 this.part2 = part2; 63 } 64 65 public int hashCode() { 66 return part1.hashCode() ^ part2.hashCode(); 67 } 68 69 public boolean equals(Object obj) { 70 if (obj instanceof Key) { 71 Key other = (Key) obj; 72 return this.part1.equals(other.part1) && this.part2.equals(other.part2); 73 } else { 74 return false; 75 } 76 } 77 } 78 } 79 | Popular Tags |