1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.wotonomy.control;
20
21 import net.wotonomy.foundation.NSArray;
22
23 /***
24 * EODataSource is used by EODisplayGroup.fetch() to retrieve
25 * a list of objects to display. When a display group has a
26 * data source, the display group will use the data source to
27 * populate the object list and to create new objects to be
28 * displayed in the list, and will update the data source when
29 * objects are inserted or removed from the list. <br><br>
30 *
31 * In certain cases, as when a display group needs to populate
32 * a child display group to show a one-to-many relationship,
33 * the display group will call dataSourceQualifiedByKey to
34 * return a new data source that can vend objects associated
35 * with the specified key and then call qualifyWithRelationshipKey
36 * to specify the object and key that are the source of the
37 * child relationship. <br><br>
38 *
39 * Concrete subclasses are expected to override fetch() and
40 * are required to override insertObject and removeObject.
41 *
42 * @author michael@mpowers.net
43 * @author $Author: cgruber $
44 * @version $Revision: 894 $
45 */
46 public abstract class EODataSource
47 {
48 /***
49 * Creates a new object. You should call
50 * insertObject() to insert the new object into
51 * this data source.
52 * This implementation attempts to create a new
53 * instance of the class returned by
54 * classDescriptionForObjects().
55 * Override to return an object specific to
56 * your implementation.
57 * @return The newly created object, or null if
58 * new objects are not supported by this data source.
59 * @see #classDescriptionForObjects
60 */
61 public Object createObject ()
62 {
63 Object result = null;
64 EOClassDescription c = classDescriptionForObjects();
65 if ( c != null )
66 {
67 result = c.createInstanceWithEditingContext( editingContext(), null );
68 }
69 return result;
70 }
71
72 /***
73 * Inserts the specified object into this data source.
74 */
75 public abstract void insertObject ( Object anObject );
76
77 /***
78 * Deletes the specified object from this data source.
79 */
80 public abstract void deleteObject ( Object anObject );
81
82 /***
83 * Returns the editing context for this data source,
84 * or null if no editing context is used.
85 * This implementation returns null.
86 */
87 public EOEditingContext editingContext ()
88 {
89 return null;
90 }
91
92 /***
93 * Returns a List containing the objects in this
94 * data source. This implementation returns null.
95 */
96 public NSArray fetchObjects ()
97 {
98 return null;
99 }
100
101 /***
102 * Returns a data source that is capable of
103 * manipulating objects of the type returned by
104 * applying the specified key to objects
105 * vended by this data source.
106 * @see #qualifyWithRelationshipKey
107 */
108 public abstract EODataSource
109 dataSourceQualifiedByKey ( String aKey );
110
111 /***
112 * Restricts this data source to vend those
113 * objects that are associated with the specified
114 * key on the specified object.
115 */
116 public abstract void
117 qualifyWithRelationshipKey (
118 String aKey, Object anObject );
119
120 /***
121 * Returns the description of the class of the
122 * objects that is vended by this data source,
123 * or null if this cannot be determined.
124 * This implementation returns null.
125 */
126 public EOClassDescription
127 classDescriptionForObjects ()
128 {
129 return null;
130 }
131
132 }
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164