Class IDLNameTranslatorImpl
- java.lang.Object
-
- com.sun.corba.ee.impl.presentation.rmi.IDLNameTranslatorImpl
-
- All Implemented Interfaces:
IDLNameTranslator
public class IDLNameTranslatorImpl extends java.lang.Object implements IDLNameTranslator
Bidirectional translator between RMI-IIOP interface methods and and IDL Names.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
IDLNameTranslatorImpl.IDLMethodInfo
Internal helper class for tracking information related to each interface method while we're building the name translation table.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ATTRIBUTE_METHOD_CLASH_MANGLE_CHARS
private static java.lang.String
BASE_IDL_ARRAY_ELEMENT_TYPE
private static java.lang.String[]
BASE_IDL_ARRAY_MODULE_TYPE
private static java.lang.String
GET_ATTRIBUTE_PREFIX
private static char[]
HEX_DIGITS
private static java.lang.String
ID_CONTAINER_CLASH_CHAR
private static java.lang.String[]
IDL_KEYWORDS
private static java.util.Set<java.lang.String>
idlKeywords_
private java.util.Map<java.lang.String,java.lang.reflect.Method>
IDLNameToMethodMap_
private static java.lang.String
INNER_CLASS_SEPARATOR
private java.lang.Class[]
interf_
private static java.lang.String
IS_ATTRIBUTE_PREFIX
private static java.lang.String
LEADING_UNDERSCORE_CHAR
private java.lang.reflect.Method[]
methods_
private java.util.Map<java.lang.reflect.Method,java.lang.String>
methodToIDLNameMap_
private static java.lang.String
OVERLOADED_TYPE_SEPARATOR
private static java.lang.String
SET_ATTRIBUTE_PREFIX
private static java.lang.String
UNDERSCORE
-
Constructor Summary
Constructors Modifier Constructor Description private
IDLNameTranslatorImpl(java.lang.Class<?>[] interfaces)
Initialize an IDLNameTranslator for the given interface.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
buildNameTranslation()
static java.lang.String
charToUnicodeRepresentation(char c)
Returns Unicode mangling as defined in Section 1.3.2.4 of Java2IDL spec.private static IDLType
classToIDLType(java.lang.Class<?> c)
static IDLNameTranslator
get(java.lang.Class interf)
Return an IDLNameTranslator for the given interface.static IDLNameTranslator
get(java.lang.Class[] interfaces)
Return an IDLNameTranslator for the given interfaces.static java.lang.String
getExceptionId(java.lang.Class cls)
java.lang.String
getIDLName(java.lang.reflect.Method method)
Get the mangled name that corresponds to the given method on this IDLNameTranslator's interface.java.lang.Class[]
getInterfaces()
Get the interfaces that this IDLNameTranslator describes.private static java.lang.String
getMappedContainerName(java.lang.Class<?> c)
java.lang.reflect.Method
getMethod(java.lang.String idlName)
Get the method from this IDLNameTranslator's interfaces that corresponds to the mangled name idlName.java.lang.reflect.Method[]
getMethods()
Get all methods for this remote interface.private static java.lang.String
getPackageName(java.lang.Class<?> c)
Return Class' package name or null if there is no package.private static java.lang.String
getUnmappedContainerName(java.lang.Class<?> c)
Return portion of class name excluding package name.private static boolean
hasLeadingUnderscore(java.lang.String identifier)
Checks whether a java identifier starts with an underscore.private static boolean
identifierClashesWithContainer(java.lang.String mappedContainerName, java.lang.String identifier)
Implements Section 1.3.2.9 of Java2IDL Mapping.private static boolean
isIDLAlphabeticChar(char c)
True if character is one of 114 Alphabetic characters as specified in Table 2 of Chapter 3 in CORBA spec.private static boolean
isIDLDecimalDigit(char c)
True if character is one of 10 Decimal Digits specified in Table 3 of Chapter 3 in CORBA spec.private static boolean
isIDLIdentifier(java.lang.String identifier)
private static boolean
isIDLIdentifierChar(char c)
(package private) static boolean
isIDLKeyword(java.lang.String identifier)
Checks whether a java identifier clashes with an IDL keyword.private static boolean
isUnderscore(char c)
(package private) java.lang.String
mangleCaseSensitiveCollision(java.lang.String identifier)
Implements mangling portion of Section 1.3.2.7 of Java2IDL spec.private static java.lang.String
mangleContainerClash(java.lang.String identifier)
private static java.lang.String
mangleIdentifier(java.lang.String identifier)
Perform all necessary stand-alone identifier mangling operations on a java identifier that is being transformed into an IDL name.private static java.lang.String
mangleIdentifier(java.lang.String identifier, boolean attribute)
(package private) static java.lang.String
mangleIDLKeywordClash(java.lang.String identifier)
private static java.lang.String
mangleLeadingUnderscore(java.lang.String identifier)
private static java.lang.String
mangleOverloadedMethod(java.lang.String mangledName, java.lang.reflect.Method m)
Mangle an overloaded method name as defined in Section 1.3.2.6 of Java2IDL spec.(package private) static java.lang.String
mangleUnicodeChars(java.lang.String identifier)
Implements Section 1.3.2.4 of Java2IDL Mapping.java.lang.String
toString()
-
-
-
Field Detail
-
IDL_KEYWORDS
private static java.lang.String[] IDL_KEYWORDS
-
HEX_DIGITS
private static char[] HEX_DIGITS
-
UNDERSCORE
private static final java.lang.String UNDERSCORE
- See Also:
- Constant Field Values
-
INNER_CLASS_SEPARATOR
private static final java.lang.String INNER_CLASS_SEPARATOR
- See Also:
- Constant Field Values
-
BASE_IDL_ARRAY_MODULE_TYPE
private static final java.lang.String[] BASE_IDL_ARRAY_MODULE_TYPE
-
BASE_IDL_ARRAY_ELEMENT_TYPE
private static final java.lang.String BASE_IDL_ARRAY_ELEMENT_TYPE
- See Also:
- Constant Field Values
-
LEADING_UNDERSCORE_CHAR
private static final java.lang.String LEADING_UNDERSCORE_CHAR
- See Also:
- Constant Field Values
-
ID_CONTAINER_CLASH_CHAR
private static final java.lang.String ID_CONTAINER_CLASH_CHAR
- See Also:
- Constant Field Values
-
OVERLOADED_TYPE_SEPARATOR
private static final java.lang.String OVERLOADED_TYPE_SEPARATOR
- See Also:
- Constant Field Values
-
ATTRIBUTE_METHOD_CLASH_MANGLE_CHARS
private static final java.lang.String ATTRIBUTE_METHOD_CLASH_MANGLE_CHARS
- See Also:
- Constant Field Values
-
GET_ATTRIBUTE_PREFIX
private static final java.lang.String GET_ATTRIBUTE_PREFIX
- See Also:
- Constant Field Values
-
SET_ATTRIBUTE_PREFIX
private static final java.lang.String SET_ATTRIBUTE_PREFIX
- See Also:
- Constant Field Values
-
IS_ATTRIBUTE_PREFIX
private static final java.lang.String IS_ATTRIBUTE_PREFIX
- See Also:
- Constant Field Values
-
idlKeywords_
private static java.util.Set<java.lang.String> idlKeywords_
-
interf_
private java.lang.Class[] interf_
-
methodToIDLNameMap_
private java.util.Map<java.lang.reflect.Method,java.lang.String> methodToIDLNameMap_
-
IDLNameToMethodMap_
private java.util.Map<java.lang.String,java.lang.reflect.Method> IDLNameToMethodMap_
-
methods_
private java.lang.reflect.Method[] methods_
-
-
Method Detail
-
get
public static IDLNameTranslator get(java.lang.Class interf)
Return an IDLNameTranslator for the given interface.- Parameters:
interf
- Interface to get translator for.- Returns:
- IDLNameTranslator for specified interface.
- Throws:
java.lang.IllegalStateException
- if given class is not a valid RMI/IIOP Remote Interface
-
get
public static IDLNameTranslator get(java.lang.Class[] interfaces)
Return an IDLNameTranslator for the given interfaces.- Parameters:
interfaces
- Interfaces to get a translator for- Returns:
- IDLNameTranslator for specified interfaces.
- Throws:
java.lang.IllegalStateException
- if given classes are not valid RMI/IIOP Remote Interfaces
-
getExceptionId
public static java.lang.String getExceptionId(java.lang.Class cls)
-
getInterfaces
public java.lang.Class[] getInterfaces()
Description copied from interface:IDLNameTranslator
Get the interfaces that this IDLNameTranslator describes.- Specified by:
getInterfaces
in interfaceIDLNameTranslator
- Returns:
- interfaces described
-
getMethods
public java.lang.reflect.Method[] getMethods()
Description copied from interface:IDLNameTranslator
Get all methods for this remote interface. The methods are returned in a canonical order, that is, they are always in the same order for a particular interface.- Specified by:
getMethods
in interfaceIDLNameTranslator
- Returns:
- methods for interface
-
getMethod
public java.lang.reflect.Method getMethod(java.lang.String idlName)
Description copied from interface:IDLNameTranslator
Get the method from this IDLNameTranslator's interfaces that corresponds to the mangled name idlName. Returns null if there is no matching method.- Specified by:
getMethod
in interfaceIDLNameTranslator
- Parameters:
idlName
- name of method- Returns:
- method with the specified name
-
getIDLName
public java.lang.String getIDLName(java.lang.reflect.Method method)
Description copied from interface:IDLNameTranslator
Get the mangled name that corresponds to the given method on this IDLNameTranslator's interface. Returns null if there is no matching name.- Specified by:
getIDLName
in interfaceIDLNameTranslator
- Parameters:
method
- method to get name of- Returns:
- the corresponding name
-
buildNameTranslation
private void buildNameTranslation()
-
mangleIdentifier
private static java.lang.String mangleIdentifier(java.lang.String identifier)
Perform all necessary stand-alone identifier mangling operations on a java identifier that is being transformed into an IDL name. That is, mangling operations that don't require looking at anything else but the identifier itself. This covers sections 1.3.2.2, 1.3.2.3, and 1.3.2.4 of the Java2IDL spec. Method overloading and case-sensitivity checks are handled elsewhere.
-
mangleIdentifier
private static java.lang.String mangleIdentifier(java.lang.String identifier, boolean attribute)
-
isIDLKeyword
static boolean isIDLKeyword(java.lang.String identifier)
Checks whether a java identifier clashes with an IDL keyword. Note that this is a case-insensitive comparison. Used to implement section 1.3.2.2 of Java2IDL spec.
-
mangleIDLKeywordClash
static java.lang.String mangleIDLKeywordClash(java.lang.String identifier)
-
mangleLeadingUnderscore
private static java.lang.String mangleLeadingUnderscore(java.lang.String identifier)
-
hasLeadingUnderscore
private static boolean hasLeadingUnderscore(java.lang.String identifier)
Checks whether a java identifier starts with an underscore. Used to implement section 1.3.2.3 of Java2IDL spec.
-
mangleUnicodeChars
static java.lang.String mangleUnicodeChars(java.lang.String identifier)
Implements Section 1.3.2.4 of Java2IDL Mapping. All non-IDL identifier characters must be replaced with their Unicode representation.
-
mangleCaseSensitiveCollision
java.lang.String mangleCaseSensitiveCollision(java.lang.String identifier)
Implements mangling portion of Section 1.3.2.7 of Java2IDL spec. This method only deals with the actual mangling. Decision about whether case-sensitive collision mangling is required is made elsewhere. "...a mangled name is generated consisting of the original name followed by an underscore separated list of decimal indices into the string, where the indices identify all the upper case characters in the original string. Indices are zero based."
-
mangleContainerClash
private static java.lang.String mangleContainerClash(java.lang.String identifier)
-
identifierClashesWithContainer
private static boolean identifierClashesWithContainer(java.lang.String mappedContainerName, java.lang.String identifier)
Implements Section 1.3.2.9 of Java2IDL Mapping. Container in this context means the name of the java Class(excluding package) in which the identifier is defined. Comparison is case-insensitive.
-
charToUnicodeRepresentation
public static java.lang.String charToUnicodeRepresentation(char c)
Returns Unicode mangling as defined in Section 1.3.2.4 of Java2IDL spec. "For Java identifiers that contain illegal OMG IDL identifier characters such as '$' or Unicode characters outside of ISO Latin 1, any such illegal characters are replaced by "U" followed by the 4 hexadecimal characters(in upper case) representing the Unicode value. So, the Java name a$b is mapped to aU0024b and xμy is mapped to xU03BCy."- Parameters:
c
- character to convert- Returns:
- Unicode String
-
isIDLIdentifier
private static boolean isIDLIdentifier(java.lang.String identifier)
-
isIDLIdentifierChar
private static boolean isIDLIdentifierChar(char c)
-
isIDLAlphabeticChar
private static boolean isIDLAlphabeticChar(char c)
True if character is one of 114 Alphabetic characters as specified in Table 2 of Chapter 3 in CORBA spec.
-
isIDLDecimalDigit
private static boolean isIDLDecimalDigit(char c)
True if character is one of 10 Decimal Digits specified in Table 3 of Chapter 3 in CORBA spec.
-
isUnderscore
private static boolean isUnderscore(char c)
-
mangleOverloadedMethod
private static java.lang.String mangleOverloadedMethod(java.lang.String mangledName, java.lang.reflect.Method m)
Mangle an overloaded method name as defined in Section 1.3.2.6 of Java2IDL spec. Current value of method name is passed in as argument. We can't start from original method name since the name might have been partially mangled as a result of the other rules.
-
classToIDLType
private static IDLType classToIDLType(java.lang.Class<?> c)
-
getPackageName
private static java.lang.String getPackageName(java.lang.Class<?> c)
Return Class' package name or null if there is no package.
-
getMappedContainerName
private static java.lang.String getMappedContainerName(java.lang.Class<?> c)
-
getUnmappedContainerName
private static java.lang.String getUnmappedContainerName(java.lang.Class<?> c)
Return portion of class name excluding package name.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-