DataModel.java
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:5k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: DataModel.java,v 1.3 2005/10/10 17:01:03 rbair Exp $
  3.  *
  4.  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
  5.  * Santa Clara, California 95054, U.S.A. All rights reserved.
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20.  */
  21. package org.jdesktop.binding;
  22. import org.jdesktop.binding.metadata.MetaDataProvider;
  23. import org.jdesktop.binding.metadata.Validator;
  24. /**
  25.  * <p>
  26.  * Abstract model interface for representing a record of named data fields.
  27.  * The map provides a uniform API for accessing data which may be contained
  28.  * in a variety of data model constructs underneath, such as RowSet,
  29.  * DefaultTableModelExt, or arbitrary JavaBean classes.  The user-interface
  30.  * Binding classes use this interface to &quot;bind&quot; user-interface
  31.  * components to field elements in a data model without having to understand
  32.  * the specific flavor of data model being used by the application.
  33.  * For example, a field element may map to a named column on a RowSet
  34.  * or a property on a JavaBean, but the binding classes don't need to
  35.  * understand those underlying data structures in order to read and write
  36.  * values.</p>
  37.  * <p>
  38.  * For each named field, the data model provides access to:
  39.  * <ul>
  40.  * <li>meta-data: information describing the data field, such as type
  41.  *                and edit constraints</li>
  42.  * <li>value: the current value of the field</li>
  43.  * </ul>
  44.  * </p>
  45.  * <p>
  46.  * Often data models are collections of like-objects, such as the rows in a
  47.  * RowSet, or a list of JavaBeans.  This interface provides a mechanism
  48.  * to index into such a collection such that at any given time, the data model
  49.  * contains the element values associated with the &quot;current&quot; record index
  50.  * into that collection (the current row, or the current bean, etc).
  51.  * </p>
  52.  *
  53.  *
  54.  * @author Amy Fowler
  55.  * @version 1.0
  56.  */
  57. public interface DataModel extends MetaDataProvider {
  58. //---------------------- moved to MetaDataProvider
  59.     
  60. //    /**
  61. //     * @return array containing the names of all data fields in this map
  62. //     */
  63. //    String[] getFieldNames();
  64. //
  65. //    MetaData[] getMetaData();
  66. //
  67. //    /**
  68. //     *
  69. //     * @param fieldName String containing the name of the field
  70. //     * @return MetaData object which describes the named field
  71. //     */
  72. //    MetaData getMetaData(String fieldName);
  73. //
  74. //    /**
  75. //    *
  76. //    * @return integer containing the number of fields in this data model
  77. //    */
  78. //   int getFieldCount();
  79. //
  80.     
  81.     /**
  82.      *
  83.      * @param fieldName String containing the name of the field
  84.      * @return Object containing the current value of the named field
  85.      */
  86.     Object getValue(String fieldName);
  87.     /**
  88.      *
  89.      * @param fieldName String containing the name of the field
  90.      * @param value Object containing the current value of the named field
  91.      */
  92.     void setValue(String fieldName, Object value);
  93.     /**
  94.      * Adds the specified validator for the fields represented by this
  95.      * data model.
  96.      * A validator object may be used to perform validation checks which
  97.      * require analyzing more than one field value in a single check.
  98.      * This DataModel instance will be passed in as the <code>value</code>
  99.      * parameter to the validator's <code>validate</code> method.
  100.      *
  101.      * @see #removeValidator
  102.      * @see #getValidators
  103.      * @param validator Validator object which performs validation checks on
  104.      *        this set of data field values
  105.      */
  106.     public void addValidator(Validator validator);
  107.     /**
  108.      * Removes the specified validator from this data model.
  109.      * @see #addValidator
  110.      * @param validator Validator object which performs validation checks on
  111.      *        this set of data field values
  112.      */
  113.     public void removeValidator(Validator validator);
  114.     /**
  115.      *
  116.      * @return array containing the validators registered for data model
  117.      */
  118.     Validator[] getValidators();
  119.     /**
  120.      * Adds the specified value change listener to be notified when
  121.      * the value is changed outside of calling <code>setValue</code> directly.
  122.      * @param valueChangeListener ValueChangeListener object to receive events
  123.      *        when the field value changes
  124.      */
  125.     void addValueChangeListener(ValueChangeListener valueChangeListener);
  126.     /**
  127.      * Removes the specified value change listener from this value adapter.
  128.      * @param valueChangeListener ValueChangeListener object to receive events
  129.      *        when the field value changes
  130.      */
  131.     void removeValueChangeListener(ValueChangeListener valueChangeListener);
  132.     /**
  133.      *
  134.      * @return array containing the ValueChangeListener objects registered
  135.      *         on this data model
  136.      */
  137.     ValueChangeListener[] getValueChangeListeners();
  138. }