org.beanfabrics.event
Class BnPropertyChangeSupport

java.lang.Object
  extended by org.beanfabrics.event.BnPropertyChangeSupport

public class BnPropertyChangeSupport
extends java.lang.Object

The BnPropertyChangeSupport is a utility class for handling listeners of bound properties.


Constructor Summary
BnPropertyChangeSupport(java.lang.Object sourceBean)
          Constructs a BnPropertyChangeSupport.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds the given PropertyChangeListener for any property of the source bean.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Adds the given PropertyChangeListener for the specified property of the source bean.
 void firePropertyChange(BnPropertyChangeEvent evt)
          Fire thw given PropertyChangeEvent to each registered listener.
 void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Report a bound property update to each registered listener.
 void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue, java.util.EventObject cause)
          Report a bound property update to each registered listener.
 boolean hasListeners()
          Returns true if there are any listeners registered at all.
 boolean hasListeners(java.lang.String propertyName)
          Returns true if there are any listeners for the property with the specified name.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes the given PropertyChangeListener.
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Removes the given PropertyChangeListener for a specific property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BnPropertyChangeSupport

public BnPropertyChangeSupport(java.lang.Object sourceBean)
Constructs a BnPropertyChangeSupport.

Parameters:
sourceBean - The bean to be given as the source for any events
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds the given PropertyChangeListener for any property of the source bean.

Parameters:
listener - the listener add

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the given PropertyChangeListener.

Parameters:
listener - the listener to remove

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Adds the given PropertyChangeListener for the specified property of the source bean. The listener will only receive events that are triggered by that property.

Parameters:
propertyName - the name of the property
listener - the listener to add

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)
Removes the given PropertyChangeListener for a specific property.

Parameters:
propertyName - the name of the property
listener - the listener to remove

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               java.lang.Object oldValue,
                               java.lang.Object newValue)
Report a bound property update to each registered listener. No event is fired if old and new are equal and non-null.

Parameters:
propertyName - the property name of the property that was changed
oldValue - the old value of the property
newValue - the new value of the property

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               java.lang.Object oldValue,
                               java.lang.Object newValue,
                               java.util.EventObject cause)
Report a bound property update to each registered listener. No event is fired if old and new are equal and non-null.

Parameters:
propertyName - the property name of the property that was changed
oldValue - the old value of the property
newValue - the new value of the property
cause - the event that triggered the new event

firePropertyChange

public void firePropertyChange(BnPropertyChangeEvent evt)
Fire thw given PropertyChangeEvent to each registered listener. No event is fired if the given event's old and new values are equal and non-null.

Parameters:
evt - the PropertyChangeEvent object

hasListeners

public boolean hasListeners(java.lang.String propertyName)
Returns true if there are any listeners for the property with the specified name.

Parameters:
propertyName - the property name
Returns:
true if there are any listeners

hasListeners

public boolean hasListeners()
Returns true if there are any listeners registered at all.

Returns:
true if there are any listeners for any property