svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.api / src / main / java / org / gvsig / fmap / dal / feature / FeatureSet.java @ 40559
History | View | Annotate | Download (12.1 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.fmap.dal.feature; |
25 |
|
26 |
import java.util.List; |
27 |
|
28 |
import org.gvsig.fmap.dal.DataSet; |
29 |
import org.gvsig.fmap.dal.exception.DataException; |
30 |
import org.gvsig.tools.dispose.DisposableIterator; |
31 |
import org.gvsig.tools.dynobject.DynObject; |
32 |
import org.gvsig.tools.dynobject.DynObjectSet; |
33 |
import org.gvsig.tools.exception.BaseException; |
34 |
import org.gvsig.tools.visitor.IndexedVisitable; |
35 |
import org.gvsig.tools.visitor.Visitor; |
36 |
|
37 |
/**
|
38 |
* A FeatureSet represents a set of {@link Feature}(s). These sets of features
|
39 |
* are typically obtained directly from a {@link FeatureStore}, or through a
|
40 |
* {@link FeatureQuery}.
|
41 |
*
|
42 |
* A FeatureSet may contain subsets of {@link Feature}(s) of different
|
43 |
* {@link FeatureType}(s). It allows iterating and editing the features.
|
44 |
*
|
45 |
* FIXME: Actualizar javadoc
|
46 |
*
|
47 |
* Si el store en el que esta basado el featureset es modificado, se realiza un
|
48 |
* update, insert, delete o se modifican los featuretype de este, el FeatureSet
|
49 |
* quedara invalidado, y cualquier acceso a el provocara que se lance una
|
50 |
* excepcion de tiempo de ejecucion ConcurrentModificationException.
|
51 |
*
|
52 |
* Habria que indicar que invocar al metodo accept del interface visitor
|
53 |
* provocara la excepcion ConcurrentModificationException si el store a sido
|
54 |
* modificado desde otro punto.
|
55 |
*
|
56 |
* Indicar que los metodos insert/delete/update ademas de actuar sobre el set,
|
57 |
* actuan sobre el store en el que este esta basado, pero que no invalidan el
|
58 |
* set sobre el que se ejecutan. No se si esto deberia hacerse mencion en esos
|
59 |
* metodos o en la doc general del featureset.
|
60 |
*
|
61 |
*/
|
62 |
public interface FeatureSet extends DataSet, IndexedVisitable { |
63 |
|
64 |
/**
|
65 |
* Returns the default {@link FeatureType} of this FeatureSet.
|
66 |
*
|
67 |
* @return default {@link FeatureType} in this FeatureSet.
|
68 |
*/
|
69 |
public FeatureType getDefaultFeatureType();
|
70 |
|
71 |
/**
|
72 |
* Returns a list of the {@link FeatureType}(s) in this FeatureSet.
|
73 |
*
|
74 |
* @return list of the {@link FeatureType}(s) in this FeatureSet.
|
75 |
*/
|
76 |
public List getFeatureTypes(); |
77 |
|
78 |
/**
|
79 |
* Returns the number of {@link Feature}(s) contained in this FeatureSet.
|
80 |
*
|
81 |
* The value returned by this method won't be accurate when
|
82 |
* the FeatureStore is being edited and this set's features
|
83 |
* are modified, added or deleted.
|
84 |
*
|
85 |
* @return number of {@link Feature}(s) contained in this FeatureSet.
|
86 |
*
|
87 |
* @throws DataException
|
88 |
*/
|
89 |
public long getSize() throws DataException; |
90 |
|
91 |
/**
|
92 |
* Returns an iterator over the elements in this collection, in the order
|
93 |
* (if any) defined when the collection was obtained.
|
94 |
*
|
95 |
* The iterator starts at the specified position in this collection. The
|
96 |
* specified index indicates the first element that would be returned by an
|
97 |
* initial call to the <tt>next</tt> method. An initial call to the
|
98 |
* <tt>previous</tt> method would return the element with the specified
|
99 |
* index minus one.
|
100 |
*
|
101 |
* <p>
|
102 |
* <em>
|
103 |
* <strong>NOTE:</strong> if you use this method to get the iterator, you
|
104 |
* must get sure the iterator is disposed (@see
|
105 |
* {@link DisposableIterator#dispose()}) in any case, even if an error occurs
|
106 |
* while getting the data. It is recommended to use the <code>accept</code>
|
107 |
* methods instead, which handle everything for you.
|
108 |
* Take into account the accept methods may use a fast iterator to
|
109 |
* get the features.
|
110 |
* </em>
|
111 |
* </p>
|
112 |
*
|
113 |
* @see #accept(org.gvsig.tools.visitor.Visitor)
|
114 |
* @see #accept(org.gvsig.tools.visitor.Visitor, long)
|
115 |
* @see #fastIterator()
|
116 |
* @see #fastIterator(long)
|
117 |
*
|
118 |
* @param index
|
119 |
* index of first element to be returned from the iterator (by a
|
120 |
* call to the <tt>next</tt> method).
|
121 |
* @return an iterator of the elements in this collection (in proper
|
122 |
* sequence), starting at the specified position in the collection.
|
123 |
* @throws DataException
|
124 |
* if the index is out of range (index < 0 || index >
|
125 |
* size()).
|
126 |
* @deprecated use {@link #fastIterator(long)} instead
|
127 |
*/
|
128 |
DisposableIterator iterator(long index) throws DataException; |
129 |
|
130 |
/**
|
131 |
* Returns an iterator over the elements in this collection, in the order
|
132 |
* (if any) defined when the collection was obtained.
|
133 |
*
|
134 |
* <p>
|
135 |
* <em>
|
136 |
* <strong>NOTE:</strong> if you use this method to get the iterator, you
|
137 |
* must get sure the iterator is disposed (@see
|
138 |
* {@link DisposableIterator#dispose()}) in any case, even if an error occurs
|
139 |
* while getting the data. It is recommended to use the <code>accept</code>
|
140 |
* methods instead, which handle everything for you.
|
141 |
* Take into account the accept methods may use a fast iterator to
|
142 |
* get the features.
|
143 |
* </em>
|
144 |
* </p>
|
145 |
*
|
146 |
* @see #accept(org.gvsig.tools.visitor.Visitor)
|
147 |
* @see #accept(org.gvsig.tools.visitor.Visitor, long)
|
148 |
* @see #fastIterator()
|
149 |
* @see #fastIterator(long)
|
150 |
*
|
151 |
* @return an iterator of the elements in this collection (in proper
|
152 |
* sequence).
|
153 |
*
|
154 |
* @throws DataException
|
155 |
* if there is an error getting the iterator
|
156 |
*
|
157 |
* @deprecated use {@link #fastIterator()} instead
|
158 |
*/
|
159 |
DisposableIterator iterator() throws DataException;
|
160 |
|
161 |
/**
|
162 |
* Returns a fast iterator over this set.
|
163 |
* <p>
|
164 |
* Fast in this case means that each of the elements returned may be a
|
165 |
* reused or pooled object instance, so don't use it to be stored in any
|
166 |
* way.
|
167 |
* </p>
|
168 |
* <p>
|
169 |
* If you need to store one of the {@link Feature} of the iterator, use the
|
170 |
* {@link Feature#getCopy()} to create a clone of the object.
|
171 |
* </p>
|
172 |
*
|
173 |
* <p>
|
174 |
* <em>
|
175 |
* <strong>NOTE:</strong> if you use this method to get the iterator, you
|
176 |
* must get sure the iterator is disposed (@see
|
177 |
* {@link DisposableIterator#dispose()}) in any case, even if an error occurs
|
178 |
* while getting the data. It is recommended to use the <code>accept</code>
|
179 |
* methods instead, which handle everything for you.
|
180 |
* Take into account the accept methods may use a fast iterator to
|
181 |
* get the features.
|
182 |
* </em>
|
183 |
* </p>
|
184 |
*
|
185 |
* @see #accept(org.gvsig.tools.visitor.Visitor)
|
186 |
* @see #accept(org.gvsig.tools.visitor.Visitor, long)
|
187 |
*
|
188 |
* @return an iterator over this set.
|
189 |
*
|
190 |
* @throws DataException
|
191 |
*/
|
192 |
public DisposableIterator fastIterator() throws DataException; |
193 |
|
194 |
/**
|
195 |
* Returns a fast iterator over this set, starting from the given index.
|
196 |
* <p>
|
197 |
* Fast in this case means that each of the elements returned may be a
|
198 |
* reused or pooled object instance, so don't use it to be stored in any
|
199 |
* way.
|
200 |
* </p>
|
201 |
* <p>
|
202 |
* If you need to store one of the {@link Feature} of the iterator, use the
|
203 |
* {@link Feature#getCopy()} to create a clone of the object.
|
204 |
* </p>
|
205 |
*
|
206 |
* <p>
|
207 |
* <em>
|
208 |
* <strong>NOTE:</strong> if you use this method to get the iterator, you
|
209 |
* must get sure the iterator is disposed (@see
|
210 |
* {@link DisposableIterator#dispose()}) in any case, even if an error occurs
|
211 |
* while getting the data. It is recommended to use the <code>accept</code>
|
212 |
* methods instead, which handle everything for you.
|
213 |
* Take into account the accept methods may use a fast iterator to
|
214 |
* get the features.
|
215 |
* </em>
|
216 |
* </p>
|
217 |
*
|
218 |
* @see #accept(org.gvsig.tools.visitor.Visitor)
|
219 |
* @see #accept(org.gvsig.tools.visitor.Visitor, long)
|
220 |
*
|
221 |
* @param index
|
222 |
* position in which the iterator is initially located.
|
223 |
*
|
224 |
* @return an iterator initially located at the position indicated by the
|
225 |
* given index
|
226 |
*
|
227 |
* @throws DataException
|
228 |
*/
|
229 |
public DisposableIterator fastIterator(long index) throws DataException; |
230 |
|
231 |
/**
|
232 |
* Indicates whether this FeatureSet contains zero features.
|
233 |
*
|
234 |
* The value returned by this method won't be accurate when
|
235 |
* the FeatureStore is being edited and this set's features
|
236 |
* are modified, added or deleted.
|
237 |
*
|
238 |
* @return true if this FeatureSet is empty, false otherwise.
|
239 |
*
|
240 |
* @throws DataException
|
241 |
*/
|
242 |
boolean isEmpty() throws DataException; |
243 |
|
244 |
/**
|
245 |
* Updates a {@link Feature} with the given {@link EditableFeature}.<br>
|
246 |
*
|
247 |
* Any {@link DisposableIterator} from this store that was still in use can will not
|
248 |
* reflect this change.
|
249 |
*
|
250 |
* @param feature
|
251 |
* an instance of {@link EditableFeature} with which to update
|
252 |
* the associated {@link Feature}.
|
253 |
*
|
254 |
* @throws DataException
|
255 |
*/
|
256 |
public void update(EditableFeature feature) throws DataException; |
257 |
|
258 |
/**
|
259 |
* Deletes a {@link Feature} from this FeatureSet.<br>
|
260 |
*
|
261 |
* Any {@link DisposableIterator} from this store that was still in use will be
|
262 |
* <i>unsafe</i>. Use {@link DisposableIterator#remove()} instead.
|
263 |
*
|
264 |
* @param feature
|
265 |
* the {@link Feature} to delete.
|
266 |
*
|
267 |
* @throws DataException
|
268 |
*/
|
269 |
public void delete(Feature feature) throws DataException; |
270 |
|
271 |
/**
|
272 |
* Inserts a new feature in this set. It needs to be an instance of
|
273 |
* {@link EditableFeature} as it has not been stored yet.<br>
|
274 |
*
|
275 |
* Any {@link DisposableIterator} from this store that was still in use can will not
|
276 |
* reflect this change.
|
277 |
*
|
278 |
* @param feature
|
279 |
* the {@link EditableFeature} to insert.
|
280 |
*
|
281 |
* @throws DataException
|
282 |
*/
|
283 |
public void insert(EditableFeature feature) throws DataException; |
284 |
|
285 |
/**
|
286 |
* Returns a {@link DynObjectSet} of the contents of this set.
|
287 |
* Defaults to fast iteration.
|
288 |
*
|
289 |
* @return a {@link DynObjectSet}
|
290 |
*/
|
291 |
public DynObjectSet getDynObjectSet();
|
292 |
|
293 |
/**
|
294 |
* Returns a {@link DynObjectSet} of the contents of this set.
|
295 |
*
|
296 |
* @param fast
|
297 |
* if the set will be able to be iterated in a fast way, by
|
298 |
* reusing the {@link DynObject} instance for each
|
299 |
* {@link Feature} instance.
|
300 |
* @return a {@link DynObjectSet}
|
301 |
*/
|
302 |
public DynObjectSet getDynObjectSet(boolean fast); |
303 |
|
304 |
/**
|
305 |
* Provides each value of this Store to the provided {@link Visitor},
|
306 |
* beginning from the provided index position.
|
307 |
* The values received through the {@link Visitor#visit(Object)} method
|
308 |
* may be transient, reused or externally modifiable, so they can't
|
309 |
* be used to be stored in any external form out of the visit method.
|
310 |
*
|
311 |
* If you need to store any of the values out of the
|
312 |
* {@link Visitor#visit(Object)} method execution, create a copy or clone
|
313 |
* the received value in order to be stored.
|
314 |
*
|
315 |
* @param visitor
|
316 |
* the visitor to apply to each value.
|
317 |
* @param firstValueIndex
|
318 |
* index of first element to be visited by the {@link Visitor}
|
319 |
* @exception BaseException
|
320 |
* if there is an error while performing the visit
|
321 |
*/
|
322 |
void accept(Visitor visitor, long firstValueIndex) throws BaseException; |
323 |
} |