org.jdesktop.swing.data
Class AbstractDataModel

java.lang.Object
  extended byorg.jdesktop.swing.data.AbstractDataModel
All Implemented Interfaces:
DataModel
Direct Known Subclasses:
DefaultDataModel, TabularDataModelAdapter

public abstract class AbstractDataModel
extends Object
implements DataModel

Abstract base class for implementing concrete DataModel implementations. This class provides support for managing validators and value change listeners. Subclasses must implement their own mechanism to store field meta-data and values.


Field Summary
protected  ArrayList validators
           
 
Constructor Summary
AbstractDataModel()
           
 
Method Summary
 void addValidator(Validator validator)
          Adds the specified validator for the fields represented by this data model.
 void addValueChangeListener(ValueChangeListener l)
          Adds the specified value change listener to be notified when the value is changed outside of calling setValue directly.
protected  void fireValueChanged(String fieldName)
           
abstract  String[] getFieldNames()
           
abstract  MetaData getMetaData(String fieldName)
           
 Validator[] getValidators()
           
abstract  Object getValue(String fieldName)
           
 ValueChangeListener[] getValueChangeListeners()
           
 void removeValidator(Validator validator)
          Removes the specified validator from this data model.
 void removeValueChangeListener(ValueChangeListener l)
          Removes the specified value change listener from this value adapter.
 void setValue(String fieldName, Object value)
           
protected abstract  void setValueImpl(String fieldName, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jdesktop.swing.data.DataModel
getFieldCount, getRecordCount, getRecordIndex, setRecordIndex
 

Field Detail

validators

protected ArrayList validators
Constructor Detail

AbstractDataModel

public AbstractDataModel()
Method Detail

getFieldNames

public abstract String[] getFieldNames()
Specified by:
getFieldNames in interface DataModel
Returns:
array containing the names of all data fields in this map

getMetaData

public abstract MetaData getMetaData(String fieldName)
Specified by:
getMetaData in interface DataModel
Parameters:
fieldName - String containing the name of the field
Returns:
MetaData object which describes the named field

getValue

public abstract Object getValue(String fieldName)
Specified by:
getValue in interface DataModel
Parameters:
fieldName - String containing the name of the field
Returns:
Object containing the current value of the named field

setValue

public void setValue(String fieldName,
                     Object value)
Specified by:
setValue in interface DataModel
Parameters:
fieldName - String containing the name of the field
value - Object containing the current value of the named field

setValueImpl

protected abstract void setValueImpl(String fieldName,
                                     Object value)

addValidator

public void addValidator(Validator validator)
Description copied from interface: DataModel
Adds the specified validator for the fields represented by this data model. A validator object may be used to perform validation checks which require analyzing more than one field value in a single check. This DataModel instance will be passed in as the value parameter to the validator's validate method.

Specified by:
addValidator in interface DataModel
Parameters:
validator - Validator object which performs validation checks on this set of data field values
See Also:
DataModel.removeValidator(org.jdesktop.swing.data.Validator), DataModel.getValidators()

removeValidator

public void removeValidator(Validator validator)
Description copied from interface: DataModel
Removes the specified validator from this data model.

Specified by:
removeValidator in interface DataModel
Parameters:
validator - Validator object which performs validation checks on this set of data field values
See Also:
DataModel.addValidator(org.jdesktop.swing.data.Validator)

getValidators

public Validator[] getValidators()
Specified by:
getValidators in interface DataModel
Returns:
array containing the validators registered for data model

addValueChangeListener

public void addValueChangeListener(ValueChangeListener l)
Description copied from interface: DataModel
Adds the specified value change listener to be notified when the value is changed outside of calling setValue directly.

Specified by:
addValueChangeListener in interface DataModel
Parameters:
l - ValueChangeListener object to receive events when the field value changes

removeValueChangeListener

public void removeValueChangeListener(ValueChangeListener l)
Description copied from interface: DataModel
Removes the specified value change listener from this value adapter.

Specified by:
removeValueChangeListener in interface DataModel
Parameters:
l - ValueChangeListener object to receive events when the field value changes

getValueChangeListeners

public ValueChangeListener[] getValueChangeListeners()
Specified by:
getValueChangeListeners in interface DataModel
Returns:
array containing the ValueChangeListener objects registered on this data model

fireValueChanged

protected void fireValueChanged(String fieldName)


Copyright 2004 by Sun Microsystems, Inc. All Rights Reserved.