01: package com.openedit.util;
02:
03: import java.util.Map;
04:
05: /**
06: * Copied from AbstractMap
07: * @author cburkey
08: * @date Feb 6, 2003
09: */
10: public class SimpleEntry implements Map.Entry {
11: Object key;
12: Object value;
13:
14: public SimpleEntry(Object key, Object value) {
15: this .key = key;
16: this .value = value;
17: }
18:
19: public SimpleEntry(Map.Entry e) {
20: this .key = e.getKey();
21: this .value = e.getValue();
22: }
23:
24: public Object getKey() {
25: return key;
26: }
27:
28: public Object getValue() {
29: return value;
30: }
31:
32: public Object setValue(Object value) {
33: Object oldValue = this .value;
34: this .value = value;
35: return oldValue;
36: }
37:
38: public boolean equals(Object o) {
39: if (!(o instanceof Map.Entry))
40: return false;
41: Map.Entry e = (Map.Entry) o;
42: return eq(key, e.getKey()) && eq(value, e.getValue());
43: }
44:
45: public int hashCode() {
46: Object v;
47: return ((key == null) ? 0 : key.hashCode())
48: ^ ((value == null) ? 0 : value.hashCode());
49: }
50:
51: public String toString() {
52: return key + "=" + value;
53: }
54:
55: private static boolean eq(Object o1, Object o2) {
56: return (o1 == null ? o2 == null : o1.equals(o2));
57: }
58: }
|