|
Java EE 5 SDK | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.appserv.management.util.misc.ClassUtil
public final class ClassUtil
Provides a variety of useful utilities having to do with classes, types of objects, etc.
Method Summary | |
---|---|
static Class<?> |
classForName(String name)
|
static boolean |
classIsAccessible(String name)
|
static boolean |
classIsArray(Class theClass)
Test whether a Class is an array |
static boolean |
classnameIsArray(String classname)
Test whether a classname is an array |
static boolean |
classnameIsPrimitiveArray(String classname)
Test whether a classname is a primitive array |
static String[] |
classnamesFromSignature(Class[] classes)
Return the corresponding classes for each classname. |
static Class |
convertArrayClass(Class arrayClass,
Class newInnerType)
Convert inner element to another type. |
static String |
ExpandClassName(String name)
Expand an abbreviated classname into its true java name. |
static Method |
findMethod(Class theClass,
String methodName,
Class[] sig)
Find all methods that match the name. |
static Set<Method> |
findMethods(Method[] candidates,
String methodName)
Find all methods that match the name. |
static int |
getArrayDimensions(Class theClass)
|
static Class |
getArrayElementClass(Class arrayClass)
|
static String |
getArrayMemberClassName(String classname)
Get the classname for an array element. |
static Class |
getClassFromName(String classname)
Get a Class from a classname. |
static Object |
getFieldValue(Class theInterface,
String name)
|
static String |
getFriendlyClassname(Class theClass)
Get a "friendly" classname for a Class. |
static String |
getFriendlyClassname(String type)
|
static Class |
getInnerArrayElementClass(Class arrayClass)
|
static String |
getPackagePrefix(String classname)
|
static Package[] |
getPackages()
|
static Package[] |
getPackages(ClassLoader cl)
|
static char |
getPrimitiveArrayTypeCode(Class theClass)
Return the primitive element type code for an array of primitive types. |
static char |
getPrimitiveArrayTypeCode(String classname)
Return the primitive element type code for an array of primitive types. |
static String[] |
getTypes(Object[] args)
Return the corresponding classes for each element in an Object[] If an element is null, then its corresponding Class will also be null. |
static Object |
InstantiateDefault(Class inClass)
Given a Class, create a new instance with an empty constructor. |
static Object |
InstantiateFromString(Class theClass,
String theString)
Given a Class and a String, create a new instance with a constructor that accept a String. |
static Object |
InstantiateObject(Class theClass,
Object[] args)
Create a new object of the specified class using a constructor that accepts the specified arguments. |
static Object |
InstantiateObject(Class theClass,
String theString)
Create a new object of the specified class using a String constructor. |
static boolean |
IsPrimitiveClass(Class theClass)
Test whether a class is a primitive class. |
static Class |
ObjectClassToPrimitiveClass(Class theClass)
Map primitive class Classes to Object forms eg int.class to Integer.class |
static boolean |
objectIsArray(Object o)
Test whether an Object is an array |
static boolean |
objectIsPrimitiveArray(Object o)
Test whether an Object is an array of primitive types |
static Class |
PrimitiveClassToObjectClass(Class theClass)
Map primitive class Classes to Object forms eg int.class to Integer.class |
static String |
PrimitiveLetterToClassName(char primitive)
Convert a primitive class letter to its corresponding class name. |
static Class[] |
signatureFromClassnames(String[] classnames)
Return the corresponding classes for each classname. |
static boolean |
signaturesAreCompatible(Class<?>[] callee,
Class<?>[] argsSignature)
Return true if caller signature is compatible with callee. |
static boolean |
sigsEqual(Class[] sig1,
Class[] sig2)
|
static String |
stripPackageName(String classname)
Strip the package name. |
static String |
stripPackagePrefix(String classname)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean classIsAccessible(String name)
public static boolean sigsEqual(Class[] sig1, Class[] sig2)
public static boolean objectIsArray(Object o)
o
- object to test
public static boolean classIsArray(Class theClass)
theClass
- class to test
public static boolean objectIsPrimitiveArray(Object o)
o
- object to test
public static boolean classnameIsArray(String classname)
classname
- classname string
public static String stripPackageName(String classname)
classname
- classname string
public static boolean classnameIsPrimitiveArray(String classname)
classname
- classname string
public static char getPrimitiveArrayTypeCode(Class theClass)
theClass
- the Class object
public static char getPrimitiveArrayTypeCode(String classname)
classname
- classname string
public static String getArrayMemberClassName(String classname)
classname
- classname string
public static Class<?> classForName(String name) throws ClassNotFoundException
ClassNotFoundException
public static Class getClassFromName(String classname) throws ClassNotFoundException
classname
- classname string
ClassNotFoundException
public static Class PrimitiveClassToObjectClass(Class theClass)
theClass
- the class to map
public static Class ObjectClassToPrimitiveClass(Class theClass)
theClass
- the class to map
public static boolean IsPrimitiveClass(Class theClass)
theClass
- the class to test
public static String PrimitiveLetterToClassName(char primitive)
primitive
- the primitive character code
public static String[] getTypes(Object[] args)
args
- an array of objects.
public static Class[] signatureFromClassnames(String[] classnames) throws ClassNotFoundException
classnames
- an array of classnames.
ClassNotFoundException
public static String[] classnamesFromSignature(Class[] classes)
classes
- an array of classnames.
public static String getFriendlyClassname(Class theClass)
Calls getFriendlyClassname( theClass.getName() )
theClass
- the class for which the name should be gotten
public static String getFriendlyClassname(String type)
public static int getArrayDimensions(Class theClass)
public static Class getArrayElementClass(Class arrayClass)
public static Class getInnerArrayElementClass(Class arrayClass) throws ClassNotFoundException
ClassNotFoundException
public static boolean signaturesAreCompatible(Class<?>[] callee, Class<?>[] argsSignature)
callee
- the signature of the method to be calledargsSignature
- the signature of the argument listpublic static final Method findMethod(Class theClass, String methodName, Class[] sig)
public static final Set<Method> findMethods(Method[] candidates, String methodName)
public static Object InstantiateObject(Class theClass, Object[] args) throws Exception
theClass
- the Class of the desired Objectargs
- the argument list for the constructor
Exception
public static Object InstantiateObject(Class theClass, String theString) throws Exception
theClass
- the Class of the desired ObjecttheString
- the string for a String constructor
Exception
public static Object InstantiateFromString(Class theClass, String theString) throws Exception
theClass
- the class from which an instance should be instantiatedtheString
- the string to be supplied to the constructor
Exception
public static Object InstantiateDefault(Class inClass) throws Exception
inClass
- the class from which an instance should be instantiated
Exception
public static String ExpandClassName(String name)
public static Class convertArrayClass(Class arrayClass, Class newInnerType) throws ClassNotFoundException
arrayClass
- newInnerType
- the desired Class of the innermost element
ClassNotFoundException
public static Package[] getPackages()
public static Package[] getPackages(ClassLoader cl)
public static Object getFieldValue(Class theInterface, String name)
public static String stripPackagePrefix(String classname)
public static String getPackagePrefix(String classname)
|
Java EE 5 SDK | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 2006 Sun Microsystems, Inc. All rights reserved.