com.jgoodies.binding.beans
Class BeanUtils

java.lang.Object
  extended by com.jgoodies.binding.beans.BeanUtils

public final class BeanUtils
extends Object

Consists exclusively of static methods that provide convenience behavior for working with Java Bean properties.

Version:
$Revision: 1.22 $
Author:
Karsten Lentzsch
See Also:
Introspector, BeanInfo, PropertyDescriptor

Method Summary
static void addPropertyChangeListener(Object bean, Class<?> beanClass, PropertyChangeListener listener)
          Adds a property change listener to the given bean.
static void addPropertyChangeListener(Object bean, Class<?> beanClass, String propertyName, PropertyChangeListener listener)
          Adds a named property change listener to the given bean.
static void addPropertyChangeListener(Object bean, PropertyChangeListener listener)
          Adds a property change listener to the given bean.
static void addPropertyChangeListener(Object bean, String propertyName, PropertyChangeListener listener)
          Adds a named property change listener to the given bean.
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.
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.
static Method getPCLAdder(Class<?> clazz)
          Looks up and returns the method that adds a multicast PropertyChangeListener to instances of the given class.
static Method getPCLRemover(Class<?> clazz)
          Looks up and returns the method that removes a multicast PropertyChangeListener from instances of the given class.
static void removePropertyChangeListener(Object bean, Class<?> beanClass, PropertyChangeListener listener)
          Removes a property change listener from the given bean.
static void removePropertyChangeListener(Object bean, Class<?> beanClass, String propertyName, PropertyChangeListener listener)
          Removes a named property change listener from the given bean.
static void removePropertyChangeListener(Object bean, PropertyChangeListener listener)
          Removes a property change listener from the given bean.
static void removePropertyChangeListener(Object bean, String propertyName, PropertyChangeListener listener)
          Removes a named property change listener from the given bean.
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 PropertyChangeListeners: public void addPropertyChangeListener(PropertyChangeListener x); public void removePropertyChangeListener(PropertyChangeListener x);
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

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 PropertyChangeListeners:
 public void addPropertyChangeListener(PropertyChangeListener x);
 public void removePropertyChangeListener(PropertyChangeListener x);
 

Parameters:
clazz - the class to test
Returns:
true if the class supports bound properties, false otherwise

getPCLAdder

public static Method getPCLAdder(Class<?> clazz)
Looks up and returns the method that adds a multicast PropertyChangeListener to instances of the given class.

Parameters:
clazz - the class that provides the adder method
Returns:
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.

Parameters:
clazz - the class that provides the remover method
Returns:
the method that removes multicast PropertyChangeListeners

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.

Parameters:
clazz - the class that provides the adder method
Returns:
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.

Parameters:
clazz - the class that provides the remover method
Returns:
the method that removes the PropertyChangeListeners

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.

beanClass can be a type other than bean.getClass(), for example if the bean is specified by public interfaces, and implemented by package private class.

Parameters:
bean - the bean to add the property change listener to
beanClass - the Bean class used to lookup methods from
listener - the listener to add
Throws:
NullPointerException - if the bean or listener is null
IllegalArgumentException - if the bean is not an instance of the bean class
PropertyUnboundException - if the bean does not support bound properties
PropertyNotBindableException - if the property change handler cannot be added successfully
Since:
1.1.1

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 Specification. The bean class must provide the method:
 public void addPropertyChangeListener(String name, PropertyChangeListener l);
 

beanClass can be a type other than bean.getClass(), for example if the bean is specified by public interfaces, and implemented by package private class.

Parameters:
bean - the bean to add a property change handler
beanClass - the Bean class used to lookup methods from
propertyName - the name of the property to be observed
listener - the listener to add
Throws:
NullPointerException - if the bean, propertyName or listener is null
IllegalArgumentException - if the bean is not an instance of the bean class
PropertyNotBindableException - if the property change handler cannot be added successfully

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.

Parameters:
bean - the bean to add the property change listener to
listener - the listener to add
Throws:
NullPointerException - if the bean or listener is null
PropertyUnboundException - if the bean does not support bound properties
PropertyNotBindableException - if the property change handler cannot be added successfully

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 Specification. The bean class must provide the method:
 public void addPropertyChangeListener(String name, PropertyChangeListener l);
 

Parameters:
bean - the bean to add a property change handler
propertyName - the name of the property to be observed
listener - the listener to add
Throws:
NullPointerException - if the bean, propertyName or listener is null
PropertyNotBindableException - if the property change handler cannot be added successfully

removePropertyChangeListener

public static void removePropertyChangeListener(Object bean,
                                                Class<?> beanClass,
                                                PropertyChangeListener listener)
Removes a property change listener from the given bean.

beanClass can be a type other than bean.getClass(), for example if the bean is specified by public interfaces, and implemented by package private class.

Parameters:
bean - the bean to remove the property change listener from
beanClass - the Java Bean class used to lookup methods from
listener - the listener to remove
Throws:
NullPointerException - if the bean or listener is null
IllegalArgumentException - if the bean is not an instance of the bean class
PropertyUnboundException - if the bean does not support bound properties
PropertyNotBindableException - if the property change handler cannot be removed successfully
Since:
1.1.1

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 Specification. The bean class must provide the method:
 public void removePropertyChangeHandler(String name, PropertyChangeListener l);
 

beanClass can be a type other than bean.getClass(), for example if the bean is specified by public interfaces, and implemented by package private class.

Parameters:
bean - the bean to remove the property change listener from
beanClass - the Java Bean class used to lookup methods from
propertyName - the name of the observed property
listener - the listener to remove
Throws:
NullPointerException - if the bean, propertyName, or listener is null
IllegalArgumentException - if the bean is not an instance of the bean class
PropertyNotBindableException - if the property change handler cannot be removed successfully
Since:
1.1.1

removePropertyChangeListener

public static void removePropertyChangeListener(Object bean,
                                                PropertyChangeListener listener)
Removes a property change listener from the given bean.

Parameters:
bean - the bean to remove the property change listener from
listener - the listener to remove
Throws:
NullPointerException - if the bean or listener is null
PropertyUnboundException - if the bean does not support bound properties
PropertyNotBindableException - if the property change handler cannot be removed successfully

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 Specification. The bean class must provide the method:
 public void removePropertyChangeHandler(String name, PropertyChangeListener l);
 

beanClass can be a type other than bean.getClass(), for example if the bean is specified by public interfaces, and implemented by package private class.

Parameters:
bean - the bean to remove the property change listener from
propertyName - the name of the observed property
listener - the listener to remove
Throws:
NullPointerException - if the bean, propertyName, or listener is null
PropertyNotBindableException - if the property change handler cannot be removed successfully


Copyright © 2002-2013 JGoodies Software GmbH. All Rights Reserved.