01: /*
02: * @(#)IdentityHashtable.java 1.5 03/01/23
03: *
04: * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
05: * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
06: */
07: package org.conform.mdl;
08:
09: import java.util.*;
10:
11: /*
12: * @version 1.5 01/23/03
13: * @author Philip Milne
14: */
15:
16: class IdentityHashtable extends HashMap {
17: // private InstanceWrapper hashtableNull = new InstanceWrapper();
18:
19: private class InstanceWrapper {
20: public Object o;
21:
22: public InstanceWrapper(Object o) {
23: this .o = o;
24: }
25:
26: public boolean equals(Object o2) {
27: return (o2.getClass() == InstanceWrapper.class)
28: && (o == ((InstanceWrapper) o2).o);
29: }
30:
31: public int hashCode() {
32: return System.identityHashCode(o);
33: }
34: }
35:
36: public Object put(Object key, Object value) {
37: return super .put(new InstanceWrapper(key), value);
38: }
39:
40: public Object get(Object key) {
41: return super .get(new InstanceWrapper(key));
42: }
43:
44: public Object remove(Object key) {
45: return super .remove(new InstanceWrapper(key));
46: }
47: }
|