com.jgoodies.binding.beans
Class Model

java.lang.Object
  extended by AbstractBean
      extended by com.jgoodies.binding.beans.Model
All Implemented Interfaces:
Observable
Direct Known Subclasses:
AbstractValueModel, BeanAdapter, ChangeTracker, IndirectListModel, PresentationModel

public abstract class Model
extends AbstractBean
implements Observable

An abstract superclass that minimizes the effort required to provide change support for bound and constrained Bean properties. This class follows the conventions and recommendations as described in the Java Bean Specification.

Uses class ExtendedPropertyChangeSupport, to enable the == or #equals test when changing values.

TODO: Consider adding a method #fireChange that invokes #firePropertyChange if and only if new value != old value. The background is, that #firePropertyChange must fire an event if new value==null==old value.

TODO: Consider renaming this class to AbstractBean. That better describes what this class is about.

Version:
$Revision: 1.20 $
Author:
Karsten Lentzsch
See Also:
Observable, PropertyChangeEvent, PropertyChangeListener, PropertyChangeSupport, ExtendedPropertyChangeSupport, VetoableChangeListener, VetoableChangeSupport

Constructor Summary
Model()
           
 
Method Summary
protected  java.beans.PropertyChangeSupport createPropertyChangeSupport(java.lang.Object bean)
          Creates and returns a PropertyChangeSupport for the given bean.
protected  void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue, boolean checkIdentity)
          Support for reporting bound property changes for Object properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jgoodies.binding.beans.Observable
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

Model

public Model()
Method Detail

createPropertyChangeSupport

protected java.beans.PropertyChangeSupport createPropertyChangeSupport(java.lang.Object bean)
Creates and returns a PropertyChangeSupport for the given bean. Invoked by the first call to Observable.addPropertyChangeListener(java.beans.PropertyChangeListener) when lazily creating the sole change support instance used throughout this bean.

This implementation creates an extended change support that allows to configure whether the old and new value are compared with == or equals.

Parameters:
bean - the bean to create a change support for
Returns:
the new change support

firePropertyChange

protected final void firePropertyChange(java.lang.String propertyName,
                                        java.lang.Object oldValue,
                                        java.lang.Object newValue,
                                        boolean checkIdentity)
Support for reporting bound property changes for Object properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

The boolean parameter specifies whether the old and new value are compared with == or equals.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value
checkIdentity - true to check differences using == false to use equals.


Copyright © 2002-2010 JGoodies Karsten Lentzsch. All Rights Reserved.