1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43:
44: import ;
45: import ;
46: import ;
47:
48:
54: public class TypeKindNamer
55: {
56:
59: protected static final String[] tk =
60: new String[]
61: {
62: "null", "void", "short", "long", "ushort", "ulong", "float", "double",
63: "boolean", "char", "octet", "any", "TypeCode", "Principal", "objref",
64: "struct", "union", "enum", "string", "sequence", "array", "alias",
65: "exception", "longlong", "ulonglong", "longdouble", "wchar", "wstring",
66: "fixed", "value", "value_box", "native", "abstract_interface"
67: };
68:
69:
72: protected static final TypeCode[] primitveCodes =
73: new TypeCode[]
74: {
75: new PrimitiveTypeCode(TCKind.tk_null),
76: new PrimitiveTypeCode(TCKind.tk_void),
77: new PrimitiveTypeCode(TCKind.tk_short),
78: new PrimitiveTypeCode(TCKind.tk_long),
79: new PrimitiveTypeCode(TCKind.tk_ushort),
80: new PrimitiveTypeCode(TCKind.tk_ulong),
81: new PrimitiveTypeCode(TCKind.tk_float),
82: new PrimitiveTypeCode(TCKind.tk_double),
83: new PrimitiveTypeCode(TCKind.tk_boolean),
84: new PrimitiveTypeCode(TCKind.tk_char),
85: new PrimitiveTypeCode(TCKind.tk_octet),
86: new PrimitiveTypeCode(TCKind.tk_any),
87: new PrimitiveTypeCode(TCKind.tk_TypeCode),
88: new PrimitiveTypeCode(TCKind.tk_Principal),
89: new RecordTypeCode(TCKind.tk_objref),
90: new PrimitiveTypeCode(TCKind.tk_struct),
91: new PrimitiveTypeCode(TCKind.tk_union),
92: new PrimitiveTypeCode(TCKind.tk_enum),
93: new PrimitiveTypeCode(TCKind.tk_string),
94: new PrimitiveTypeCode(TCKind.tk_sequence),
95: new PrimitiveTypeCode(TCKind.tk_array),
96: new PrimitiveTypeCode(TCKind.tk_alias),
97: new PrimitiveTypeCode(TCKind.tk_except),
98: new PrimitiveTypeCode(TCKind.tk_longlong),
99: new PrimitiveTypeCode(TCKind.tk_ulonglong),
100: new PrimitiveTypeCode(TCKind.tk_longdouble),
101: new PrimitiveTypeCode(TCKind.tk_wchar),
102: new PrimitiveTypeCode(TCKind.tk_wstring),
103: new PrimitiveTypeCode(TCKind.tk_fixed),
104: new PrimitiveTypeCode(TCKind.tk_value),
105: new PrimitiveTypeCode(TCKind.tk_value_box),
106: new PrimitiveTypeCode(TCKind.tk_native),
107: new PrimitiveTypeCode(TCKind.tk_abstract_interface)
108: };
109:
110: static
111: {
112:
113: RecordTypeCode object =
114: (RecordTypeCode) primitveCodes [ TCKind._tk_objref ];
115: object.setId("");
116: object.setName("Object");
117: }
118:
119:
126: public static TypeCode getPrimitveTC(TCKind tc)
127: throws BadKind
128: {
129: try
130: {
131: return primitveCodes [ tc.value() ];
132: }
133: catch (ArrayIndexOutOfBoundsException ex)
134: {
135: throw new BadKind(tc.value() + " is not a primitve type.");
136: }
137: }
138:
139:
147: public static String nameIt(int kind)
148: {
149: try
150: {
151: return tk [ kind ];
152: }
153: catch (ArrayIndexOutOfBoundsException ex)
154: {
155: return "type of kind '" + kind + "'";
156: }
157: }
158:
159:
167: public static String nameIt(TypeCode type)
168: {
169: try
170: {
171: if (type.kind().value() == TCKind._tk_array)
172: return "array of " + nameIt(type.content_type());
173: else if (type.kind().value() == TCKind._tk_sequence)
174: return "sequence of " + nameIt(type.content_type());
175: else
176: return nameIt(type.kind().value());
177: }
178: catch (Exception ex)
179: {
180: return "type of kind '" + type.kind().value() + "'";
181: }
182: }
183: }