Consists exclusively of static methods that provide
convenience behavior for working with Java Bean properties.
addPropertyChangeListener
public static void addPropertyChangeListener(Object bean,
Class beanClass,
PropertyChangeListener listener)
Adds a property change listener to the given bean. First checks
whether the bean supports bound properties, i.e. it provides
a pair of methods to register multicast property change event listeners;
see section 7.4.1 of the Java Beans specification for details.
bean
- the bean to add the property change listener tobeanClass
- the Bean class used to lookup methods fromlistener
- the listener to add
addPropertyChangeListener
public static void addPropertyChangeListener(Object bean,
Class beanClass,
String propertyName,
PropertyChangeListener listener)
Adds a named property change listener to the given bean. The bean
must provide the optional support for listening on named properties
as described in section 7.4.5 of the
Java Bean
Secification. The bean class must provide the method:
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 add
addPropertyChangeListener
public static void addPropertyChangeListener(Object bean,
PropertyChangeListener listener)
Adds a property change listener to the given bean. First checks
whether the bean supports bound properties, i.e. it provides
a pair of methods to register multicast property change event listeners;
see section 7.4.1 of the Java Beans specification for details.
bean
- the bean to add the property change listener tolistener
- the listener to add
addPropertyChangeListener
public static void addPropertyChangeListener(Object bean,
String propertyName,
PropertyChangeListener listener)
Adds a named property change listener to the given bean. The bean
must provide the optional support for listening on named properties
as described in section 7.4.5 of the
Java Bean
Secification. The bean class must provide the method:
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 add
getNamedPCLAdder
public static Method getNamedPCLAdder(Class clazz)
Looks up and returns the method that adds a PropertyChangeListener
for a specified property name to instances of the given class.
clazz
- the class that provides the adder method
- the method that adds the PropertyChangeListeners
getNamedPCLRemover
public static Method getNamedPCLRemover(Class clazz)
Looks up and returns the method that removes a PropertyChangeListener
for a specified property name from instances of the given class.
clazz
- the class that provides the remover method
- the method that removes the PropertyChangeListeners
getPCLAdder
public static Method getPCLAdder(Class clazz)
Looks up and returns the method that adds a multicast
PropertyChangeListener to instances of the given class.
clazz
- the class that provides the adder method
- the method that adds multicast PropertyChangeListeners
getPCLRemover
public static Method getPCLRemover(Class clazz)
Looks up and returns the method that removes a multicast
PropertyChangeListener from instances of the given class.
clazz
- the class that provides the remover method
- the method that removes multicast PropertyChangeListeners
getPropertyDescriptor
public static PropertyDescriptor getPropertyDescriptor(Class beanClass,
String propertyName)
throws IntrospectionException
Looks up and returns a 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 property
- the
PropertyDescriptor
associated with the given
bean and property name as returned by the Bean introspection
getPropertyDescriptor
public static PropertyDescriptor getPropertyDescriptor(Class beanClass,
String propertyName,
String getterName,
String setterName)
Looks up and returns a 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 setter
- the
PropertyDescriptor
associated with the
given bean and property name
getValue
public static Object getValue(Object bean,
PropertyDescriptor propertyDescriptor)
Returns the value of the specified property of the given non-null bean.
This operation is unsupported if the bean property is read-only.
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 read
- the bean's property value
removePropertyChangeListener
public static void removePropertyChangeListener(Object bean,
Class beanClass,
PropertyChangeListener listener)
Removes a property change listener from the given bean.
bean
- the bean to remove the property change listener frombeanClass
- the Java Bean class used to lookup methods fromlistener
- the listener to remove
removePropertyChangeListener
public static void removePropertyChangeListener(Object bean,
Class beanClass,
String propertyName,
PropertyChangeListener listener)
Removes a named property change listener from the given bean. The bean
must provide the optional support for listening on named properties
as described in section 7.4.5 of the
Java Bean
Secification. The bean class must provide the method:
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 remove
removePropertyChangeListener
public static void removePropertyChangeListener(Object bean,
PropertyChangeListener listener)
Removes a property change listener from the given bean.
bean
- the bean to remove the property change listener fromlistener
- the listener to remove
removePropertyChangeListener
public static void removePropertyChangeListener(Object bean,
String propertyName,
PropertyChangeListener listener)
Removes a named property change listener from the given bean. The bean
must provide the optional support for listening on named properties
as described in section 7.4.5 of the
Java Bean
Secification. The bean class must provide the method:
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 remove
setValue
public static void setValue(Object bean,
PropertyDescriptor propertyDescriptor,
Object newValue)
throws PropertyVetoException
Sets the given object as new value of the specified property of the given
non-null bean. This is unsupported if the bean property is read-only.
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 set
supportsBoundProperties
public static boolean supportsBoundProperties(Class clazz)
Checks and answers whether the given class supports bound properties,
i.e. it provides a pair of multicast event listener registration methods
for
PropertyChangeListener
s:
public void addPropertyChangeListener(PropertyChangeListener x);
public void removePropertyChangeListener(PropertyChangeListener x);
clazz
- the class to test
- true if the class supports bound properties, false otherwise