|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectariba.util.core.ClassUtil
public final class ClassUtil
ClassUtil. A set of helpers for dealing with java classes.
Field Summary | |
---|---|
static java.lang.String |
NativeBoolean
|
static java.lang.String |
NativeByte
|
static java.lang.String |
NativeChar
|
static java.lang.String |
NativeDouble
|
static java.lang.String |
NativeFloat
|
static java.lang.String |
NativeInteger
|
static java.lang.String |
NativeLong
|
static java.lang.String |
NativeShort
|
Method Summary | |
---|---|
static java.lang.Class |
classForName(java.lang.String className)
Find a Class for the specified class name. |
static java.lang.Class |
classForName(java.lang.String className,
boolean warning)
Find a Class for the specified class name. |
static java.lang.Class |
classForName(java.lang.String className,
java.lang.Class supposedSuperclass)
Find a Class for the specified class name. |
static java.lang.Class |
classForName(java.lang.String className,
java.lang.Class supposedSuperclass,
boolean warning)
Find a Class for the specified class name. |
static java.lang.Class |
classForNameNonCaching(java.lang.String className,
java.lang.String pattern,
boolean warning)
Find a Class for the specified class name. |
static java.lang.Class |
classForNameWithException(java.lang.String className)
Find a Class for the specified class name. |
static java.lang.Class |
classForNativeType(java.lang.String typeName)
|
static void |
classTouch(java.lang.String name)
Make sure a class' static inits have run. |
static ClassFactory |
getClassFactory()
|
static java.lang.String |
getClassNameOfObject(java.lang.Object o)
Returns the name of the class of the specified object. |
static java.lang.reflect.Field[] |
getDeclaredFields(java.lang.Class clazz)
ClassUtil.getDeclaredFields returns all the declared fields for the class and it's superclasses. |
static boolean |
instanceOf(java.lang.Class instance,
java.lang.Class target)
Check if one class inherits from another class. |
static boolean |
instanceOf(java.lang.Object object,
java.lang.String className)
Check if an object is an instance of a class identified by it's name. |
static java.lang.Object |
invokeStaticMethod(java.lang.String className,
java.lang.String methodName)
Invokes the specified static method of the specified class. |
static java.lang.Object |
invokeStaticMethod(java.lang.String className,
java.lang.String methodName,
java.lang.Class[] paramTypes,
java.lang.Object[] args)
Invokes the specified static method of the specified class. |
static java.lang.Object |
newInstance(java.lang.Class theClass)
Creates a new instance of the specified class. |
static java.lang.Object |
newInstance(java.lang.Class classObj,
java.lang.Class supposedSuperclass,
boolean warning)
Creates a new Instance of the specified class with error checking. |
static java.lang.Object |
newInstance(java.lang.String className)
Creates a new instance of the specified class. |
static java.lang.Object |
newInstance(java.lang.String className,
boolean warning)
Creates a new instance of the specified class. |
static java.lang.Object |
newInstance(java.lang.String className,
java.lang.Class supposedSuperclass,
boolean warning)
Creates a new Instance of the specified class with error checking. |
static java.lang.Object |
newInstance(java.lang.String className,
java.lang.String supposedSuperclassName)
Creates a new Instance of the specified class with error checking. |
static java.lang.Object |
newInstance(java.lang.String className,
java.lang.String supposedSuperclassName,
boolean warning)
Creates a new Instance of the specified class with error checking. |
static ClassFactory |
setClassFactory(ClassFactory cf)
|
static java.lang.String |
stripClassFromClassName(java.lang.String className)
Find the package specifier for a given class name. |
static java.lang.String |
stripPackageFromClassName(java.lang.String className)
Strips any package specifiers from the given class name. |
static java.lang.String |
typeToVMType(java.lang.String type)
Convert from a class name into an internal java representation of that class String int -> I java.lang.String -> Ljava.lang.String; |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String NativeInteger
public static java.lang.String NativeBoolean
public static java.lang.String NativeDouble
public static java.lang.String NativeFloat
public static java.lang.String NativeLong
public static java.lang.String NativeByte
public static java.lang.String NativeShort
public static java.lang.String NativeChar
Method Detail |
---|
public static void classTouch(java.lang.String name)
name
- the name of the class to load.public static java.lang.Class classForNativeType(java.lang.String typeName)
public static java.lang.Class classForName(java.lang.String className)
className
- the name of the class to find
newInstance(java.lang.String)
public static java.lang.Class classForName(java.lang.String className, java.lang.Class supposedSuperclass)
className
- the name of the class to findsupposedSuperclass
- The class of the required
superclass for the class specified by className
newInstance(java.lang.String)
public static ClassFactory setClassFactory(ClassFactory cf)
public static ClassFactory getClassFactory()
public static java.lang.Class classForName(java.lang.String className, boolean warning)
className
- the name of the class to findwarning
- if true and the class can not be found,
a warning will be printed
newInstance(java.lang.String)
public static java.lang.Class classForName(java.lang.String className, java.lang.Class supposedSuperclass, boolean warning)
className
- the name of the class to findsupposedSuperclass
- The required superclass for the classwarning
- if true and the class can not be found,
or it is not assignable to the supposedSuperclass, a warning
will be printed
newInstance(java.lang.String)
public static java.lang.Class classForNameWithException(java.lang.String className) throws java.lang.ClassNotFoundException
The java spec does not define behavior with a null className. If a null is passed in a ClassNotFoundException will be thrown.
className
- the name of the class to find
java.lang.ClassNotFoundException
- if the class can not be
found.newInstance(java.lang.String)
public static java.lang.Class classForNameNonCaching(java.lang.String className, java.lang.String pattern, boolean warning)
Each call to classForNameNonCaching reloads the byte codes into the VM. This is very useful debugging programs that have long start-up times because classes loaded with classForNameNonCaching can be recompiled and reloaded into the VM without restarting.
The pattern parameter allows you to extend the dynamic type of class loading to other classes that are instantiated by the class identified in className. If you provide null for this parameter, then the only class that gets dynamically reloaded is the className class. Any classes it instantiates will be based on byte codes cached in the VM. Note the className needs to conform to the pattern.
The java spec does not define behavior with a null className. If a null is passed in a ClassNotFoundException will be thrown. This will dynamically load RequisitionTester plus any classes that RequisitionTester instantiates that also belong to packages that begin with the string "test".
className
- the name of the class to find - null not allowedpattern
- the classname pattern for other classes to reloadwarning
- if true and the class can not be found,
a warning will be printed
newInstance(java.lang.String)
,
StringUtil.stringMatchesPattern(java.lang.String, java.lang.String)
public static boolean instanceOf(java.lang.Object object, java.lang.String className)
object
- the object to test the instance ofclassName
- the name of the class being tested for
public static boolean instanceOf(java.lang.Class instance, java.lang.Class target)
instance
- the class to check the inheritance tree of, must not be null.target
- the class to check against. If null, will return false.
public static java.lang.String getClassNameOfObject(java.lang.Object o)
o
- the object to find the class name of
public static java.lang.Object newInstance(java.lang.String className)
className
- the name of class to create a new instance of
classForName(java.lang.String)
public static java.lang.Object newInstance(java.lang.String className, boolean warning)
className
- the name of class to create a new instance ofwarning
- if true and the class can not be found,
a warning will be printed
classForName(java.lang.String)
public static java.lang.Object newInstance(java.lang.String className, java.lang.String supposedSuperclassName)
className
- the class to create a new instance ofsupposedSuperclassName
- The name of the required
superclass for the new class
public static java.lang.Object newInstance(java.lang.String className, java.lang.String supposedSuperclassName, boolean warning)
className
- the class to create a new instance ofsupposedSuperclassName
- The name of the required
superclass for the new classwarning
- if true and the class can not be found,
a warning will be printed
public static java.lang.Object newInstance(java.lang.String className, java.lang.Class supposedSuperclass, boolean warning)
className
- the class to create a new instance ofsupposedSuperclass
- The class of the required
superclass for the new classwarning
- if true and the class can not be found,
a warning will be printed
public static java.lang.Object newInstance(java.lang.Class classObj, java.lang.Class supposedSuperclass, boolean warning)
classObj
- the class to create a new instance ofsupposedSuperclass
- The class of the required
superclass for the new classwarning
- if true and the class can not be found,
a warning will be printed
public static java.lang.Object newInstance(java.lang.Class theClass)
theClass
- the class to create a new instance of
classForName(java.lang.String)
public static java.lang.String stripPackageFromClassName(java.lang.String className)
className
- class name to strip
public static java.lang.String stripClassFromClassName(java.lang.String className)
className
- class name to strip
public static java.lang.Object invokeStaticMethod(java.lang.String className, java.lang.String methodName)
className
- the name of the class to invoke the static
method onmethodName
- the name of the method to call
Method.invoke(java.lang.Object, java.lang.Object...)
public static java.lang.Object invokeStaticMethod(java.lang.String className, java.lang.String methodName, java.lang.Class[] paramTypes, java.lang.Object[] args)
className
- the name of the class to invoke the static
method onmethodName
- the name of the method to callparamTypes
- an array of Class types that *exactly* match
the signature of the method being invoked.args
- an array of Object arguments to the method
Method.invoke(java.lang.Object, java.lang.Object...)
public static java.lang.reflect.Field[] getDeclaredFields(java.lang.Class clazz)
clazz
- the Class to discover the fields of
public static java.lang.String typeToVMType(java.lang.String type)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |