public class BeanUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static void |
addWeakListenerByReflection(java.beans.PropertyChangeListener listener,
java.lang.Object source)
Add a weak PropertyChangeListener to an object, using reflection to look up the addPropertyChangeListener method
|
static java.lang.Class |
findTargetClass(java.lang.Object bean)
Finds the first public superclass of the given bean.
|
static java.lang.String |
generateUniqueBeanName(java.lang.Object bean)
Generates a unique name for the bean using the same convention as the
implementation of toString() in Object, which is :
"bean class name"+@+"hash code of the bean in hexadecimal"
|
static boolean |
hasExplicitBeanInfo(java.lang.Class clazz)
Checks whether there is an explicit bean info for given class.
|
static java.awt.Image |
loadImage(java.lang.String imagePathname,
java.lang.Class relatedClass)
This is a utility method to help in loading icon images.
|
static void |
registerBeanInfoSearchPaths(java.lang.String[] pathsToRegister)
Registers a set of paths in the
BeanInfo search path of
the java.beans.Introspector. |
static void |
registerEditorSearchPaths(java.lang.String[] pathsToRegister)
Registers a set of paths in the
PropertyEditor search path of
the java.beans.PropertyEditorManager. |
public static final java.lang.String generateUniqueBeanName(java.lang.Object bean)
bean - the bean the name has to be generated frompublic static final void registerEditorSearchPaths(java.lang.String[] pathsToRegister)
PropertyEditor search path of
the java.beans.PropertyEditorManager.
Use this method when you have PropertyEditor named following the convention
TypenameEditor that are not located in the same package as Typename.
For a given java type a.b.X, the java.beans.PropertyEditorManager will
first check if there is an editor registered for the type, if not it will look for the editor
a.b.XEditor and if not found it will look in the search path for the class XEditor.
You can use this method to register the path where XEditor is. For instance, if the editor is located in
a.c.d.XEditor you would pass in parameter to this method new String[] {"a.c.d"}.
Note that paths are not added if they are already present.
pathsToRegister - the array of paths to register in the search path of the PropertyEditorManager.public static final void registerBeanInfoSearchPaths(java.lang.String[] pathsToRegister)
BeanInfo search path of
the java.beans.Introspector.
Use this method when you have BeanInfo named following the convention BeanNameBeanInfo that are
not located in the same package as BeanName. For a given java bean a.b.X, the java.beans.
Introspector will first check if there is a BeanInfo a.b.XBeanInfo and if not found it will look in
the search path for the class XBeanInfo. You can use this method to register the path where XBeanInfo
is. For instance, if the BeanInfo is located in a.c.d.XBeanInfo you would pass in parameter
to this method new String [] {"a.c.d"}.
Note that paths are not added if they are already present.
pathsToRegister - the array of paths to register in the search path of the Introspector.public static final java.awt.Image loadImage(java.lang.String imagePathname,
java.lang.Class relatedClass)
The pathname should be relative to the given class and be contained in the classpath.
For instance if the related class is in cern.gp.beans and the icon is stored in
cern/gp/beans/images/MyIcon.gif the pathname to give would be
images/MyIcon.gif.
imagePathname - A pathname relative to the directory holding the class file of
the given relatedClass. For example, images/MyIcon.gif.relatedClass - the class the image is related with.public static final java.lang.Class findTargetClass(java.lang.Object bean)
bean - the bean to find the public class frompublic static final boolean hasExplicitBeanInfo(java.lang.Class clazz)
clazz - the class to testpublic static void addWeakListenerByReflection(java.beans.PropertyChangeListener listener,
java.lang.Object source)
listener - the listener to addsource - the object to which a PCL shall be added