|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.hivemind.impl; |
|
16 |
| |
|
17 |
| import java.util.HashMap; |
|
18 |
| import java.util.Map; |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| public class JavaTypeUtils |
|
28 |
| { |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| private static Map PRIMITIVE_TYPE_CODES = new HashMap(); |
|
34 |
| |
|
35 |
| static |
|
36 |
| { |
|
37 |
1
| PRIMITIVE_TYPE_CODES.put("boolean", "Z");
|
|
38 |
1
| PRIMITIVE_TYPE_CODES.put("short", "S");
|
|
39 |
1
| PRIMITIVE_TYPE_CODES.put("int", "I");
|
|
40 |
1
| PRIMITIVE_TYPE_CODES.put("long", "J");
|
|
41 |
1
| PRIMITIVE_TYPE_CODES.put("float", "F");
|
|
42 |
1
| PRIMITIVE_TYPE_CODES.put("double", "D");
|
|
43 |
1
| PRIMITIVE_TYPE_CODES.put("char", "C");
|
|
44 |
1
| PRIMITIVE_TYPE_CODES.put("byte", "B");
|
|
45 |
| } |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| private static final Map PRIMITIVE_CLASSES = new HashMap(); |
|
51 |
| |
|
52 |
| static |
|
53 |
| { |
|
54 |
1
| PRIMITIVE_CLASSES.put("boolean", boolean.class);
|
|
55 |
1
| PRIMITIVE_CLASSES.put("short", short.class);
|
|
56 |
1
| PRIMITIVE_CLASSES.put("char", char.class);
|
|
57 |
1
| PRIMITIVE_CLASSES.put("byte", byte.class);
|
|
58 |
1
| PRIMITIVE_CLASSES.put("int", int.class);
|
|
59 |
1
| PRIMITIVE_CLASSES.put("long", long.class);
|
|
60 |
1
| PRIMITIVE_CLASSES.put("float", float.class);
|
|
61 |
1
| PRIMITIVE_CLASSES.put("double", double.class);
|
|
62 |
| } |
|
63 |
| |
|
64 |
0
| private JavaTypeUtils()
|
|
65 |
| { |
|
66 |
| |
|
67 |
| } |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
8709
| public static String getJVMClassName(String type)
|
|
75 |
| { |
|
76 |
| |
|
77 |
8709
| if (!type.endsWith("[]"))
|
|
78 |
8701
| return type;
|
|
79 |
| |
|
80 |
| |
|
81 |
8
| StringBuffer buffer = new StringBuffer();
|
|
82 |
| |
|
83 |
8
| while (type.endsWith("[]"))
|
|
84 |
| { |
|
85 |
12
| buffer.append("[");
|
|
86 |
12
| type = type.substring(0, type.length() - 2);
|
|
87 |
| } |
|
88 |
| |
|
89 |
8
| String primitiveIdentifier = (String) PRIMITIVE_TYPE_CODES.get(type);
|
|
90 |
8
| if (primitiveIdentifier != null)
|
|
91 |
4
| buffer.append(primitiveIdentifier);
|
|
92 |
| else |
|
93 |
| { |
|
94 |
4
| buffer.append("L");
|
|
95 |
4
| buffer.append(type);
|
|
96 |
4
| buffer.append(";");
|
|
97 |
| } |
|
98 |
| |
|
99 |
8
| return buffer.toString();
|
|
100 |
| } |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
| |
|
105 |
| |
|
106 |
| |
|
107 |
| |
|
108 |
| |
|
109 |
| |
|
110 |
8707
| public static Class getPrimtiveClass(String type)
|
|
111 |
| { |
|
112 |
8707
| return (Class) PRIMITIVE_CLASSES.get(type);
|
|
113 |
| } |
|
114 |
| } |