de.bea.domingo.map
Class ClassUtilities

java.lang.Object
  extended by de.bea.domingo.map.ClassUtilities

final class ClassUtilities
extends java.lang.Object

Utility methods for querying Class objects.


Method Summary
static java.lang.Class classForNameOrPrimitive(java.lang.String name, java.lang.ClassLoader loader)
           
static boolean classIsAccessible(java.lang.Class aClass)
           
static boolean compatibleClasses(java.lang.Class[] lhs, java.lang.Class[] rhs)
          Tells whether instances of the classes in the 'rhs' array could be used as parameters to a reflective method invocation whose parameter list has types denoted by the 'lhs' array.
static java.lang.reflect.Method getAccessibleMethodFrom(java.lang.Class aClass, java.lang.String methodName, java.lang.Class[] parameterTypes)
           
static java.lang.Class primitiveEquivalentOf(java.lang.Class aClass)
           
static boolean primitiveIsAssignableFrom(java.lang.Class lhs, java.lang.Class rhs)
          Tells whether an instance of the primitive class represented by 'rhs' can be assigned to an instance of the primitive class represented by 'lhs'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

classForNameOrPrimitive

public static java.lang.Class classForNameOrPrimitive(java.lang.String name,
                                                      java.lang.ClassLoader loader)
                                               throws java.lang.ClassNotFoundException
Parameters:
name - FQN of a class, or the name of a primitive type
loader - a ClassLoader
Returns:
the Class for the name given. Primitive types are converted to their particular Class object. null, the empty string, "null", and "void" yield Void.TYPE. If any classes require loading because of this operation, the loading is done by the given class loader. Such classes are not initialized, however.
Throws:
java.lang.ClassNotFoundException - if name names an unknown class or primitive

classIsAccessible

public static boolean classIsAccessible(java.lang.Class aClass)
Parameters:
aClass - a Class
Returns:
true if the class is accessible, false otherwise. Presently returns true if the class is declared public.

compatibleClasses

public static boolean compatibleClasses(java.lang.Class[] lhs,
                                        java.lang.Class[] rhs)
Tells whether instances of the classes in the 'rhs' array could be used as parameters to a reflective method invocation whose parameter list has types denoted by the 'lhs' array.

Parameters:
lhs - Class array representing the types of the formal parameters of a method
rhs - Class array representing the types of the actual parameters of a method. A null value or Void.TYPE is considered to match a corresponding Object or array class in lhs, but not a primitive.
Returns:
true if compatible, false otherwise

getAccessibleMethodFrom

public static java.lang.reflect.Method getAccessibleMethodFrom(java.lang.Class aClass,
                                                               java.lang.String methodName,
                                                               java.lang.Class[] parameterTypes)
Parameters:
aClass - a Class
methodName - name of a method
parameterTypes - Class array representing the types of a method's formal parameters
Returns:
the Method with the given name and formal parameter types that is in the nearest accessible class in the class hierarchy, starting with aClass's superclass. The superclass and implemented interfaces of aClass are searched, then their superclasses, etc. until a method is found. Returns null if there is no such method.

primitiveEquivalentOf

public static java.lang.Class primitiveEquivalentOf(java.lang.Class aClass)
Parameters:
aClass - a Class
Returns:
the class's primitive equivalent, if aClass is a primitive wrapper. If aClass is primitive, returns aClass. Otherwise, returns null.

primitiveIsAssignableFrom

public static boolean primitiveIsAssignableFrom(java.lang.Class lhs,
                                                java.lang.Class rhs)
Tells whether an instance of the primitive class represented by 'rhs' can be assigned to an instance of the primitive class represented by 'lhs'.

Parameters:
lhs - assignee class
rhs - assigned class
Returns:
true if compatible, false otherwise. If either argument is null, or one of the parameters does not represent a primitive (e.g. Byte.TYPE), returns false.


Domingo Java-API