/** * Return an IDLNameTranslator for the given interface. * * @throws IllegalStateException * if given class is not a valid RMI/IIOP Remote Interface */ public static IDLNameTranslator get(Class<?> interf) { return new IDLNameTranslatorImpl(new Class<?>[]{interf}); }
private static String getMappedContainerName(Class<?> c) { String unmappedName = getUnmappedContainerName(c); return mangleIdentifier(unmappedName); }
private static String mangleIdentifier(String identifier, boolean attribute) { String mangledName = identifier; // Apply leading underscore test (1.3.2.3) // This should be done before IDL Keyword clash test, since clashing IDL keywords are mangled by adding a // leading underscore. if (hasLeadingUnderscore(mangledName)) { mangledName = mangleLeadingUnderscore(mangledName); } // Apply IDL keyword clash test (1.3.2.2). // This is not needed for attributes since when the full property name is composed it cannot clash with an IDL // keyword. (Also, rmic doesn't do it.) if (!attribute && isIDLKeyword(mangledName)) { mangledName = mangleIDLKeywordClash(mangledName); } // Replace illegal IDL identifier characters (1.3.2.4) for all method names and attributes. if (!isIDLIdentifier(mangledName)) { mangledName = mangleUnicodeChars(mangledName); } return mangledName; }
&& outer.originalName.equalsIgnoreCase(inner.originalName)) outer.mangledName = mangleCaseSensitiveCollision(outer.originalName); break; next.mangledName = mangleIdentifier(next.mangledName, next.isProperty); outer.mangledName = mangleOverloadedMethod(outer.mangledName, outer.method); break; String mappedContainerName = getMappedContainerName(interf); for (Iterator<IDLMethodInfo> iter = allMethodInfo.values().iterator(); iter.hasNext();) if (!next.isProperty && identifierClashesWithContainer(mappedContainerName, next.mangledName)) next.mangledName = mangleContainerClash(next.mangledName);
numArrayDimensions++; IDLType componentIdlType = classToIDLType(componentType); String memberName = getUnmappedContainerName(c); if (hasLeadingUnderscore(memberName)) memberName = mangleLeadingUnderscore(memberName); String packageName = getPackageName(c); String moreMangled = hasLeadingUnderscore(next) ? mangleLeadingUnderscore(next) : next;
IDLType idlType = classToIDLType(nextParamType); && (idlTypesUtil.getSpecialCaseIDLTypeMapping(nextParamType) == null) && isIDLKeyword(typeName)) typeName = mangleIDLKeywordClash(typeName); typeName = mangleUnicodeChars(typeName);
/** * Implements Section 1.3.2.4 of Java2IDL Mapping. All non-IDL identifier characters must be replaced with their * Unicode representation. */ static String mangleUnicodeChars(String identifier) { StringBuffer mangledIdentifier = new StringBuffer(); for (int i = 0; i < identifier.length(); i++) { char nextChar = identifier.charAt(i); if (isIDLIdentifierChar(nextChar)) { mangledIdentifier.append(nextChar); } else { String unicode = charToUnicodeRepresentation(nextChar); mangledIdentifier.append(unicode); } } return mangledIdentifier.toString(); }
try IDLNameTranslator nameTranslator = IDLNameTranslatorImpl.get(remoteInterface); System.out.println(nameTranslator);
public ExceptionRWRMIImpl(Class<?> cls) { super(cls); setId(IDLNameTranslatorImpl.getExceptionId(cls)); }
public static String getExceptionId(Class<?> cls) { // Requirements for this method: // 1. cls must be an exception but not a RemoteException. // 2. If cls has an IDL keyword name, an underscore is prepended (1.3.2.2). // 3. If cls jas a leading underscore, J is prepended (1.3.2.3). // 4. If cls has an illegal IDL ident char, it is mapped to UXXXX where // XXXX is the unicode value in hex of the char (1.3.2.4). // 5. double underscore for inner class (1.3.2.5). // 6. The ID is "IDL:" + name with / separators + ":1.0". IDLType itype = classToIDLType(cls); return itype.getExceptionName(); }
/** * Return portion of class name excluding package name. */ private static String getUnmappedContainerName(Class<?> c) { String memberName = null; String packageName = getPackageName(c); String fullyQualifiedClassName = c.getName(); if (packageName != null) { int packageLength = packageName.length(); memberName = fullyQualifiedClassName.substring(packageLength + 1); } else { memberName = fullyQualifiedClassName; } return memberName; }
/** * Initialize an IDLNameTranslator for the given interface. * * @throws IllegalStateException * if given class is not a valid RMI/IIOP Remote Interface */ private IDLNameTranslatorImpl(Class<?>[] interfaces) { SecurityManager s = System.getSecurityManager(); if (s != null) { s.checkPermission(new DynamicAccessPermission("access")); } try { IDLTypesUtil idlTypesUtil = new IDLTypesUtil(); for (int ctr = 0; ctr < interfaces.length; ctr++) idlTypesUtil.validateRemoteInterface(interfaces[ctr]); interf_ = interfaces; buildNameTranslation(); } catch (IDLTypeException ite) { String msg = ite.getMessage(); IllegalStateException ise = new IllegalStateException(msg); ise.initCause(ite); throw ise; } }
&& outer.originalName.equalsIgnoreCase(inner.originalName)) outer.mangledName = mangleCaseSensitiveCollision(outer.originalName); break; next.mangledName = mangleIdentifier(next.mangledName, next.isProperty); outer.mangledName = mangleOverloadedMethod(outer.mangledName, outer.method); break; String mappedContainerName = getMappedContainerName(interf); for (Iterator<IDLMethodInfo> iter = allMethodInfo.values().iterator(); iter.hasNext();) if (!next.isProperty && identifierClashesWithContainer(mappedContainerName, next.mangledName)) next.mangledName = mangleContainerClash(next.mangledName);
numArrayDimensions++; IDLType componentIdlType = classToIDLType(componentType); String memberName = getUnmappedContainerName(c); if (hasLeadingUnderscore(memberName)) memberName = mangleLeadingUnderscore(memberName); String packageName = getPackageName(c); String moreMangled = hasLeadingUnderscore(next) ? mangleLeadingUnderscore(next) : next;
IDLType idlType = classToIDLType(nextParamType); && (idlTypesUtil.getSpecialCaseIDLTypeMapping(nextParamType) == null) && isIDLKeyword(typeName)) typeName = mangleIDLKeywordClash(typeName); typeName = mangleUnicodeChars(typeName);
/** * Implements Section 1.3.2.4 of Java2IDL Mapping. All non-IDL identifier characters must be replaced with their * Unicode representation. */ static String mangleUnicodeChars(String identifier) { StringBuffer mangledIdentifier = new StringBuffer(); for (int i = 0; i < identifier.length(); i++) { char nextChar = identifier.charAt(i); if (isIDLIdentifierChar(nextChar)) { mangledIdentifier.append(nextChar); } else { String unicode = charToUnicodeRepresentation(nextChar); mangledIdentifier.append(unicode); } } return mangledIdentifier.toString(); }
try IDLNameTranslator nameTranslator = IDLNameTranslatorImpl.get(remoteInterface); System.out.println(nameTranslator);
public ExceptionRWRMIImpl(Class<?> cls) { super(cls); setId(IDLNameTranslatorImpl.getExceptionId(cls)); }
public static String getExceptionId(Class<?> cls) { // Requirements for this method: // 1. cls must be an exception but not a RemoteException. // 2. If cls has an IDL keyword name, an underscore is prepended (1.3.2.2). // 3. If cls jas a leading underscore, J is prepended (1.3.2.3). // 4. If cls has an illegal IDL ident char, it is mapped to UXXXX where // XXXX is the unicode value in hex of the char (1.3.2.4). // 5. double underscore for inner class (1.3.2.5). // 6. The ID is "IDL:" + name with / separators + ":1.0". IDLType itype = classToIDLType(cls); return itype.getExceptionName(); }
/** * Return portion of class name excluding package name. */ private static String getUnmappedContainerName(Class<?> c) { String memberName = null; String packageName = getPackageName(c); String fullyQualifiedClassName = c.getName(); if (packageName != null) { int packageLength = packageName.length(); memberName = fullyQualifiedClassName.substring(packageLength + 1); } else { memberName = fullyQualifiedClassName; } return memberName; }