org.jdesktop.swing.data
Class DefaultDataModel

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

public class DefaultDataModel
extends AbstractDataModel

Default data model implementation designed to hold a single record of field values. This class provides storage of the model's values and may be used when there is no underlying data model.

See Also:
TabularDataModelAdapter, JavaBeanDataModel

Field Summary
 
Fields inherited from class org.jdesktop.swing.data.AbstractDataModel
validators
 
Constructor Summary
DefaultDataModel()
           
DefaultDataModel(MetaData[] fieldMetaData)
           
 
Method Summary
 void addField(MetaData fieldMetaData)
           
 void addField(MetaData fieldMetaData, Object defaultValue)
           
 int getFieldCount()
           
 String[] getFieldNames()
           
 MetaData getMetaData(String fieldName)
           
 int getRecordCount()
           
 int getRecordIndex()
           
 Object getValue(String fieldName)
           
 void removeField(MetaData fieldMetaData)
           
 void setRecordIndex(int index)
          Sets the current record index such that the field values in this data model represent the values contained at the specified index in the underlying data model.
protected  void setValueImpl(String fieldName, Object value)
           
 
Methods inherited from class org.jdesktop.swing.data.AbstractDataModel
addValidator, addValueChangeListener, fireValueChanged, getValidators, getValueChangeListeners, removeValidator, removeValueChangeListener, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDataModel

public DefaultDataModel()

DefaultDataModel

public DefaultDataModel(MetaData[] fieldMetaData)
Method Detail

addField

public void addField(MetaData fieldMetaData,
                     Object defaultValue)

addField

public void addField(MetaData fieldMetaData)

removeField

public void removeField(MetaData fieldMetaData)

getFieldNames

public String[] getFieldNames()
Specified by:
getFieldNames in interface DataModel
Specified by:
getFieldNames in class AbstractDataModel

getMetaData

public MetaData getMetaData(String fieldName)
Specified by:
getMetaData in interface DataModel
Specified by:
getMetaData in class AbstractDataModel

getFieldCount

public int getFieldCount()
Returns:
integer containing the number of fields in this data model

getValue

public Object getValue(String fieldName)
Specified by:
getValue in interface DataModel
Specified by:
getValue in class AbstractDataModel

setValueImpl

protected void setValueImpl(String fieldName,
                            Object value)
Specified by:
setValueImpl in class AbstractDataModel

getRecordCount

public int getRecordCount()
Returns:
integer containing the number of records accessible from this data model

getRecordIndex

public int getRecordIndex()
Returns:
integer representing the current index into the underlying data model's records

setRecordIndex

public void setRecordIndex(int index)
Description copied from interface: DataModel
Sets the current record index such that the field values in this data model represent the values contained at the specified index in the underlying data model.

Parameters:
index - integer representing the current index into the underlying data model's records


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