org.jdesktop.binding
Interface DataModel

All Superinterfaces:
MetaDataProvider
All Known Subinterfaces:
TabularDataModel
All Known Implementing Classes:
AbstractDataModel, DataModelAdapter, DefaultDataModel, JavaBeanDataModel, TableModelExtAdapter, TabularDataModelAdapter

public interface DataModel
extends MetaDataProvider

Abstract model interface for representing a record of named data fields. The map provides a uniform API for accessing data which may be contained in a variety of data model constructs underneath, such as RowSet, DefaultTableModelExt, or arbitrary JavaBean classes. The user-interface Binding classes use this interface to "bind" user-interface components to field elements in a data model without having to understand the specific flavor of data model being used by the application. For example, a field element may map to a named column on a RowSet or a property on a JavaBean, but the binding classes don't need to understand those underlying data structures in order to read and write values.

For each named field, the data model provides access to:

Often data models are collections of like-objects, such as the rows in a RowSet, or a list of JavaBeans. This interface provides a mechanism to index into such a collection such that at any given time, the data model contains the element values associated with the "current" record index into that collection (the current row, or the current bean, etc).

Version:
1.0
Author:
Amy Fowler

Method Summary
 void addValidator(Validator validator)
          Adds the specified validator for the fields represented by this data model.
 void addValueChangeListener(ValueChangeListener valueChangeListener)
          Adds the specified value change listener to be notified when the value is changed outside of calling setValue directly.
 Validator[] getValidators()
           
 java.lang.Object getValue(java.lang.String fieldName)
           
 ValueChangeListener[] getValueChangeListeners()
           
 void removeValidator(Validator validator)
          Removes the specified validator from this data model.
 void removeValueChangeListener(ValueChangeListener valueChangeListener)
          Removes the specified value change listener from this value adapter.
 void setValue(java.lang.String fieldName, java.lang.Object value)
           
 
Methods inherited from interface org.jdesktop.binding.metadata.MetaDataProvider
getFieldCount, getFieldNames, getMetaData, getMetaData
 

Method Detail

getValue

java.lang.Object getValue(java.lang.String fieldName)
Parameters:
fieldName - String containing the name of the field
Returns:
Object containing the current value of the named field

setValue

void setValue(java.lang.String fieldName,
              java.lang.Object value)
Parameters:
fieldName - String containing the name of the field
value - Object containing the current value of the named field

addValidator

void addValidator(Validator validator)
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.

Parameters:
validator - Validator object which performs validation checks on this set of data field values
See Also:
removeValidator(org.jdesktop.binding.metadata.Validator), getValidators()

removeValidator

void removeValidator(Validator validator)
Removes the specified validator from this data model.

Parameters:
validator - Validator object which performs validation checks on this set of data field values
See Also:
addValidator(org.jdesktop.binding.metadata.Validator)

getValidators

Validator[] getValidators()
Returns:
array containing the validators registered for data model

addValueChangeListener

void addValueChangeListener(ValueChangeListener valueChangeListener)
Adds the specified value change listener to be notified when the value is changed outside of calling setValue directly.

Parameters:
valueChangeListener - ValueChangeListener object to receive events when the field value changes

removeValueChangeListener

void removeValueChangeListener(ValueChangeListener valueChangeListener)
Removes the specified value change listener from this value adapter.

Parameters:
valueChangeListener - ValueChangeListener object to receive events when the field value changes

getValueChangeListeners

ValueChangeListener[] getValueChangeListeners()
Returns:
array containing the ValueChangeListener objects registered on this data model


Copyright © 2005 Sun Microsystems All Rights Reserved.