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 String |
debugObject(Object o) |
static List<String> |
getAllowedProtocols() |
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(IScopeProvider scopeProvider,
String resource)
Get a resource-URL from a specific IConfigurationClassLoader.
|
static URL |
getResourceURL(IScopeProvider scopeProvider,
String resource,
String allowedProtocols)
Get a resource-URL from a ClassLoader, therefore the resource should not start with a leading slash
|
static URL |
getResourceURL(String resource)
Get a resource-URL directly from the ClassPath
|
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) |
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(ClassLoader classLoader)
If the classLoader is derivable of IConfigurationClassLoader return the className + configurationName,
else return the className of the object.
|
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 Reader |
urlToReader(URL url) |
static Reader |
urlToReader(URL url,
int timeoutMs) |
static InputStream |
urlToStream(URL url,
int timeoutMs) |
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 Constructor<?> getConstructorOnType(Class<?> clas, Class<?>[] parameterTypes) throws NoSuchMethodException
NoSuchMethodException
public static URL getResourceURL(String resource)
resource
- name of the resource you are trying to fetch the URL frompublic static URL getResourceURL(IScopeProvider scopeProvider, String resource)
IbisContext.init()
public static URL getResourceURL(IScopeProvider scopeProvider, String resource, String allowedProtocols)
scopeProvider
- to retrieve the file from, or NULL when you want to retrieve the resource directly from the ClassPath (using an absolute path)resource
- name of the resource you are trying to fetch the URL frompublic static InputStream urlToStream(URL url, int timeoutMs) throws IOException
IOException
public static Reader urlToReader(URL url) throws IOException
IOException
public static Reader urlToReader(URL url, int timeoutMs) throws IOException
IOException
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)
public static String nameOf(ClassLoader classLoader)
public static String nameOf(Object o)
public static String classNameOf(Object o)
nameOf(Object)
, but without [name] suffix for a INamedObject
.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.