01: package tijmp.ui;
02:
03: /** A class that can turn a class name into human readable format.
04: */
05: public class Translator {
06: public static String translate(Class<?> c) {
07: if (c.isPrimitive()) {
08: if (c == Boolean.TYPE)
09: return "boolean";
10: if (c == Character.TYPE)
11: return "char";
12: if (c == Byte.TYPE)
13: return "byte";
14: if (c == Short.TYPE)
15: return "short";
16: if (c == Integer.TYPE)
17: return "int";
18: if (c == Long.TYPE)
19: return "long";
20: if (c == Float.TYPE)
21: return "float";
22: if (c == Double.TYPE)
23: return "double";
24: if (c == Void.TYPE)
25: return "void";
26: }
27: if (c.isArray()) {
28: Class<?> comp = c.getComponentType();
29: return translate(comp) + "[]";
30: }
31: return c.getName();
32: }
33: }
|