public class ClassUtils extends Object
Constructor and Description |
---|
ClassUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
getCleanedFilePath(String path)
clean up file path, to replace websphere specific classpath references with generic ones.
|
static Constructor |
getConstructorOnType(Class clas,
Class[] parameterTypes)
Retrieves the constructor of a class, based on the parameters
|
static Object |
getDeclaredFieldValue(Object o,
Class c,
String name) |
static Object |
getDeclaredFieldValue(Object o,
String name) |
static Object |
getFieldValue(Object o,
Class c,
String name) |
static Object |
getFieldValue(Object o,
String name) |
static Object |
getFieldValueSafe(Object o,
String name) |
static URL |
getResourceURL(String resource) |
static boolean |
implementsInterface(Class class1,
Class iface)
Tests if a class implements a given interface
|
static boolean |
implementsInterface(String className,
String iface)
Tests if a class implements a given interface
|
static Object |
invokeGetter(Object o,
String name) |
static Object |
invokeGetter(Object o,
String name,
boolean forceAccess) |
static Object |
invokeGetterSafe(Object o,
String name,
boolean forceAccess) |
static void |
invokeSetter(Object o,
String name,
Object value) |
static void |
invokeSetter(Object o,
String name,
Object value,
Class clazz) |
static String |
invokeStringGetter(Object o,
String name) |
static String |
invokeStringGetterSafe(Object o,
String name) |
static long |
lastModified(Class aClass)
Determine the last modification date for this
class file or its enclosing library
|
static Class |
loadClass(String className)
Load a class given its name.
|
static String |
nameOf(Object o)
returns the className of the object, without the package name.
|
static Object |
newInstance(String className)
Create a new instance given a class name.
|
static Object |
newInstance(String className,
Class[] parameterClasses,
Object[] parameterObjects)
creates a new instance of an object, based on the classname as string, the classes
and the actual parameters.
|
static Object |
newInstance(String className,
Object[] parameterObjects)
Creates a new instance from a class, while it looks for a constructor
that matches the parameters, and initializes the object (by calling the constructor)
Notice: this does not work when the instantiated object uses an interface class
as a parameter, as the class names are, in that case, not the same..
|
static String |
which(Class aClass)
Gets the absolute pathname of the class file
containing the specified class name, as prescribed
by the current classpath.
|
protected static Logger log
public static Constructor getConstructorOnType(Class clas, Class[] parameterTypes)
public static URL getResourceURL(String resource) throws FileNotFoundException
FileNotFoundException
public static boolean implementsInterface(Class class1, Class iface)
public static boolean implementsInterface(String className, String iface) throws Exception
Exception
public static long lastModified(Class aClass) throws IOException, IllegalArgumentException
aClass
- A class whose last modification date is queriedIOException
- IOErrorIllegalArgumentException
- The class was not loaded from a file
or directorypublic static Class loadClass(String className) throws ClassNotFoundException
className
- A class nameclassName
ClassNotFoundException
- If a loading error occurspublic static Object newInstance(String className) throws Exception
className
- A class nameException
- If an instantiation error occurspublic static Object newInstance(String className, Class[] parameterClasses, Object[] parameterObjects)
public static Object newInstance(String className, Object[] parameterObjects)
className
- a class NameparameterObjects
- the parameters for the constructorpublic static String which(Class aClass)
aClass
- A classpublic static String nameOf(Object o)
public static void invokeSetter(Object o, String name, Object value) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
public static void invokeSetter(Object o, String name, Object value, Class clazz) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
public static Object invokeGetter(Object o, String name, boolean forceAccess) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
public static Object invokeGetter(Object o, String name) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
public static String invokeStringGetter(Object o, String name) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
public static Object getFieldValue(Object o, Class c, String name) throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException
public static Object getFieldValue(Object o, String name) throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException
public static Object getDeclaredFieldValue(Object o, Class c, String name) throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException
public static Object getDeclaredFieldValue(Object o, String name) throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException
Copyright © 2023 Frank!Framework. All rights reserved.