KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > swing > data > DataModel


1 /*
2  * $Id: DataModel.java,v 1.5 2005/02/24 20:35:31 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
8 package org.jdesktop.swing.data;
9
10 import java.util.List JavaDoc;
11
12 /**
13  * <p>
14  * Abstract model interface for representing a record of named data fields.
15  * The map provides a uniform API for accessing data which may be contained
16  * in a variety of data model constructs underneath, such as RowSet,
17  * DefaultTableModelExt, or arbitrary JavaBean classes. The user-interface
18  * Binding classes use this interface to &quot;bind&quot; user-interface
19  * components to field elements in a data model without having to understand
20  * the specific flavor of data model being used by the application.
21  * For example, a field element may map to a named column on a RowSet
22  * or a property on a JavaBean, but the binding classes don't need to
23  * understand those underlying data structures in order to read and write
24  * values.</p>
25  * <p>
26  * For each named field, the data model provides access to:
27  * <ul>
28  * <li>meta-data: information describing the data field, such as type
29  * and edit constraints</li>
30  * <li>value: the current value of the field</li>
31  * </ul>
32  * </p>
33  * <p>
34  * Often data models are collections of like-objects, such as the rows in a
35  * RowSet, or a list of JavaBeans. This interface provides a mechanism
36  * to index into such a collection such that at any given time, the data model
37  * contains the element values associated with the &quot;current&quot; record index
38  * into that collection (the current row, or the current bean, etc).
39  * </p>
40  *
41  *
42  * @author Amy Fowler
43  * @version 1.0
44  */

45 public interface DataModel extends MetaDataProvider {
46
47 //---------------------- moved to MetaDataProvider
48

49 // /**
50
// * @return array containing the names of all data fields in this map
51
// */
52
// String[] getFieldNames();
53
//
54
// MetaData[] getMetaData();
55
//
56
// /**
57
// *
58
// * @param fieldName String containing the name of the field
59
// * @return MetaData object which describes the named field
60
// */
61
// MetaData getMetaData(String fieldName);
62
//
63
// /**
64
// *
65
// * @return integer containing the number of fields in this data model
66
// */
67
// int getFieldCount();
68
//
69

70     /**
71      *
72      * @param fieldName String containing the name of the field
73      * @return Object containing the current value of the named field
74      */

75     Object JavaDoc getValue(String JavaDoc fieldName);
76
77     /**
78      *
79      * @param fieldName String containing the name of the field
80      * @param value Object containing the current value of the named field
81      */

82     void setValue(String JavaDoc fieldName, Object JavaDoc value);
83
84     /**
85      * Adds the specified validator for the fields represented by this
86      * data model.
87      * A validator object may be used to perform validation checks which
88      * require analyzing more than one field value in a single check.
89      * This DataModel instance will be passed in as the <code>value</code>
90      * parameter to the validator's <code>validate</code> method.
91      *
92      * @see #removeValidator
93      * @see #getValidators
94      * @param validator Validator object which performs validation checks on
95      * this set of data field values
96      */

97     public void addValidator(Validator validator);
98
99     /**
100      * Removes the specified validator from this data model.
101      * @see #addValidator
102      * @param validator Validator object which performs validation checks on
103      * this set of data field values
104      */

105     public void removeValidator(Validator validator);
106
107     /**
108      *
109      * @return array containing the validators registered for data model
110      */

111     Validator[] getValidators();
112
113     /**
114      * Adds the specified value change listener to be notified when
115      * the value is changed outside of calling <code>setValue</code> directly.
116      * @param valueChangeListener ValueChangeListener object to receive events
117      * when the field value changes
118      */

119     void addValueChangeListener(ValueChangeListener valueChangeListener);
120
121     /**
122      * Removes the specified value change listener from this value adapter.
123      * @param valueChangeListener ValueChangeListener object to receive events
124      * when the field value changes
125      */

126     void removeValueChangeListener(ValueChangeListener valueChangeListener);
127
128     /**
129      *
130      * @return array containing the ValueChangeListener objects registered
131      * on this data model
132      */

133     ValueChangeListener[] getValueChangeListeners();
134
135
136 }
137
Popular Tags