01: /*
02: * An predefined implementation of InterfaceMap.
03: *
04: * @see U2.T2.InterfaceMap
05: */
06:
07: package U2.T2;
08:
09: import java.util.*;
10: import java.lang.reflect.*;
11:
12: public class InterfaceMap0 extends InterfaceMap {
13:
14: HashMap<Class, Class> map;
15:
16: /**
17: * Creating an empty interface map.
18: */
19: public InterfaceMap0() {
20: map = new HashMap<Class, Class>();
21:
22: try {
23: map.put(Class.forName("java.lang.Comparable"), Class
24: .forName("java.lang.Integer"));
25: } catch (Exception e) {
26: }
27:
28: try {
29: map.put(Class.forName("java.util.Collection"), Class
30: .forName("java.util.LinkedList"));
31: } catch (Exception e) {
32: }
33:
34: try {
35: map.put(Class.forName("java.util.List"), Class
36: .forName("java.util.LinkedList"));
37: } catch (Exception e) {
38: }
39:
40: try {
41: map.put(Class.forName("java.util.Queue"), Class
42: .forName("java.util.LinkedList"));
43: } catch (Exception e) {
44: }
45:
46: try {
47: map.put(Class.forName("java.util.Set"), Class
48: .forName("java.util.HashSet"));
49: } catch (Exception e) {
50: }
51:
52: try {
53: map.put(Class.forName("java.util.Map"), Class
54: .forName("java.util.HashMap"));
55: } catch (Exception e) {
56: }
57:
58: }
59:
60: /**
61: * Obtain an implementaiton of an interface I. Return null if it
62: * can't find I or an implementation of it in the interface map.
63: */
64: public Class getImplementation(Class I) {
65: return map.get(I);
66: }
67:
68: }
|