| java.lang.Object org.compass.core.util.ClassUtils
ClassUtils | abstract public class ClassUtils (Code) | | Miscellaneous class utility methods. Mainly for internal use within the
framework; consider Jakarta's Commons Lang for a more comprehensive suite
of utilities.
author: kimchy |
Method Summary | |
public 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. | public 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 ('/'). | public static Class | forName(String name, ClassLoader classLoader) Replacement for Class.forName() that also returns Class instances
for primitives (like "int") and array class names (like "String[]"). | public static Class[] | getAllInterfaces(Object object) Return all interfaces that the given object implements as array,
including ones implemented by superclasses. | public static Set | getAllInterfacesAsSet(Object object) Return all interfaces that the given object implements as List,
including ones implemented by superclasses. | public static Class[] | getAllInterfacesForClass(Class clazz) Return all interfaces that the given class implements as array,
including ones implemented by superclasses. | public static Set | getAllInterfacesForClassAsSet(Class clazz) Return all interfaces that the given class implements as Set,
including ones implemented by superclasses. | public static Constructor | getDefaultConstructor(Class clazz) Returns the default constructor for the class. | public static int | getMethodCountForName(Class clazz, String methodName) Return the number of methods with a given name (with any argument types),
for the given class and/or its superclasses. | public static String | getQualifiedMethodName(Method method) Return the qualified name of the given method, consisting of
fully qualified interface/class name + "." + method name. | public static String | getShortName(Class clazz) Get the class name without the qualified package name. | public static String | getShortName(String className) Get the class name without the qualified package name. | public static String | getShortNameAsProperty(Class clazz) Return the short string name of a Java class in decapitalized
JavaBeans property format. | public static String | getShortNameForField(Field field) | public static String | getShortNameForMethod(Method method) | public static Method | getStaticMethod(Class clazz, String methodName, Class[] args) Return a static method of a class. | public static boolean | hasAtLeastOneMethodWithName(Class clazz, 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. | public static boolean | hasMethod(Class clazz, String methodName, Class[] paramTypes) Determine whether the given class has a method with the given signature. | public static boolean | isAbstractClass(Class clazz) Returns true of the class is an abstract class. | public static boolean | isPublic(Class clazz, Member member) Returns true if the member is public and the class
is public. | public static Class | resolvePrimitiveClassName(String name) Resolve the given class name as primitive class, if appropriate. |
ARRAY_SUFFIX | final public static String ARRAY_SUFFIX(Code) | | Suffix for array class names
|
addResourcePathToPackagePath | public static String addResourcePathToPackagePath(Class clazz, String resourceName)(Code) | | Return a path suitable for use with ClassLoader.getResource (also
suitable for use with Class.getResource by prepending a slash ('/') to
the return value. Built by taking the package of the specified class
file, converting all dots ('.') to slashes ('/'), adding a trailing slash
if necesssary, and concatenating the specified resource name to this.
As such, this function may be used to build a path suitable for
loading a resource file that is in the same package as a class file,
although {link org.springframework.core.io.ClassPathResource} is usually
even more convenient.
Parameters: clazz - the Class whose package will be used as the base Parameters: resourceName - the resource name to append. A leading slash is optional. the built-up resource path See Also: java.lang.ClassLoader.getResource See Also: java.lang.Class.getResource |
classPackageAsResourcePath | public static String classPackageAsResourcePath(Class clazz)(Code) | | 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 ('/'). Neither a leading nor trailing slash is added. The result
could be concatenated with a slash and the name of a resource, and fed
directly to ClassLoader.getResource(). For it to be fed to Class.getResource,
a leading slash would also have to be prepended to the return value.
Parameters: clazz - the input class. A null value or the default (empty) packagewill result in an empty string ("") being returned. a path which represents the package name See Also: java.lang.ClassLoader.getResource See Also: java.lang.Class.getResource |
getAllInterfaces | public static Class[] getAllInterfaces(Object object)(Code) | | Return all interfaces that the given object implements as array,
including ones implemented by superclasses.
Parameters: object - the object to analyse for interfaces all interfaces that the given object implements as array |
getAllInterfacesAsSet | public static Set getAllInterfacesAsSet(Object object)(Code) | | Return all interfaces that the given object implements as List,
including ones implemented by superclasses.
Parameters: object - the object to analyse for interfaces all interfaces that the given object implements as List |
getAllInterfacesForClass | public static Class[] getAllInterfacesForClass(Class clazz)(Code) | | Return all interfaces that the given class implements as array,
including ones implemented by superclasses.
Parameters: clazz - the class to analyse for interfaces all interfaces that the given object implements as array |
getAllInterfacesForClassAsSet | public static Set getAllInterfacesForClassAsSet(Class clazz)(Code) | | Return all interfaces that the given class implements as Set,
including ones implemented by superclasses.
Parameters: clazz - the class to analyse for interfaces all interfaces that the given object implements as Set |
getDefaultConstructor | public static Constructor getDefaultConstructor(Class clazz)(Code) | | Returns the default constructor for the class. If it is not visible,
will set it to be accessible.
Parameters: clazz - the class to get the default constructor the default constructor |
getMethodCountForName | public static int getMethodCountForName(Class clazz, String methodName)(Code) | | Return the number of methods with a given name (with any argument types),
for the given class and/or its superclasses. Includes non-public methods.
Parameters: clazz - the clazz to check Parameters: methodName - the name of the method the number of methods with the given name |
getQualifiedMethodName | public static String getQualifiedMethodName(Method method)(Code) | | Return the qualified name of the given method, consisting of
fully qualified interface/class name + "." + method name.
Parameters: method - the method the qualified name of the method |
getShortName | public static String getShortName(Class clazz)(Code) | | Get the class name without the qualified package name.
Parameters: clazz - the class to get the short name for the class name of the class without the package name throws: IllegalArgumentException - if the class is null |
getShortName | public static String getShortName(String className)(Code) | | Get the class name without the qualified package name.
Parameters: className - the className to get the short name for the class name of the class without the package name throws: IllegalArgumentException - if the className is empty |
getShortNameAsProperty | public static String getShortNameAsProperty(Class clazz)(Code) | | Return the short string name of a Java class in decapitalized
JavaBeans property format.
Parameters: clazz - the class the short name rendered in a standard JavaBeans property format See Also: java.beans.Introspector.decapitalize(String) |
getStaticMethod | public static Method getStaticMethod(Class clazz, String methodName, Class[] args)(Code) | | Return a static method of a class.
Parameters: methodName - the static method name Parameters: clazz - the class which defines the method Parameters: args - the parameter types to the method the static method, or null if no static method was found throws: IllegalArgumentException - if the method name is blank or the clazz is null |
hasAtLeastOneMethodWithName | public static boolean hasAtLeastOneMethodWithName(Class clazz, String methodName)(Code) | | Does the given class and/or its superclasses at least have one or more
methods (with any argument types)? Includes non-public methods.
Parameters: clazz - the clazz to check Parameters: methodName - the name of the method whether there is at least one method with the given name |
hasMethod | public static boolean hasMethod(Class clazz, String methodName, Class[] paramTypes)(Code) | | Determine whether the given class has a method with the given signature.
Essentially translates NoSuchMethodException to "false".
Parameters: clazz - the clazz to analyze Parameters: methodName - the name of the method Parameters: paramTypes - the parameter types of the method |
isAbstractClass | public static boolean isAbstractClass(Class clazz)(Code) | | Returns true of the class is an abstract class. An
abstract class is a either an abstract class or an interface.
Parameters: clazz - the class to check for abstact true if the class is an abstract class |
isPublic | public static boolean isPublic(Class clazz, Member member)(Code) | | Returns true if the member is public and the class
is public.
Parameters: clazz - the class to check for public Parameters: member - the member to check for public true if the member is public and the class is public |
resolvePrimitiveClassName | public static Class resolvePrimitiveClassName(String name)(Code) | | Resolve the given class name as primitive class, if appropriate.
Parameters: name - the name of the potentially primitive class the primitive class, or null if the name does not denotea primitive class |
|
|