Framework Professional Edition Package


com.prosyst.util.beans
Class BeanUtils

java.lang.Object
  extended by com.prosyst.util.beans.BeanUtils

public class BeanUtils
extends java.lang.Object

Utility class for processing Java Beans. It refers to the rather extensive JavaBeans Specification in a very constrained manner, not considering beans as "a reusable software component that can be manipulated visually in a builder tool", not taking into account their possible usage and not using their full set of features like events, persistence, etc. It just considers beans as Java classes that contain standard Java bean accessor methods for properties. A bean property is a value that can be retrieved and changed using standard accessor methods. These methods are two types: getters (readers, reader methods) and setters (writers, writer methods) and must respect some naming rules. Getters have the form 'getXxx' and 'isXxx', where 'xxx' is the name of the property. Setters have the form 'setXxx' where 'xxx' is the name of the property. So method names are constructed by appending the property name with capitalized first letter after 'get', 'is' or 'set'. A bean property has also a type. It is the same as the return type of the getter and the argument type of the setter method. Bean properties are represented by the BeanProperty and IndexedBeanProperty classes, which encapsulate the name and type of the property and its methods. BeanUtils uses reflection mechanisms to process classes. It caches the retrieved bean properties for faster access.

Author:
Krasimir Nedkov, Valentin Valchev

Constructor Summary
BeanUtils()
           
 
Method Summary
static void cleanCache()
          Cleans the whole cache for all beans.
static void cleanFromCache(java.lang.Class c)
          Cleans the cached BeanProperty info for a given bean class.
static BeanProperty getBeanProperty(java.lang.String name, java.lang.Class beanClass)
          Return a BeanProperty for the given property name.
static BeanProperty getIndexedBeanProperty(java.lang.String name, java.lang.Class beanClass)
          Return an IndexedBeanProperty for the given property name.
static java.lang.Object instantiate(java.lang.ClassLoader cls, java.lang.String beanName)
          Creates an instance of a class with the given name, using the provided ClassLoader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanUtils

public BeanUtils()
Method Detail

getBeanProperty

public static final BeanProperty getBeanProperty(java.lang.String name,
                                                 java.lang.Class beanClass)
                                          throws BeanException
Return a BeanProperty for the given property name.

Parameters:
name - property name
beanClass - bean class to process
Returns:
the desired BeanProperty or null if not found
Throws:
BeanException

getIndexedBeanProperty

public static final BeanProperty getIndexedBeanProperty(java.lang.String name,
                                                        java.lang.Class beanClass)
                                                 throws BeanException
Return an IndexedBeanProperty for the given property name.

Parameters:
name - property name
beanClass - bean class to process
Returns:
the desired BeanProperty or null if not found
Throws:
BeanException

cleanFromCache

public static void cleanFromCache(java.lang.Class c)
Cleans the cached BeanProperty info for a given bean class.

Parameters:
c - the class of the bean

cleanCache

public static void cleanCache()
Cleans the whole cache for all beans.


instantiate

public static java.lang.Object instantiate(java.lang.ClassLoader cls,
                                           java.lang.String beanName)
                                    throws java.lang.ClassNotFoundException,
                                           java.lang.InstantiationException,
                                           java.lang.IllegalAccessException
Creates an instance of a class with the given name, using the provided ClassLoader. If the ClassLoader is null, the current ClassLoader will be used.

Parameters:
cls - ClassLoader to use for class loading or null
beanName - fully qualified java class name
Returns:
an instance of the provided class
Throws:
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException

Framework Professional Edition Package


Copyright © 1999-2007 ProSyst Software GmbH. All Rights Reserved