/** * Utility method for insert_Value and Util.writeAny. * * <p>The ORB passed in should have the desired ORBVersion. It is used to generate the type codes. */ public TypeCode createTypeCodeForClass(java.lang.Class c, ORB tcORB) { // Look in the cache first TypeCodeImpl classTC = tcORB.getTypeCodeForClass(c); if (classTC != null) return classTC; // All cases need to be able to create repository IDs. // // See bug 4391648 for more info about the tcORB in this // case. RepositoryIdStrings repStrs = RepositoryIdFactory.getRepIdStringsFactory(); // Assertion: c instanceof Serializable? if (c.isArray()) { // Arrays - may recurse for multi-dimensional arrays Class componentClass = c.getComponentType(); TypeCode embeddedType; if (componentClass.isPrimitive()) { embeddedType = getPrimitiveTypeCodeForClass(componentClass, tcORB); } else { embeddedType = createTypeCodeForClass(componentClass, tcORB); } TypeCode t = tcORB.create_sequence_tc(0, embeddedType); String id = repStrs.createForJavaType(c); return tcORB.create_value_box_tc(id, "Sequence", t); } else if (c == java.lang.String.class) { // Strings TypeCode t = tcORB.create_string_tc(0); String id = repStrs.createForJavaType(c); return tcORB.create_value_box_tc(id, "StringValue", t); } // Anything else // We know that this is a TypeCodeImpl since it is our ORB classTC = (TypeCodeImpl) ValueUtility.createTypeCodeForClass(tcORB, c, ORBUtility.createValueHandler()); // Intruct classTC to store its buffer classTC.setCaching(true); // Update the cache tcORB.setTypeCodeForClass(c, classTC); return classTC; }
/* */ public TypeCode createTypeCodeForClass(Class paramClass, ORB paramORB) /* */ { /* 1212 */ TypeCodeImpl localTypeCodeImpl = paramORB.getTypeCodeForClass(paramClass); /* 1213 */ if (localTypeCodeImpl != null) { /* 1214 */ return localTypeCodeImpl; /* */ } /* */ /* 1220 */ RepositoryIdStrings localRepositoryIdStrings = RepositoryIdFactory.getRepIdStringsFactory(); /* */ java.lang.Object localObject1; /* */ java.lang.Object localObject2; /* 1226 */ if (paramClass.isArray()) /* */ { /* 1228 */ localObject1 = paramClass.getComponentType(); /* */ /* 1230 */ if (((Class) localObject1).isPrimitive()) { /* 1231 */ localObject2 = getPrimitiveTypeCodeForClass((Class) localObject1, paramORB); /* */ } /* */ else { /* 1234 */ localObject2 = createTypeCodeForClass((Class) localObject1, paramORB); /* */ } /* */ /* 1237 */ TypeCode localTypeCode = paramORB.create_sequence_tc(0, (TypeCode) localObject2); /* */ /* 1239 */ String str = localRepositoryIdStrings.createForJavaType(paramClass); /* */ /* 1241 */ return paramORB.create_value_box_tc(str, "Sequence", localTypeCode); /* 1242 */ } if (paramClass == String.class) /* */ { /* 1244 */ localObject1 = paramORB.create_string_tc(0); /* */ /* 1246 */ localObject2 = localRepositoryIdStrings.createForJavaType(paramClass); /* */ /* 1248 */ return paramORB.create_value_box_tc( (String) localObject2, "StringValue", (TypeCode) localObject1); /* */ } /* */ /* 1253 */ localTypeCodeImpl = (TypeCodeImpl) ValueUtility.createTypeCodeForClass( paramORB, paramClass, ORBUtility.createValueHandler()); /* */ /* 1256 */ localTypeCodeImpl.setCaching(true); /* */ /* 1258 */ paramORB.setTypeCodeForClass(paramClass, localTypeCodeImpl); /* 1259 */ return localTypeCodeImpl; /* */ }