com.jgoodies.common.bean
public abstract class AbstractBean extends Object implements Serializable, ObservableBean2
This class uses the standard PropertyChangeSupport to notify registered listeners about changes. Subclasses can use different change support implementations by overriding {@code createPropertyChangeSupport}, for example to ensure that notifications are sent in the Event dispatch thread, or to compare old and new values with {@code ==} not {@code equals}.
Version: $Revision: 1.7 $
See Also: PropertyChangeEvent PropertyChangeListener PropertyChangeSupport VetoableChangeListener VetoableChangeSupport
Field Summary | |
---|---|
protected PropertyChangeSupport | changeSupport
If any{@code PropertyChangeListeners} have been registered,
the {@code changeSupport} field describes them.
|
Method Summary | |
---|---|
void | addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. |
void | addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific
property. |
void | addVetoableChangeListener(VetoableChangeListener listener)
Adds a VetoableChangeListener to the listener list. |
void | addVetoableChangeListener(String propertyName, VetoableChangeListener listener)
Adds a VetoableChangeListener to the listener list for a specific
property. |
protected PropertyChangeSupport | createPropertyChangeSupport(Object bean)
Creates and returns a PropertyChangeSupport for the given bean.
|
protected void | fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue)
Report a bound indexed property update to any registered listeners. No event is fired if old and new values are equal and non-null. |
protected void | fireIndexedPropertyChange(String propertyName, int index, int oldValue, int newValue)
Report an {@code int} bound indexed property update
to any registered listeners. No event is fired if old and new values are equal and non-null. This is merely a convenience wrapper around the more general fireIndexedPropertyChange method which takes Object values. |
protected void | fireIndexedPropertyChange(String propertyName, int index, boolean oldValue, boolean newValue)
Report a {@code boolean} bound indexed property update
to any registered listeners. No event is fired if old and new values are equal and non-null. This is merely a convenience wrapper around the more general fireIndexedPropertyChange method which takes Object values. |
protected void | fireMultiplePropertiesChanged()
Indicates that an arbitrary set of bound properties have changed.
|
protected void | firePropertyChange(PropertyChangeEvent event)
General support for reporting bound property changes. |
protected void | firePropertyChange(String propertyName, Object oldValue, Object newValue)
Support for reporting bound property changes for Object properties.
|
protected void | firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
Support for reporting bound property changes for boolean properties.
|
protected void | firePropertyChange(String propertyName, double oldValue, double newValue)
Support for reporting bound property changes for integer properties.
|
protected void | firePropertyChange(String propertyName, float oldValue, float newValue)
Support for reporting bound property changes for integer properties.
|
protected void | firePropertyChange(String propertyName, int oldValue, int newValue)
Support for reporting bound property changes for integer properties.
|
protected void | firePropertyChange(String propertyName, long oldValue, long newValue)
Support for reporting bound property changes for integer properties.
|
protected void | fireVetoableChange(PropertyChangeEvent event)
General support for reporting constrained property changes. |
protected void | fireVetoableChange(String propertyName, Object oldValue, Object newValue)
Support for reporting changes for constrained Object properties. |
protected void | fireVetoableChange(String propertyName, boolean oldValue, boolean newValue)
Support for reporting changes for constrained boolean properties. |
protected void | fireVetoableChange(String propertyName, double oldValue, double newValue)
Support for reporting changes for constrained integer properties. |
protected void | fireVetoableChange(String propertyName, int oldValue, int newValue)
Support for reporting changes for constrained integer properties. |
protected void | fireVetoableChange(String propertyName, float oldValue, float newValue)
Support for reporting changes for constrained integer properties. |
protected void | fireVetoableChange(String propertyName, long oldValue, long newValue)
Support for reporting changes for constrained integer 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.
|
VetoableChangeListener[] | getVetoableChangeListeners()
Returns an array of all the property change listeners
registered on this component.
|
VetoableChangeListener[] | getVetoableChangeListeners(String propertyName)
Returns an array of all the listeners which have been associated
with the named property.
|
void | removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. |
void | removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list for a specific
property. |
void | removeVetoableChangeListener(VetoableChangeListener listener)
Removes a VetoableChangeListener from the listener list. |
void | removeVetoableChangeListener(String propertyName, VetoableChangeListener listener)
Removes a VetoableChangeListener from the listener list for a specific
property. |
See Also: addPropertyChangeListener AbstractBean removePropertyChangeListener AbstractBean PropertyChangeSupport
If listener is {@code null}, no exception is thrown and no action is performed.
Parameters: listener the PropertyChangeListener to be added
See Also: removePropertyChangeListener AbstractBean AbstractBean getPropertyChangeListeners
Note that if this Model is inheriting a bound property, then no event will be fired in response to a change in the inherited property.
If listener is {@code 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: AbstractBean AbstractBean getPropertyChangeListeners
If listener is {@code null}, no exception is thrown and no action is performed.
Parameters: listener the VetoableChangeListener to be added
See Also: AbstractBean AbstractBean getVetoableChangeListeners
Note that if this Model is inheriting a bound property, then no event will be fired in response to a change in the inherited property.
If listener is {@code null}, no exception is thrown and no action is performed.
Parameters: propertyName one of the property names listed above listener the VetoableChangeListener to be added
See Also: AbstractBean AbstractBean getVetoableChangeListeners
This default implementation creates a {@code PropertyChangeSupport}. Subclasses may override to return other change support implementations. For example to ensure that listeners are notified in the Event dispatch thread (EDT change support). The JGoodies Binding uses an extended change support that allows to configure whether the old and new value are compared with {@code ==} or {@code equals}.
Parameters: bean the bean to create a change support for
Returns: the new change support
No event is fired if old and new values are equal and non-null.
Parameters: propertyName The programmatic name of the property that was changed. index index of the property element that was changed. oldValue The old value of the property. newValue The new value of the property.
Since: 2.0
No event is fired if old and new values are equal and non-null.
This is merely a convenience wrapper around the more general fireIndexedPropertyChange method which takes Object values.
Parameters: propertyName The programmatic name of the property that was changed. index index of the property element that was changed. oldValue The old value of the property. newValue The new value of the property.
Since: 2.0
No event is fired if old and new values are equal and non-null.
This is merely a convenience wrapper around the more general fireIndexedPropertyChange method which takes Object values.
Parameters: propertyName The programmatic name of the property that was changed. index index of the property element that was changed. oldValue The old value of the property. newValue The new value of the property.
Since: 2.0
Since: 1.0.3
See Also: java.beans.PropertyChangeEvent
Most bean setters will invoke the fireXXX methods that get a property name and the old and new value. However some frameworks and setters may prefer to use this general method. Also, this method allows to fire IndexedPropertyChangeEvents that have been introduced in Java 5.
Parameters: event describes the property change
Since: 1.3
Parameters: propertyName the property whose value has changed oldValue the property's previous value newValue the property's new value
Parameters: propertyName the property whose value has changed oldValue the property's previous value newValue the property's new value
Parameters: propertyName the property whose value has changed oldValue the property's previous value newValue the property's new value
Parameters: propertyName the property whose value has changed oldValue the property's previous value newValue the property's new value
Parameters: propertyName the property whose value has changed oldValue the property's previous value newValue the property's new value
Parameters: propertyName the property whose value has changed oldValue the property's previous value newValue the property's new value
Most bean setters will invoke the fireXXX methods that get a property name and the old and new value. However some frameworks and setters may prefer to use this general method. Also, this method allows to fire IndexedPropertyChangeEvents that have been introduced in Java 5.
Parameters: event describes the property change
Throws: PropertyVetoException if a constrained property change is rejected
Since: 1.3
Parameters: propertyName the property whose value has changed oldValue the property's previous value newValue the property's new value
Throws: PropertyVetoException if a constrained property change is rejected
Parameters: propertyName the property whose value has changed oldValue the property's previous value newValue the property's new value
Throws: PropertyVetoException if a constrained property change is rejected
Parameters: propertyName the property whose value has changed oldValue the property's previous value newValue the property's new value
Throws: PropertyVetoException if a constrained property change is rejected
Parameters: propertyName the property whose value has changed oldValue the property's previous value newValue the property's new value
Throws: PropertyVetoException if a constrained property change is rejected
Parameters: propertyName the property whose value has changed oldValue the property's previous value newValue the property's new value
Throws: PropertyVetoException if a constrained property change is rejected
Parameters: propertyName the property whose value has changed oldValue the property's previous value newValue the property's new value
Throws: PropertyVetoException if a constrained property change is rejected
Returns: all of this component's {@code PropertyChangeListener}s or an empty array if no property change listeners are currently registered
See Also: addPropertyChangeListener removePropertyChangeListener getPropertyChangeListeners PropertyChangeSupport#getPropertyChangeListeners()
Parameters: propertyName the name of the property to lookup listeners
Returns: all of the {@code PropertyChangeListeners} associated with the named property or an empty array if no listeners have been added
See Also: AbstractBean AbstractBean getPropertyChangeListeners
Returns: all of this component's {@code VetoableChangeListener}s or an empty array if no property change listeners are currently registered
See Also: addVetoableChangeListener removeVetoableChangeListener getVetoableChangeListeners VetoableChangeSupport#getVetoableChangeListeners()
Parameters: propertyName the name of the property to lookup listeners
Returns: all of the {@code VetoableChangeListeners} associated with the named property or an empty array if no listeners have been added
See Also: AbstractBean AbstractBean getVetoableChangeListeners
If listener is {@code null}, no exception is thrown and no action is performed.
Parameters: listener the PropertyChangeListener to be removed
See Also: addPropertyChangeListener AbstractBean AbstractBean getPropertyChangeListeners
If listener is {@code null}, no exception is thrown and no action is performed.
Parameters: propertyName a valid property name listener the PropertyChangeListener to be removed
See Also: AbstractBean removePropertyChangeListener getPropertyChangeListeners
If listener is {@code null}, no exception is thrown and no action is performed.
Parameters: listener the VetoableChangeListener to be removed
See Also: AbstractBean AbstractBean getVetoableChangeListeners
If listener is {@code null}, no exception is thrown and no action is performed.
Parameters: propertyName a valid property name listener the VetoableChangeListener to be removed
See Also: AbstractBean removeVetoableChangeListener getVetoableChangeListeners