org.obe.util
Class ClassUtils

java.lang.Object
  extended byorg.obe.util.ClassUtils

public final class ClassUtils
extends java.lang.Object

Provides helpers for performing reflection-based introspections.

Author:
Adrian Price

Field Summary
static java.util.Comparator featureDescriptorComparator
           
 
Method Summary
static java.lang.Class[] classesForNames(java.lang.String[] classNames)
          Returns an array of classes to match the supplied names.
static java.lang.Class classForName(java.lang.String className)
          Returns the class that matches the supplied names.
static java.lang.reflect.Method findMethod(java.lang.String className, java.lang.String methodSig)
          Returns the method that matches a specified signature.
static java.lang.String[] getPropertyNames(java.beans.PropertyDescriptor[] propDescs)
           
static java.beans.PropertyDescriptor[] introspect(java.lang.Class beanClass, java.lang.Class stopClass)
          Introspects properties of the specified class(es) into a map.
static java.lang.String[] namesForClasses(java.lang.Class[] parmTypes)
          Converts an array of classes to an array of class names.
static java.lang.String signatureFromMethod(java.lang.reflect.Method method)
          Generates a string method description from a Method object.
static java.lang.String signatureFromMethod(java.lang.reflect.Method method, boolean includeModifiers, boolean includeReturn, boolean includeClass, boolean includeMethod, boolean includeParameterTypes, boolean includeExceptions)
          Generates a string method description from a Method object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

featureDescriptorComparator

public static final java.util.Comparator featureDescriptorComparator
Method Detail

classForName

public static java.lang.Class classForName(java.lang.String className)
                                    throws java.lang.ClassNotFoundException
Returns the class that matches the supplied names.

N.B. The class name must be specified in Java source form, not the JVM runtime form (which uses non-reversible names for primitive types and somewhat obfuscated names for array types).

Parameters:
className - Class name.
Returns:
Class for supplied name.
Throws:
java.lang.ClassNotFoundException

classesForNames

public static java.lang.Class[] classesForNames(java.lang.String[] classNames)
                                         throws java.lang.ClassNotFoundException
Returns an array of classes to match the supplied names.

N.B. Class names must be specified in Java source form, not the JVM runtime form (which uses non-reversible names for primitive types and somewhat obfuscated names for array types).

Parameters:
classNames - Class names.
Returns:
Classes for supplied names or null if classNames is null.
Throws:
java.lang.ClassNotFoundException

findMethod

public static java.lang.reflect.Method findMethod(java.lang.String className,
                                                  java.lang.String methodSig)
                                           throws java.lang.ClassNotFoundException,
                                                  java.lang.NoSuchMethodException
Returns the method that matches a specified signature.

Parameters:
className - The class that defines the method.
methodSig - The method signature in standard Java source form.
Returns:
The Method object.
Throws:
java.lang.ClassNotFoundException - If the class could be loaded.
java.lang.NoSuchMethodException - If no matching method was found.

getPropertyNames

public static java.lang.String[] getPropertyNames(java.beans.PropertyDescriptor[] propDescs)

introspect

public static java.beans.PropertyDescriptor[] introspect(java.lang.Class beanClass,
                                                         java.lang.Class stopClass)
Introspects properties of the specified class(es) into a map.

Parameters:
beanClass -
stopClass -
Returns:
Array of PropertyDescriptor.

namesForClasses

public static java.lang.String[] namesForClasses(java.lang.Class[] parmTypes)
Converts an array of classes to an array of class names.

Parameters:
parmTypes - Array of classes.
Returns:
A corresponding array of class names in Java source format.

signatureFromMethod

public static java.lang.String signatureFromMethod(java.lang.reflect.Method method)
Generates a string method description from a Method object.

Parameters:
method - Method object.
Returns:
String representation of the method in JVM runtime format.

signatureFromMethod

public static java.lang.String signatureFromMethod(java.lang.reflect.Method method,
                                                   boolean includeModifiers,
                                                   boolean includeReturn,
                                                   boolean includeClass,
                                                   boolean includeMethod,
                                                   boolean includeParameterTypes,
                                                   boolean includeExceptions)
Generates a string method description from a Method object.

Parameters:
method - Method object.
includeModifiers - true to include the modifiers.
includeReturn - true to include the return type.
includeClass - true to include the class name.
includeMethod - true to include the method name.
includeParameterTypes - true to include the parameters.
includeExceptions - true to include the exceptions.
Returns:
String representation of the method in JVM runtime format.


SourceForge.net Logo OBE-1.0 Copyright (c) 2002-2006 Adrian Price. All Rights Reserved.