com.jgoodies.binding.beans
public final class BeanUtils extends java.lang.Object
Introspector
,
BeanInfo
,
PropertyDescriptor
Modifier and Type | Method and Description |
---|---|
static void |
addPropertyChangeListener(java.lang.Object bean,
java.lang.Class<?> beanClass,
java.beans.PropertyChangeListener listener)
Adds a property change listener to the given bean.
|
static void |
addPropertyChangeListener(java.lang.Object bean,
java.lang.Class<?> beanClass,
java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Adds a named property change listener to the given bean.
|
static void |
addPropertyChangeListener(java.lang.Object bean,
java.beans.PropertyChangeListener listener)
Adds a property change listener to the given bean.
|
static void |
addPropertyChangeListener(java.lang.Object bean,
java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Adds a named property change listener to the given bean.
|
static java.lang.reflect.Method |
getNamedPCLAdder(java.lang.Class<?> clazz)
Looks up and returns the method that adds a PropertyChangeListener
for a specified property name to instances of the given class.
|
static java.lang.reflect.Method |
getNamedPCLRemover(java.lang.Class<?> clazz)
Looks up and returns the method that removes a PropertyChangeListener
for a specified property name from instances of the given class.
|
static java.lang.reflect.Method |
getPCLAdder(java.lang.Class<?> clazz)
Looks up and returns the method that adds a multicast
PropertyChangeListener to instances of the given class.
|
static java.lang.reflect.Method |
getPCLRemover(java.lang.Class<?> clazz)
Looks up and returns the method that removes a multicast
PropertyChangeListener from instances of the given class.
|
static java.beans.PropertyDescriptor |
getPropertyDescriptor(java.lang.Class<?> beanClass,
java.lang.String propertyName)
Looks up and returns a
PropertyDescriptor for the
given Java Bean class and property name using the standard
Java Bean introspection behavior. |
static java.beans.PropertyDescriptor |
getPropertyDescriptor(java.lang.Class<?> beanClass,
java.lang.String propertyName,
java.lang.String getterName,
java.lang.String setterName)
Looks up and returns a
PropertyDescriptor for the given
Java Bean class and property name. |
static java.lang.Object |
getValue(java.lang.Object bean,
java.beans.PropertyDescriptor propertyDescriptor)
Returns the value of the specified property of the given non-null bean.
|
static void |
removePropertyChangeListener(java.lang.Object bean,
java.lang.Class<?> beanClass,
java.beans.PropertyChangeListener listener)
Removes a property change listener from the given bean.
|
static void |
removePropertyChangeListener(java.lang.Object bean,
java.lang.Class<?> beanClass,
java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Removes a named property change listener from the given bean.
|
static void |
removePropertyChangeListener(java.lang.Object bean,
java.beans.PropertyChangeListener listener)
Removes a property change listener from the given bean.
|
static void |
removePropertyChangeListener(java.lang.Object bean,
java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Removes a named property change listener from the given bean.
|
static void |
setValue(java.lang.Object bean,
java.beans.PropertyDescriptor propertyDescriptor,
java.lang.Object newValue)
Sets the given object as new value of the specified property of the given
non-null bean.
|
static boolean |
supportsBoundProperties(java.lang.Class<?> clazz)
Checks and answers whether the given class supports bound properties,
i.e.
|
public static boolean supportsBoundProperties(java.lang.Class<?> clazz)
PropertyChangeListener
s:
public void addPropertyChangeListener(PropertyChangeListener x); public void removePropertyChangeListener(PropertyChangeListener x);
clazz
- the class to testpublic static java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.Class<?> beanClass, java.lang.String propertyName) throws java.beans.IntrospectionException
PropertyDescriptor
for the
given Java Bean class and property name using the standard
Java Bean introspection behavior.beanClass
- the type of the bean that holds the propertypropertyName
- the name of the Bean propertyPropertyDescriptor
associated with the given
bean and property name as returned by the Bean introspectionjava.beans.IntrospectionException
- if an exception occurs during
introspection.java.lang.NullPointerException
- if the beanClass or propertyName is null
public static java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.Class<?> beanClass, java.lang.String propertyName, java.lang.String getterName, java.lang.String setterName)
PropertyDescriptor
for the given
Java Bean class and property name. If a getter name or setter name
is available, these are used to create a PropertyDescriptor.
Otherwise, the standard Java Bean introspection is used to determine
the property descriptor.beanClass
- the class of the bean that holds the propertypropertyName
- the name of the property to be accessedgetterName
- the optional name of the property's gettersetterName
- the optional name of the property's setterPropertyDescriptor
associated with the
given bean and property namePropertyNotFoundException
- if the property could not be foundpublic static java.lang.reflect.Method getPCLAdder(java.lang.Class<?> clazz)
clazz
- the class that provides the adder methodpublic static java.lang.reflect.Method getPCLRemover(java.lang.Class<?> clazz)
clazz
- the class that provides the remover methodpublic static java.lang.reflect.Method getNamedPCLAdder(java.lang.Class<?> clazz)
clazz
- the class that provides the adder methodpublic static java.lang.reflect.Method getNamedPCLRemover(java.lang.Class<?> clazz)
clazz
- the class that provides the remover methodpublic static void addPropertyChangeListener(java.lang.Object bean, java.lang.Class<?> beanClass, java.beans.PropertyChangeListener listener)
bean
- the bean to add the property change listener tobeanClass
- the Bean class used to lookup methods fromlistener
- the listener to addjava.lang.NullPointerException
- if the bean or listener is null
java.lang.IllegalArgumentException
- if the bean is not an instance of the bean classPropertyUnboundException
- if the bean does not support bound propertiesPropertyNotBindableException
- if the property change handler cannot be added successfullypublic static void addPropertyChangeListener(java.lang.Object bean, java.lang.Class<?> beanClass, java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public void addPropertyChangeListener(String name, PropertyChangeListener l);
bean
- the bean to add a property change handlerbeanClass
- the Bean class used to lookup methods frompropertyName
- the name of the property to be observedlistener
- the listener to addjava.lang.NullPointerException
- if the bean, propertyName or listener is null
java.lang.IllegalArgumentException
- if the bean is not an instance of the bean classPropertyNotBindableException
- if the property change handler cannot be added successfullypublic static void addPropertyChangeListener(java.lang.Object bean, java.beans.PropertyChangeListener listener)
bean
- the bean to add the property change listener tolistener
- the listener to addjava.lang.NullPointerException
- if the bean or listener is null
PropertyUnboundException
- if the bean does not support bound propertiesPropertyNotBindableException
- if the property change handler cannot be added successfullypublic static void addPropertyChangeListener(java.lang.Object bean, java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public void addPropertyChangeListener(String name, PropertyChangeListener l);
bean
- the bean to add a property change handlerpropertyName
- the name of the property to be observedlistener
- the listener to addjava.lang.NullPointerException
- if the bean, propertyName or listener is null
PropertyNotBindableException
- if the property change handler cannot be added successfullypublic static void removePropertyChangeListener(java.lang.Object bean, java.lang.Class<?> beanClass, java.beans.PropertyChangeListener listener)
bean
- the bean to remove the property change listener frombeanClass
- the Java Bean class used to lookup methods fromlistener
- the listener to removejava.lang.NullPointerException
- if the bean or listener is null
java.lang.IllegalArgumentException
- if the bean is not an instance of the bean classPropertyUnboundException
- if the bean does not support bound propertiesPropertyNotBindableException
- if the property change handler cannot be removed successfullypublic static void removePropertyChangeListener(java.lang.Object bean, java.lang.Class<?> beanClass, java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public void removePropertyChangeHandler(String name, PropertyChangeListener l);
bean
- the bean to remove the property change listener frombeanClass
- the Java Bean class used to lookup methods frompropertyName
- the name of the observed propertylistener
- the listener to removejava.lang.NullPointerException
- if the bean, propertyName, or listener is null
java.lang.IllegalArgumentException
- if the bean is not an instance of the bean classPropertyNotBindableException
- if the property change handler cannot be removed successfullypublic static void removePropertyChangeListener(java.lang.Object bean, java.beans.PropertyChangeListener listener)
bean
- the bean to remove the property change listener fromlistener
- the listener to removejava.lang.NullPointerException
- if the bean or listener is null
PropertyUnboundException
- if the bean does not support bound propertiesPropertyNotBindableException
- if the property change handler cannot be removed successfullypublic static void removePropertyChangeListener(java.lang.Object bean, java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public void removePropertyChangeHandler(String name, PropertyChangeListener l);
bean
- the bean to remove the property change listener frompropertyName
- the name of the observed propertylistener
- the listener to removejava.lang.NullPointerException
- if the bean, propertyName, or listener is null
PropertyNotBindableException
- if the property change handler cannot be removed successfullypublic static java.lang.Object getValue(java.lang.Object bean, java.beans.PropertyDescriptor propertyDescriptor)
If the read access fails, a PropertyAccessException is thrown that provides the Throwable that caused the failure.
bean
- the bean to read the value frompropertyDescriptor
- describes the property to be readjava.lang.NullPointerException
- if the bean is null
java.lang.UnsupportedOperationException
- if the bean property is write-onlyPropertyAccessException
- if the new value could not be readpublic static void setValue(java.lang.Object bean, java.beans.PropertyDescriptor propertyDescriptor, java.lang.Object newValue) throws java.beans.PropertyVetoException
If the write access fails, a PropertyAccessException is thrown that provides the Throwable that caused the failure. If the bean property is constrained and a VetoableChangeListener has vetoed against the value change, the PropertyAccessException wraps the PropertyVetoException thrown by the setter.
bean
- the bean that holds the adapted propertypropertyDescriptor
- describes the property to be setnewValue
- the property value to be setjava.lang.NullPointerException
- if the bean is null
java.lang.UnsupportedOperationException
- if the bean property is read-onlyPropertyAccessException
- if the new value could not be setjava.beans.PropertyVetoException
- if the bean setter throws this exceptionCopyright © 2002-2010 JGoodies Karsten Lentzsch. All Rights Reserved.