org.apache.jackrabbit.ocm.reflection
Class ReflectionUtils

java.lang.Object
  extended by org.apache.jackrabbit.ocm.reflection.ReflectionUtils

public abstract class ReflectionUtils
extends Object

Utility class for handling reflection using BeanUtils.

Author:
Alexandru Popescu

Constructor Summary
ReflectionUtils()
           
 
Method Summary
static Class forName(String clazz)
           
static Class getAncestorClass(Class clazz)
           
static Class getBeanClass(Object bean)
           
static ClassLoader getClassLoader()
          Returns the class loader which is used by the forName(String) method to load classes.
static Class getDefaultImplementation(Class clazz)
          Get the default implementation for an interface
static Class[] getInterfaces(Class clazz)
           
static Object getNestedProperty(Object object, String fieldName)
           
static Class getPropertyType(Object object, String fieldName)
           
static boolean implementsInterface(Class clazz, Class interfaceClass)
          Check if an class is implementing an specific interface.
static Object invokeConstructor(String className, Object[] params)
           
static boolean isAbstractClass(Class clazz)
           
static boolean isProxy(Class beanClass)
           
static Object newInstance(Class clazz)
           
static Object newInstance(String clazz)
           
static void setClassLoader(ClassLoader newClassLoader)
          Sets the class loader to use in the forName(String) method to load classes.
static void setNestedProperty(Object object, String fieldName, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionUtils

public ReflectionUtils()
Method Detail

setClassLoader

public static void setClassLoader(ClassLoader newClassLoader)
Sets the class loader to use in the forName(String) method to load classes.

Care must be taken when using this method as when setting an improperly set up classloader, the mapper will not work again throwing tons of exceptions.

Parameters:
newClassLoader - The new class loader to use. This may be null in which case the system class loader will be used.

getClassLoader

public static ClassLoader getClassLoader()
Returns the class loader which is used by the forName(String) method to load classes.

Returns:
The class loader used by forName(String) or null if the system class loader is used.

getNestedProperty

public static Object getNestedProperty(Object object,
                                       String fieldName)

getPropertyType

public static Class getPropertyType(Object object,
                                    String fieldName)

newInstance

public static Object newInstance(Class clazz)

invokeConstructor

public static Object invokeConstructor(String className,
                                       Object[] params)
Parameters:
className -
objects -
Returns:

setNestedProperty

public static void setNestedProperty(Object object,
                                     String fieldName,
                                     Object value)
Parameters:
object -
fieldName -
path -

newInstance

public static Object newInstance(String clazz)
Parameters:
string -
Returns:

forName

public static Class forName(String clazz)
Parameters:
elementClassName -
Returns:

isProxy

public static boolean isProxy(Class beanClass)

getBeanClass

public static Class getBeanClass(Object bean)

implementsInterface

public static boolean implementsInterface(Class clazz,
                                          Class interfaceClass)
Check if an class is implementing an specific interface.

Parameters:
clazz -
interfaceClass -
Returns:
true if the class is implementing the interface otherwise false

getDefaultImplementation

public static Class getDefaultImplementation(Class clazz)
Get the default implementation for an interface

Parameters:
clazz - The interface clazz
Returns:
The class matching to the interface default interface

isAbstractClass

public static boolean isAbstractClass(Class clazz)

getAncestorClass

public static Class getAncestorClass(Class clazz)

getInterfaces

public static Class[] getInterfaces(Class clazz)


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.