01: package spoon.jdiet.rt;
02:
03: /**
04: * An implementation of the Map.Entry interface. This class is used by the code
05: * produced by the J2MEConverter processor as a replacement for Map.Entry which
06: * is not available with J2ME.
07: *
08: * @author Lionel Seinturier <Lionel.Seinturier@lifl.fr>
09: */
10: public class MapEntryImpl {
11:
12: private Object key;
13: private Object value;
14:
15: public MapEntryImpl(Object key, Object value) {
16: this .key = key;
17: this .value = value;
18: }
19:
20: public Object getKey() {
21: return key;
22: }
23:
24: public Object getValue() {
25: return value;
26: }
27:
28: public Object setValue(Object value) {
29: /*
30: * Map.Entry.setValue() writes back values to the Map.
31: * The operation is not supported as we can not implement this behavior
32: * with Enumeration and Hashtable.
33: *
34: * Do not use UnsupportedOperationException (not in the J2ME API.)
35: */
36: throw new RuntimeException(
37: "Method MapEntryImpl.setValue(Object) not supported");
38: }
39:
40: public boolean equals(Object o) {
41: if (!(o instanceof MapEntryImpl)) {
42: return false;
43: }
44: MapEntryImpl e2 = (MapEntryImpl) o;
45: return (key == null ? e2.getKey() == null : key.equals(e2
46: .getKey()))
47: && (value == null ? e2.getValue() == null : value
48: .equals(e2.getValue()));
49:
50: }
51:
52: public int hashCode() {
53: return (key == null ? 0 : key.hashCode())
54: ^ (value == null ? 0 : value.hashCode());
55: }
56:
57: }
|