1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
/*
Wotonomy: OpenStep design patterns for pure Java applications.
Copyright (C) 2000 Michael Powers
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see http://www.gnu.org
*/
package net.wotonomy.datastore;
import java.util.Collection;
public interface DataSoup {
/**
* Adds the specified object to the soup and returns the key for the new object
* by which it may be subsequently retrieved. Null indicates an error, probably
* due to serialization.
*
* @param anObject Object to be added to soup.
* @return The unique identifier used for the new object.
*/
public DataKey addObject(Object anObject);
/**
* Removes the specified object from the soup and returns the removed object as
* read from the soup (which is the original copy of the object). Null indicates
* object not found.
*
* @param aKey A key for an object to be removed.
* @return The object that was removed, or null if not found or error.
*/
public Object removeObject(DataKey aKey);
/**
* Updates the specified object and returns the object as updated. Null
* indicates an error writing the object.
*
* @param aKey A key for an object to be updated.
* @param aKey The new object for that key.
* @return A copy of the updated object, possibly updated, or null if not found
* or error.
*/
public Object updateObject(DataKey aKey, Object updatedObject);
/**
* Gets object from data store whose identifier is equal to the specified
* object.
*
* @param aKey A key for an object to be retrieved.
* @return The corresponding object from the soup.
*/
public Object getObjectByKey(DataKey aKey);
/**
* Registers an object that may or may not be created later, returning a
* temporary but uniquely identifiable key. The key will be replaced with a
* permanent key when the object is created with addObject().
*
* @param anObject An object to be registered.
* @return A temporary key for this object.
*/
public DataKey registerTemporaryObject(Object anObject);
// index management
/**
* Adds an index to the soup.
*
* @param aName The string identifier for this index.
* @param aProperty The property on which this index will be based.
*/
public void addIndex(String aName, String aProperty);
/**
* Deletes the specified index from the soup.
*
* @param aName The string identifier for the index to be removed.
*/
public void removeIndex(String aName);
/**
* Gets a collection of all indices in this soup.
*
* @return A collection of all indices in this soup.
*/
public Collection<String> getAllIndices();
// relationship management
/**
* Adds a relation to entries in another soup.
*
* @param aProperty The property on which this relation will be based.
* @param aSoup The name of the soup to be related in this store.
*/
// public void addRelation( String aProperty, String aSoup );
/**
* Deletes the specified relation to entries in another soup.
*
* @param aProperty The property on which this relation will be based.
* @param aSoup The name of the soup to be related in this store.
*/
// public void removeRelation( String aProperty, String aSoup );
/**
* Gets a collection of all relations in this soup.
*
* @return A collection of all relation in this soup.
*/
// public Collection getAllRelations();
// queries
/**
* Returns an empty data view, suitable for creating new entries in the soup.
*
* @return A DataView containing no entries.
*/
public DataView createView();
/**
* Queries by the specified pre-generated index, if it exists. Will return
* objects whose values for the indexed property fall between the two values
* inclusive. Otherwise, falls through to queryByProperty.
*
* @param anIndexName The index to be queried.
* @param beginValue The beginning value, or null for all values up to an
* including the end key.
* @param endValue The ending value, or null for all values since and
* including the begin key.
* @return A DataView containing the query results, or null for invalid query
* parameters.
*/
public DataView queryByIndex(String anIndexName, Object beginKey, Object endKey);
/**
* Generates an index based on the specified property and then executes the
* query. Will return objects whose values for the specified property fall
* between the two values inclusive.
*
* @param aPropertyName The property to be queried. If null, will query the
* objects directly with queryObjects().
* @param beginValue The beginning value, or null for all values up to an
* including the end key.
* @param endValue The ending value, or null for all values since and
* including the begin key.
* @return A DataView containing the query results, or null for invalid query
* parameters.
*/
public DataView queryByProperty(String aPropertyName, Object beginKey, Object endKey);
/**
* Generates an index based on the values of the objects themselves and then
* executes the query. Will return objects whose values fall between the two
* values inclusive.
*
* @param beginValue The beginning value, or null for all values up to and
* including the end key.
* @param endValue The ending value, or null for all values since and
* including the begin key.
* @return A DataView containing the query results, or null for invalid query
* parameters.
*/
public DataView queryObjects(Object beginKey, Object endKey);
/**
* Returns a view containing the objects for the specified keys.
*
* @param aKeyList A collection of keys to be placed in the view.
* @return A DataView containing the objects for the corresponding keys, in the
* order in which the keys are returned from the collection.
*/
public DataView queryByKeys(Collection<String> aKeyList);
/**
* As queryByIndex, but with objects returned in reverse order.
*
* @param anIndexName The index to be queried.
* @param beginValue The beginning value, or null for all values up to and
* including the end key.
* @param endValue The ending value, or null for all values since and
* including the begin key.
* @return A DataView containing the query results, or null for invalid query
* parameters.
*/
public DataView reverseQueryByIndex(String anIndexName, Object beginKey, Object endKey);
/**
* As queryByProperty, but with objects returned in reverse order.
*
* @param aPropertyName The property to be queried. If null, will query the
* objects directly with queryObjects().
* @param beginValue The beginning value, or null for all values up to and
* including the end key.
* @param endValue The ending value, or null for all values since and
* including the begin key.
* @return A DataView containing the query results, or null for invalid query
* parameters.
*/
public DataView reverseQueryByProperty(String aPropertyName, Object beginKey, Object endKey);
/**
* As queryObjects, but with objects returned in reverse order.
*
* @param beginValue The beginning value, or null for all values up to and
* including the end key.
* @param endValue The ending value, or null for all values since and
* including the begin key.
* @return A DataView containing the query results, or null for invalid query
* parameters.
*/
public DataView reverseQueryObjects(Object beginKey, Object endKey);
// public void addIndex( String aName, DataIndex anIndex ) {}
// public void removeIndex( String aName ) {}
// public void addTaggedObject( String aKey, Serializable anObject )
// public Object getTaggedObject( String aKey );
// public void removeTaggedObject( String aKey );
// public void setMetaData(
// String aMetaProperty, Serializable aValue, Serializable anObject );
}
/*
* $Log$ Revision 1.2 2006/02/19 16:26:19 cgruber Move non-unit-test code to
* tests project Fix up code to work with proper imports Fix maven dependencies.
*
* Revision 1.1 2006/02/16 13:18:56 cgruber Check in all sources in
* eclipse-friendly maven-enabled packages.
*
* Revision 1.4 2003/08/14 19:29:38 chochos minor cleanup (imports, static
* method calls, etc)
*
* Revision 1.3 2001/03/05 22:12:11 mpowers Created the control package for a
* datastore-specific implementation of EOObjectStore.
*
* Revision 1.2 2001/02/15 21:12:41 mpowers Added accessors for key throughout
* the api. This breaks compatibility. insertObject now returns the permanent
* key for the newly created object. The old way returned a copy of the object
* which was an additional read that was often ignored. Now you can read it only
* if you need it. Furthermore, there was not other way of getting the permanent
* key.
*
* Revision 1.1.1.1 2000/12/21 15:47:05 mpowers Contributing wotonomy.
*
* Revision 1.2 2000/12/20 16:25:36 michael Added log to all files.
*
*
*/
|