Class ClassUtil

java.lang.Object
com.sun.enterprise.admin.util.ClassUtil

public final class ClassUtil extends Object
Various utilities used for classes.
  • Method Details

    • objectIsArray

      public static boolean objectIsArray(Object o)
      Test whether an Object is an array
      Parameters:
      o - object to test
    • classIsArray

      public static boolean classIsArray(Class theClass)
      Test whether a Class is an array
      Parameters:
      theClass - class to test
    • objectIsPrimitiveArray

      public static boolean objectIsPrimitiveArray(Object o)
      Test whether an Object is an array of primitive types
      Parameters:
      o - object to test
    • classnameIsArray

      public static boolean classnameIsArray(String classname)
      Test whether a classname is an array
      Parameters:
      classname - classname string
    • classnameIsPrimitiveArray

      public static boolean classnameIsPrimitiveArray(String classname)
      Test whether a classname is a primitive array
      Parameters:
      classname - classname string
    • getPrimitiveArrayTypeCode

      public static char getPrimitiveArrayTypeCode(Class theClass)
      Return the primitive element type code for an array of primitive types. Same as getPrimitiveArrayTypeCode( theClass.getName() )
      Parameters:
      classname - the Class object
    • getPrimitiveArrayTypeCode

      public static char getPrimitiveArrayTypeCode(String classname)
      Return the primitive element type code for an array of primitive types.
      Parameters:
      classname - classname string
    • getArrayMemberClassName

      public static String getArrayMemberClassName(String classname)
      Get the classname for an array element.
      Parameters:
      classname - classname string
    • getClassFromName

      public static Class getClassFromName(String classname) throws ClassNotFoundException
      Get a Class from a classname. Class.forName does not work for primitive types; this methods returns the correct Class for any type.
      Parameters:
      classname - classname string
      Throws:
      ClassNotFoundException
    • primitiveClassToObjectClass

      public static Class primitiveClassToObjectClass(Class theClass)
      Map primitive class Classes to Object forms eg int.class to Integer.class
      Parameters:
      theClass - the class to map
    • isPrimitiveClass

      public static boolean isPrimitiveClass(Class theClass)
      Test whether a class is a primitive class.
      Parameters:
      theClass - the class to test
    • primitiveLetterToClassName

      public static String primitiveLetterToClassName(char primitive)
    • getTypes

      public static String[] getTypes(Object[] args)
    • getFriendlyClassname

      public static String getFriendlyClassname(Class theClass)
    • getFriendlyClassname

      public static String getFriendlyClassname(String type)
    • getArrayElementClass

      public static Class getArrayElementClass(Class arrayClass)
    • getInnerArrayElementClass

      public static Class getInnerArrayElementClass(Class arrayClass) throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • signaturesAreCompatible

      public static boolean signaturesAreCompatible(Class[] callee, Class[] argsSignature)
      Return true if caller signature is compatible with callee.
      Parameters:
      callee - the signature of the method to be called
      argsSignature - the signature of the argument list
    • instantiateObject

      public static Object instantiateObject(Class theClass, Object[] args) throws Exception
      Throws:
      Exception
    • instantiateObject

      public static Object instantiateObject(Class theClass, String theString) throws Exception
      Throws:
      Exception
    • instantiateFromString

      public static Object instantiateFromString(Class theClass, String theString) throws Exception
      Given a Class and a String, create a new instance with a constructor that accept a String. Primitive types are instantiated as their equivalent Object forms.
      Parameters:
      theClass - the class from which an instance should be instantiated
      theString - the string to be supplied to the constructor
      Throws:
      Exception
    • instantiateDefault

      public static Object instantiateDefault(Class inClass) throws Exception
      Given a Class, create a new instance with an empty constructor. Primitive types are instantiated as their equivalent Object forms. Any value is acceptable in the newly created object.
      Parameters:
      theClass - the class from which an instance should be instantiated
      Throws:
      Exception
    • expandClassName

      public static String expandClassName(String name)
    • convertArrayClass

      public static Class convertArrayClass(Class arrayClass, Class newInnerType) throws ClassNotFoundException
      Convert inner element. Only works for arrays of Objects. Example: mapActualElementClass( "[[[LObject;", "Long" ) =>[[[LLong;
      Throws:
      ClassNotFoundException