|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.util.ClassUtils
Miscellaneous class utility methods. Mainly for internal use within the framework; consider Jakarta's Commons Lang for a more comprehensive suite of utilities.
Field Summary | |
static String |
ARRAY_SUFFIX
Suffix for array class names |
Constructor Summary | |
ClassUtils()
|
Method Summary | |
static String |
addResourcePathToPackagePath(Class clazz,
String resourceName)
Return a path suitable for use with ClassLoader.getResource (also suitable for use with Class.getResource by prepending a slash ('/') to the return value. |
static String |
classPackageAsResourcePath(Class clazz)
Given an input class object, return a string which consists of the class's package name as a pathname, i.e., all dots ('.') are replaced by slashes ('/'). |
static Class |
forName(String name)
Replacement for Class.forName() that also returns Class instances
for primitives (like "int") and array class names (like "String[]").
|
static String |
getShortName(Class clazz)
Get the class name without the qualified package name. |
static String |
getShortName(String className)
Get the class name without the qualified package name. |
static String |
getShortNameAsProperty(Class clazz)
Return the uncaptilized short string name of a Java class. |
static Method |
getStaticMethod(Class clazz,
String methodName,
Class[] args)
Return a static method of a class. |
static boolean |
hasAtLeastOneMethodWithName(Class clazz,
String methodName)
Does the given class or/and its superclasses at least have one or more methods (with any argument types)? |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String ARRAY_SUFFIX
Constructor Detail |
public ClassUtils()
Method Detail |
public static Class forName(String name) throws ClassNotFoundException
Class.forName()
that also returns Class instances
for primitives (like "int") and array class names (like "String[]").
Always uses the thread context class loader.
name
- the name of the Class
ClassNotFoundException
Class.forName(java.lang.String)
,
Thread.getContextClassLoader()
public static String getShortName(Class clazz)
clazz
- the class to get the short name for
IllegalArgumentException
- if the class is nullpublic static String getShortNameAsProperty(Class clazz)
clazz
- the class
public static String getShortName(String className)
className
- the className to get the short name for
IllegalArgumentException
- if the className is emptypublic static boolean hasAtLeastOneMethodWithName(Class clazz, String methodName)
clazz
- the clazz to checkmethodName
- the name of the method
public static Method getStaticMethod(Class clazz, String methodName, Class[] args)
methodName
- the static method nameclazz
- the class which defines the methodargs
- the parameter types to the method
IllegalArgumentException
- if the method name is blank or the clazz is nullpublic static String addResourcePathToPackagePath(Class clazz, String resourceName)
clazz
- the Class whose package will be used as the baseresourceName
- the resource name to append. A leading slash is optional.
ClassLoader.getResource(String)
,
Class.getResource(String)
public static String classPackageAsResourcePath(Class clazz)
clazz
- the input class. A null value or the default (empty) package
will result in an empty string ("") being returned.
ClassLoader.getResource(String)
,
Class.getResource(String)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |