}
private static IDLType classToIDLType(Class c) {
IDLType idlType = null;
IDLTypesUtil idlTypesUtil = new IDLTypesUtil();
if( idlTypesUtil.isPrimitive(c) ) {
idlType = idlTypesUtil.getPrimitiveIDLTypeMapping(c);
} else if( c.isArray() ) {
// Calculate array depth, as well as base element type.
Class componentType = c.getComponentType();
int numArrayDimensions = 1;
while(componentType.isArray()) {
componentType = componentType.getComponentType();
numArrayDimensions++;
}
IDLType componentIdlType = classToIDLType(componentType);
String[] modules = BASE_IDL_ARRAY_MODULE_TYPE;
if( componentIdlType.hasModule() ) {
modules = (String[])ObjectUtility.concatenateArrays( modules,
componentIdlType.getModules() ) ;
}
String memberName = BASE_IDL_ARRAY_ELEMENT_TYPE +
numArrayDimensions + UNDERSCORE +
componentIdlType.getMemberName();
idlType = new IDLType(c, modules, memberName);
} else {
idlType = idlTypesUtil.getSpecialCaseIDLTypeMapping(c);
if (idlType == null) {
// Section 1.3.2.5 of Java2IDL spec defines mangling rules for
// inner classes.
String memberName = getUnmappedContainerName(c);
// replace inner class separator with double underscore
memberName = memberName.replaceAll("\\$",
INNER_CLASS_SEPARATOR);
if( hasLeadingUnderscore(memberName) ) {
memberName = mangleLeadingUnderscore(memberName);
}
// Get raw package name. If there is a package, it
// will still have the "." separators and none of the
// mangling rules will have been applied.
String packageName = getPackageName(c);
if (packageName == null) {
idlType = new IDLType( c, memberName ) ;
} else {
// If this is a generated IDL Entity Type we need to
// prepend org_omg_boxedIDL per sections 1.3.5 and 1.3.9
if (idlTypesUtil.isEntity(c)) {
packageName = "org.omg.boxedIDL." + packageName ;
}
// Section 1.3.2.1 and 1.3.2.6 of Java2IDL spec defines
// rules for mapping java packages to IDL modules and for
// mangling module name portion of type name. NOTE that
// of the individual identifier mangling rules,
// only the leading underscore test is done here.
// The other two(IDL Keyword, Illegal Unicode chars) are
// done in mangleOverloadedMethodName.
StringTokenizer tokenizer =
new StringTokenizer(packageName, ".");
String[] modules = new String[ tokenizer.countTokens() ] ;
int index = 0 ;
while (tokenizer.hasMoreElements()) {
String next = tokenizer.nextToken();
String moreMangled = hasLeadingUnderscore( next ) ?
mangleLeadingUnderscore( next ) : next;
modules[index++] = moreMangled ;
}
idlType = new IDLType(c, modules, memberName);
}
}
}
return idlType;