org.jasig.cas.client.util
Class ReflectUtils

java.lang.Object
  extended by org.jasig.cas.client.util.ReflectUtils

public final class ReflectUtils
extends Object

Helper class with reflection utility methods.

Since:
3.1.11
Version:
$Revision: 22122 $
Author:
Marvin S. Addison

Method Summary
static PropertyDescriptor getPropertyDescriptor(BeanInfo info, String propertyName)
          Gets the property descriptor for the named property from the bean info describing a particular class to which property belongs.
static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String propertyName)
          Gets the property descriptor for the named property on the given class.
static
<T> Class<T>
loadClass(String className)
          Attempts to create a class from a String.
static
<T> T
newInstance(Class<T> clazz, Object... args)
          Creates a new instance of the given class by passing the given arguments to the constructor.
static
<T> T
newInstance(String className, Object... args)
          Creates a new instance of the given class by passing the given arguments to the constructor.
static void setProperty(String propertyName, Object value, Object target)
          Sets the given property on the target JavaBean using bean instrospection.
static void setProperty(String propertyName, Object value, Object target, BeanInfo info)
          Sets the given property on the target JavaBean using bean instrospection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadClass

public static <T> Class<T> loadClass(String className)
                          throws IllegalArgumentException
Attempts to create a class from a String.

Parameters:
className - the name of the class to create.
Returns:
the class. CANNOT be NULL.
Throws:
IllegalArgumentException - if the className does not exist.

newInstance

public static <T> T newInstance(String className,
                                Object... args)
Creates a new instance of the given class by passing the given arguments to the constructor.

Parameters:
className - Name of class to be created.
args - Constructor arguments.
Returns:
New instance of given class.

newInstance

public static <T> T newInstance(Class<T> clazz,
                                Object... args)
Creates a new instance of the given class by passing the given arguments to the constructor.

Parameters:
clazz - Class of instance to be created.
args - Constructor arguments.
Returns:
New instance of given class.

getPropertyDescriptor

public static PropertyDescriptor getPropertyDescriptor(Class<?> clazz,
                                                       String propertyName)
Gets the property descriptor for the named property on the given class.

Parameters:
clazz - Class to which property belongs.
propertyName - Name of property.
Returns:
Property descriptor for given property or null if no property with given name exists in given class.

getPropertyDescriptor

public static PropertyDescriptor getPropertyDescriptor(BeanInfo info,
                                                       String propertyName)
Gets the property descriptor for the named property from the bean info describing a particular class to which property belongs.

Parameters:
info - Bean info describing class to which property belongs.
propertyName - Name of property.
Returns:
Property descriptor for given property or null if no property with given name exists.

setProperty

public static void setProperty(String propertyName,
                               Object value,
                               Object target)
Sets the given property on the target JavaBean using bean instrospection.

Parameters:
propertyName - Property to set.
value - Property value to set.
target - Target java bean on which to set property.

setProperty

public static void setProperty(String propertyName,
                               Object value,
                               Object target,
                               BeanInfo info)
Sets the given property on the target JavaBean using bean instrospection.

Parameters:
propertyName - Property to set.
value - Property value to set.
target - Target JavaBean on which to set property.
info - BeanInfo describing the target JavaBean.


Copyright © 2006-2011 Jasig. All Rights Reserved.