public abstract class ClassUtils extends Object
Constructor and Description |
---|
ClassUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
classNameOf(Object o)
returns the className of the object, like
nameOf(Object) , but without [name] suffix for a INamedObject . |
static <T> T |
convertToType(Class<T> type,
String value)
Converts the String value to the supplied type.
|
static String |
debugObject(Object o) |
static Map<String,Object> |
getClassInfo(Class<?> clazz,
ClassLoader classLoader) |
static List<Object> |
getClassInfoList(Class<?> clazz) |
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 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 bean,
Method method,
String valueToSet)
Throws IllegalArgumentException if the argument type is incompatible
Throws IllegalStateException if the argument cannot be set on the target bean
|
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 boolean |
isClassPresent(String classname) |
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 String |
which(Class<?> aClass)
Gets the absolute pathname of the class file containing the specified class name, as prescribed by the current classpath.
|
public static URL getResourceURL(String resource) throws FileNotFoundException
FileNotFoundException
public static Constructor<?> getConstructorOnType(Class<?> clas, Class<?>[] parameterTypes) throws NoSuchMethodException
NoSuchMethodException
public static long lastModified(Class<?> aClass) throws IllegalArgumentException
aClass
- A class whose last modification date is queriedIllegalArgumentException
- The class was not loaded from a file or directorypublic static Object newInstance(String className) throws Exception
className
- A class nameException
- If an instantiation error occurspublic static Class<?> loadClass(String className) throws ClassNotFoundException
className
- A class nameclassName
ClassNotFoundException
- If a loading error occurspublic static String which(Class<?> aClass)
@Nonnull public static String nameOf(Object o)
@Nonnull public static String classNameOf(Object o)
nameOf(Object)
, but without [name] suffix for a INamedObject
.public static boolean isClassPresent(String classname)
public static void invokeSetter(Object bean, Method method, String valueToSet)
@Nonnull public static <T> T convertToType(Class<T> type, String value) throws IllegalArgumentException
type
- to convert the input value toIllegalArgumentException
- (or NumberFormatException) when the value cannot be converted to the given type T.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
public static String getCleanedFilePath(String path)
public static List<Object> getClassInfoList(Class<?> clazz) throws IOException
IOException
public static Map<String,Object> getClassInfo(Class<?> clazz, ClassLoader classLoader) throws IOException
IOException
Copyright © 2023 Frank!Framework. All rights reserved.