Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.jgoodies.binding.beans
Class IndirectPropertyChangeSupport

    java.lang.Object
      com.jgoodies.binding.beans.IndirectPropertyChangeSupport

    public final class IndirectPropertyChangeSupport

extends Object

A helper class for observing changes in bound bean properties where the target bean changes. Provides two access styles to the target bean that holds the observed property: you can specify a bean directly, or you can use a bean channel to access the bean indirectly. In the latter case you specify a `ValueModel` that holds the bean that in turn holds the observed properties.

If the target bean is `null`, it won't report any changes.

It is recommended to remove all listener by invoking `#removeAll` if the observed bean lives much longer than this change support instance. As an alternative you may use event listener lists that are based on `WeakReference`s.

Constraints: All target bean classes must support bound properties, i. e. must provide the following pair of methods for registration of multicast property change event listeners:

     public void addPropertyChangeListener(PropertyChangeListener x);
     public void removePropertyChangeListener(PropertyChangeListener x);

and the following methods for listening on named properties:

     public void addPropertyChangeListener(String, PropertyChangeListener x);
     public void removePropertyChangeListener(String, PropertyChangeListener x);

Version:
  $Revision: 1.13 $
Author:
  Karsten Lentzsch
See Also:
  `PropertyChangeEvent`, `PropertyChangeListener`, `PropertyChangeSupport`, `BeanAdapter`

Constructor Summary
`IndirectPropertyChangeSupport()` Constructs an IndirectPropertyChangeSupport that has no bean set.
`IndirectPropertyChangeSupport(Object bean)` Constructs an IndirectPropertyChangeSupport with the given initial bean.
`IndirectPropertyChangeSupport(ValueModel beanChannel)` Constructs an IndirectPropertyChangeSupport using the given bean channel.

Method Summary
`void` | `addPropertyChangeListener(PropertyChangeListener listener)` Adds a PropertyChangeListener to the list of bean listeners.
`void` | `addPropertyChangeListener(String propertyName, PropertyChangeListener listener)` Adds a PropertyChangeListener to the list of bean listeners for a specific property.
`Object` | `getBean()` Returns the Java Bean that holds the observed properties.
`PropertyChangeListener[]` | `getPropertyChangeListeners()` Returns an array of all the property change listeners registered on this component.
`PropertyChangeListener[]` | `getPropertyChangeListeners(String propertyName)` Returns an array of all the listeners which have been associated with the named property.
`void` | `removeAll()` Removes all registered PropertyChangeListeners from the current target bean - if any.
`void` | `removePropertyChangeListener(PropertyChangeListener listener)` Removes a PropertyChangeListener from the list of bean listeners.
`void` | `removePropertyChangeListener(String propertyName, PropertyChangeListener listener)` Removes a PropertyChangeListener from the listener list for a specific property.
`void` | `setBean(Object newBean)` Sets a new Java Bean as holder of the observed properties.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### IndirectPropertyChangeSupport

    public IndirectPropertyChangeSupport()

  Constructs an IndirectPropertyChangeSupport that has no bean set.

### IndirectPropertyChangeSupport

    public IndirectPropertyChangeSupport(Object bean)

  Constructs an IndirectPropertyChangeSupport with the given initial bean.

  Parameters:
    `bean` - the initial bean

### IndirectPropertyChangeSupport

    public IndirectPropertyChangeSupport(ValueModel beanChannel)

  Constructs an IndirectPropertyChangeSupport using the given bean channel.

  Parameters:
    `beanChannel` - the ValueModel that holds the bean

Method Detail

### getBean

    public Object getBean()

  Returns the Java Bean that holds the observed properties.

  Returns:
    the Bean that holds the observed properties
  See Also:
    `setBean(Object)`

### setBean

    public void setBean(Object newBean)

  Sets a new Java Bean as holder of the observed properties. Removes all registered listeners from the old bean and adds them to the new bean.

  Parameters:
    `newBean` - the new holder of the observed properties
  See Also:
    `getBean()`

### addPropertyChangeListener

    public void addPropertyChangeListener(PropertyChangeListener listener)

  Adds a PropertyChangeListener to the list of bean listeners. The listener is registered for all bound properties of the target bean.

  If listener is `null`, no exception is thrown and no action is performed.

  Parameters:
    `listener` - the PropertyChangeListener to be added
  See Also:
    `removePropertyChangeListener(PropertyChangeListener)`, `removePropertyChangeListener(String, PropertyChangeListener)`, `addPropertyChangeListener(String, PropertyChangeListener)`, `getPropertyChangeListeners()`

### removePropertyChangeListener

    public void removePropertyChangeListener(PropertyChangeListener listener)

  Removes a PropertyChangeListener from the list of bean listeners. This method should be used to remove PropertyChangeListeners that were registered for all bound properties of the target bean.

  If listener is `null`, no exception is thrown and no action is performed.

  Parameters:
    `listener` - the PropertyChangeListener to be removed
  See Also:
    `addPropertyChangeListener(PropertyChangeListener)`, `addPropertyChangeListener(String, PropertyChangeListener)`, `removePropertyChangeListener(String, PropertyChangeListener)`, `getPropertyChangeListeners()`

### addPropertyChangeListener

    public void addPropertyChangeListener(String propertyName,
                                          PropertyChangeListener listener)

  Adds a PropertyChangeListener to the list of bean listeners for a specific property. The specified property may be user-defined.

  Note that if the bean is inheriting a bound property, then no event will be fired in response to a change in the inherited property.

  If listener is `null`, no exception is thrown and no action is performed.

  Parameters:
    `propertyName` - one of the property names listed above
    `listener` - the PropertyChangeListener to be added
  See Also:
    `removePropertyChangeListener(String, PropertyChangeListener)`, `addPropertyChangeListener(String, PropertyChangeListener)`, `getPropertyChangeListeners(String)`

### removePropertyChangeListener

    public void removePropertyChangeListener(String propertyName,
                                             PropertyChangeListener listener)

  Removes a PropertyChangeListener from the listener list for a specific property. This method should be used to remove PropertyChangeListeners that were registered for a specific bound property.

  If listener is `null`, no exception is thrown and no action is performed.

  Parameters:
    `propertyName` - a valid property name
    `listener` - the PropertyChangeListener to be removed
  See Also:
    `addPropertyChangeListener(String, PropertyChangeListener)`, `removePropertyChangeListener(PropertyChangeListener)`, `getPropertyChangeListeners(String)`

### getPropertyChangeListeners

    public PropertyChangeListener[] getPropertyChangeListeners()

  Returns an array of all the property change listeners registered on this component.

  Returns:
    all of this component's `PropertyChangeListener`s or an empty array if no property change listeners are currently registered
  See Also:
    `addPropertyChangeListener(PropertyChangeListener)`, `removePropertyChangeListener(PropertyChangeListener)`, `getPropertyChangeListeners(String)`, `PropertyChangeSupport.getPropertyChangeListeners()`

### getPropertyChangeListeners

    public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)

  Returns an array of all the listeners which have been associated with the named property.

  Parameters:
    `propertyName` - the name of the property to lookup listeners
  Returns:
    all of the `PropertyChangeListeners` associated with the named property or an empty array if no listeners have been added
  See Also:
    `addPropertyChangeListener(String, PropertyChangeListener)`, `removePropertyChangeListener(String, PropertyChangeListener)`, `getPropertyChangeListeners()`

### removeAll

    public void removeAll()

  Removes all registered PropertyChangeListeners from the current target bean - if any.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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