1 ackage util;
16
17 public final class typeDesc {
23
24 public static String charToType( char ch ) {
25 String typeName;
26
27 typeName = "badType";
28
29 switch (ch) {
30 case 'B':
31 typeName = "byte";
32 break;
33 case 'C':
34 typeName = "char";
35 break;
36 case 'D':
37 typeName = "double";
38 break;
39 case 'F':
40 typeName = "float";
41 break;
42 case 'I':
43 typeName = "int";
44 break;
45 case 'J':
46 typeName = "long";
47 break;
48 case 'S':
49 typeName = "short";
50 break;
51 case 'Z':
52 typeName = "boolean";
53 break;
54 }
56 return typeName;
57 }
59
60 public static boolean isTypeChar( char tChar ) {
61 return (tChar == 'B' ||
62 tChar == 'C' ||
63 tChar == 'D' ||
64 tChar == 'F' ||
65 tChar == 'I' ||
66 tChar == 'J' ||
67 tChar == 'S' ||
68 tChar == 'Z');
69 }
71
72 public static String decodeFieldDesc( String descStr ) {
81 String typeStr = null;
82
83 if (descStr != null) {
84 int dimCnt, charIx;
85 char typeChar;
86
87 for (dimCnt = 0; descStr.charAt( dimCnt ) == '['; dimCnt++)
89 ;
90
91 charIx = dimCnt;
92 typeChar = descStr.charAt(charIx);
93 if (typeChar == 'L') { String objName;
95
96 charIx++; objName = descStr.substring( charIx );
98 typeStr = objNameFormat.toDotSeparator( objName );
100 }
101 else if (typeDesc.isTypeChar( typeChar )) {
102 typeStr = typeDesc.charToType( typeChar );
103 }
104 for (int i = 0; i < dimCnt; i++) {
106 typeStr = typeStr + "[]";
107 }
108 }
109
110 return typeStr;
111 }
113
114 }