|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.directory.shared.ldap.util.SpringClassUtils
public abstract class SpringClassUtils
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 java.lang.String |
ARRAY_SUFFIX
Suffix for array class names |
Constructor Summary | |
---|---|
SpringClassUtils()
|
Method Summary | |
---|---|
static java.lang.String |
addResourcePathToPackagePath(java.lang.Class clazz,
java.lang.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 java.lang.String |
classPackageAsResourcePath(java.lang.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 java.lang.Class |
forName(java.lang.String name)
Replacement for Class.forName() that also returns Class instances
for primitives (like "int") and array class names (like "String[]"). |
static java.lang.Class |
forName(java.lang.String name,
java.lang.ClassLoader classLoader)
Replacement for Class.forName() that also returns Class instances
for primitives (like "int") and array class names (like "String[]"). |
static java.lang.Class[] |
getAllInterfaces(java.lang.Object object)
Return all interfaces that the given object implements as array, including ones implemented by superclasses. |
static java.util.Set<java.lang.Class> |
getAllInterfacesAsSet(java.lang.Object object)
Return all interfaces that the given object implements as List, including ones implemented by superclasses. |
static java.lang.Class[] |
getAllInterfacesForClass(java.lang.Class clazz)
Return all interfaces that the given class implements as array, including ones implemented by superclasses. |
static java.util.Set<java.lang.Class> |
getAllInterfacesForClassAsSet(java.lang.Class clazz)
Return all interfaces that the given class implements as Set, including ones implemented by superclasses. |
static java.lang.ClassLoader |
getDefaultClassLoader()
Return a default ClassLoader to use (never null ). |
static int |
getMethodCountForName(java.lang.Class clazz,
java.lang.String methodName)
Return the number of methods with a given name (with any argument types), for the given class and/or its superclasses. |
static java.lang.String |
getQualifiedMethodName(java.lang.reflect.Method method)
Return the qualified name of the given method, consisting of fully qualified interface/class name + "." + method name. |
static java.lang.String |
getShortName(java.lang.Class clazz)
Get the class name without the qualified package name. |
static java.lang.String |
getShortName(java.lang.String className)
Get the class name without the qualified package name. |
static java.lang.String |
getShortNameAsProperty(java.lang.Class clazz)
Return the short string name of a Java class in decapitalized JavaBeans property format. |
static java.lang.reflect.Method |
getStaticMethod(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Class[] args)
Return a static method of a class. |
static boolean |
hasAtLeastOneMethodWithName(java.lang.Class clazz,
java.lang.String methodName)
Does the given class and/or its superclasses at least have one or more methods (with any argument types)? Includes non-public methods. |
static boolean |
hasMethod(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Class[] paramTypes)
Determine whether the given class has a method with the given signature. |
static java.lang.Class |
resolvePrimitiveClassName(java.lang.String name)
Resolve the given class name as primitive class, if appropriate. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ARRAY_SUFFIX
Constructor Detail |
---|
public SpringClassUtils()
Method Detail |
---|
public static java.lang.ClassLoader getDefaultClassLoader()
null
).
Returns the thread context ClassLoader, if available.
The ClassLoader that loaded the ClassUtils class will be used as fallback.
Call this method if you intend to use the thread context ClassLoader
in a scenario where you absolutely need a non-null ClassLoader reference:
for example, for class path resource loading (but not necessarily for
Class.forName
, which accepts a null
ClassLoader
reference as well).
Thread.getContextClassLoader()
public static java.lang.Class forName(java.lang.String name) throws java.lang.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
java.lang.ClassNotFoundException
Class.forName(String, boolean, ClassLoader)
,
Thread.getContextClassLoader()
public static java.lang.Class forName(java.lang.String name, java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundException
Class.forName()
that also returns Class instances
for primitives (like "int") and array class names (like "String[]").
name
- the name of the ClassclassLoader
- the class loader to use
java.lang.ClassNotFoundException
Class.forName(String, boolean, ClassLoader)
,
Thread.getContextClassLoader()
public static java.lang.Class resolvePrimitiveClassName(java.lang.String name)
name
- the name of the potentially primitive class
null
if the name does not denote
a primitive classpublic static java.lang.String getShortNameAsProperty(java.lang.Class clazz)
clazz
- the class
Introspector.decapitalize(String)
public static java.lang.String getShortName(java.lang.Class clazz)
clazz
- the class to get the short name for
java.lang.IllegalArgumentException
- if the class is nullpublic static java.lang.String getShortName(java.lang.String className)
className
- the className to get the short name for
java.lang.IllegalArgumentException
- if the className is emptypublic static java.lang.String getQualifiedMethodName(java.lang.reflect.Method method)
method
- the method
public static boolean hasMethod(java.lang.Class clazz, java.lang.String methodName, java.lang.Class[] paramTypes)
NoSuchMethodException
to "false".
clazz
- the clazz to analyzemethodName
- the name of the methodparamTypes
- the parameter types of the methodpublic static int getMethodCountForName(java.lang.Class clazz, java.lang.String methodName)
clazz
- the clazz to checkmethodName
- the name of the method
public static boolean hasAtLeastOneMethodWithName(java.lang.Class clazz, java.lang.String methodName)
clazz
- the clazz to checkmethodName
- the name of the method
public static java.lang.reflect.Method getStaticMethod(java.lang.Class clazz, java.lang.String methodName, java.lang.Class[] args)
methodName
- the static method nameclazz
- the class which defines the methodargs
- the parameter types to the method
null
if no static method was found
java.lang.IllegalArgumentException
- if the method name is blank or the clazz is nullpublic static java.lang.String addResourcePathToPackagePath(java.lang.Class clazz, java.lang.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(java.lang.String)
,
Class.getResource(java.lang.String)
public static java.lang.String classPackageAsResourcePath(java.lang.Class clazz)
clazz
- the input class. A null value or the default (empty) package
will result in an empty string ("") being returned.
ClassLoader.getResource(java.lang.String)
,
Class.getResource(java.lang.String)
public static java.lang.Class[] getAllInterfaces(java.lang.Object object)
object
- the object to analyse for interfaces
public static java.lang.Class[] getAllInterfacesForClass(java.lang.Class clazz)
clazz
- the class to analyse for interfaces
public static java.util.Set<java.lang.Class> getAllInterfacesAsSet(java.lang.Object object)
object
- the object to analyse for interfaces
public static java.util.Set<java.lang.Class> getAllInterfacesForClassAsSet(java.lang.Class clazz)
clazz
- the class to analyse for interfaces
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |