Package com.sun.enterprise.admin.util
Class ClassUtil
java.lang.Object
com.sun.enterprise.admin.util.ClassUtil
Various utilities used for classes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanclassIsArray(Class theClass) Test whether a Class is an arraystatic booleanclassnameIsArray(String classname) Test whether a classname is an arraystatic booleanclassnameIsPrimitiveArray(String classname) Test whether a classname is a primitive arraystatic ClassconvertArrayClass(Class arrayClass, Class newInnerType) Convert inner element.static StringexpandClassName(String name) static ClassgetArrayElementClass(Class arrayClass) static StringgetArrayMemberClassName(String classname) Get the classname for an array element.static ClassgetClassFromName(String classname) Get a Class from a classname.static StringgetFriendlyClassname(Class theClass) static StringgetFriendlyClassname(String type) static ClassgetInnerArrayElementClass(Class arrayClass) static chargetPrimitiveArrayTypeCode(Class theClass) Return the primitive element type code for an array of primitive types.static chargetPrimitiveArrayTypeCode(String classname) Return the primitive element type code for an array of primitive types.static String[]static ObjectinstantiateDefault(Class inClass) Given a Class, create a new instance with an empty constructor.static ObjectinstantiateFromString(Class theClass, String theString) Given a Class and a String, create a new instance with a constructor that accept a String.static ObjectinstantiateObject(Class theClass, Object[] args) static ObjectinstantiateObject(Class theClass, String theString) static booleanisPrimitiveClass(Class theClass) Test whether a class is a primitive class.static booleanTest whether an Object is an arraystatic booleanTest whether an Object is an array of primitive typesstatic ClassprimitiveClassToObjectClass(Class theClass) Map primitive class Classes to Object forms eg int.class to Integer.classstatic StringprimitiveLetterToClassName(char primitive) static booleansignaturesAreCompatible(Class[] callee, Class[] argsSignature) Return true if caller signature is compatible with callee.
-
Method Details
-
objectIsArray
Test whether an Object is an array- Parameters:
o- object to test
-
classIsArray
Test whether a Class is an array- Parameters:
theClass- class to test
-
objectIsPrimitiveArray
Test whether an Object is an array of primitive types- Parameters:
o- object to test
-
classnameIsArray
Test whether a classname is an array- Parameters:
classname- classname string
-
classnameIsPrimitiveArray
Test whether a classname is a primitive array- Parameters:
classname- classname string
-
getPrimitiveArrayTypeCode
Return the primitive element type code for an array of primitive types. Same as getPrimitiveArrayTypeCode( theClass.getName() )- Parameters:
classname- the Class object
-
getPrimitiveArrayTypeCode
Return the primitive element type code for an array of primitive types.- Parameters:
classname- classname string
-
getArrayMemberClassName
Get the classname for an array element.- Parameters:
classname- classname string
-
getClassFromName
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
Map primitive class Classes to Object forms eg int.class to Integer.class- Parameters:
theClass- the class to map
-
isPrimitiveClass
Test whether a class is a primitive class.- Parameters:
theClass- the class to test
-
primitiveLetterToClassName
-
getTypes
-
getFriendlyClassname
-
getFriendlyClassname
-
getArrayElementClass
-
getInnerArrayElementClass
- Throws:
ClassNotFoundException
-
signaturesAreCompatible
Return true if caller signature is compatible with callee.- Parameters:
callee- the signature of the method to be calledargsSignature- the signature of the argument list
-
instantiateObject
- Throws:
Exception
-
instantiateObject
- Throws:
Exception
-
instantiateFromString
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 instantiatedtheString- the string to be supplied to the constructor- Throws:
Exception
-
instantiateDefault
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
-
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
-