Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / FeatureSet.java @ 34827

History | View | Annotate | Download (9.78 KB)

1
package org.gvsig.fmap.dal.feature;
2

    
3
import java.util.List;
4

    
5
import org.gvsig.fmap.dal.DataSet;
6
import org.gvsig.fmap.dal.exception.DataException;
7
import org.gvsig.tools.dispose.DisposableIterator;
8
import org.gvsig.tools.dynobject.DynObject;
9
import org.gvsig.tools.dynobject.DynObjectSet;
10
import org.gvsig.tools.exception.BaseException;
11
import org.gvsig.tools.visitor.IndexedVisitable;
12
import org.gvsig.tools.visitor.Visitor;
13

    
14
/**
15
 * A FeatureSet represents a set of {@link Feature}(s). These sets of features
16
 * are typically obtained directly from a {@link FeatureStore}, or through a
17
 * {@link FeatureQuery}.
18
 * 
19
 * A FeatureSet may contain subsets of {@link Feature}(s) of different
20
 * {@link FeatureType}(s). It allows iterating and editing the features.
21
 * 
22
 * FIXME: Actualizar javadoc
23
 * 
24
 * Si el store en el que esta basado el featureset es modificado, se realiza un
25
 * update, insert, delete o se modifican los featuretype de este, el FeatureSet
26
 * quedara invalidado, y cualquier acceso a el provocara que se lance una
27
 * excepcion de tiempo de ejecucion ConcurrentModificationException.
28
 * 
29
 * Habria que indicar que invocar al metodo accept del interface visitor
30
 * provocara la excepcion ConcurrentModificationException si el store a sido
31
 * modificado desde otro punto.
32
 * 
33
 * Indicar que los metodos insert/delete/update ademas de actuar sobre el set,
34
 * actuan sobre el store en el que este esta basado, pero que no invalidan el
35
 * set sobre el que se ejecutan. No se si esto deberia hacerse mencion en esos
36
 * metodos o en la doc general del featureset.
37
 * 
38
 */
39
public interface FeatureSet extends DataSet, IndexedVisitable {
40

    
41
        /**
42
         * Returns the default {@link FeatureType} of this FeatureSet.
43
         * 
44
         * @return default {@link FeatureType} in this FeatureSet.
45
         */
46
        public FeatureType getDefaultFeatureType();
47

    
48
        /**
49
         * Returns a list of the {@link FeatureType}(s) in this FeatureSet.
50
         * 
51
         * @return list of the {@link FeatureType}(s) in this FeatureSet.
52
         */
53
        public List getFeatureTypes();
54

    
55
        /**
56
         * Returns the number of {@link Feature}(s) contained in this FeatureSet.
57
         * 
58
         * The value returned by this method won't be accurate when
59
         * the FeatureStore is being edited and this set's features
60
         * are modified, added or deleted.
61
         *  
62
         * @return number of {@link Feature}(s) contained in this FeatureSet.
63
         * 
64
         * @throws DataException
65
         */
66
    public long getSize() throws DataException;
67

    
68
        /**
69
         * Returns an iterator over the elements in this collection, in the order
70
         * (if any) defined when the collection was obtained.
71
         * 
72
         * The iterator starts at the specified position in this collection. The
73
         * specified index indicates the first element that would be returned by an
74
         * initial call to the <tt>next</tt> method. An initial call to the
75
         * <tt>previous</tt> method would return the element with the specified
76
         * index minus one.
77
         * 
78
         * <p>
79
         * <em>
80
         * <strong>NOTE:</strong> if you use this method to get the iterator, you
81
         * must get sure the iterator is disposed (@see
82
         * {@link DisposableIterator#dispose()}) in any case, even if an error occurs
83
         * while getting the data. It is recommended to use the <code>accept</code>
84
         * methods instead, which handle everything for you. 
85
         * Take into account the accept methods may use a fast iterator to 
86
         * get the features.
87
         * </em>
88
         * </p>
89
         * 
90
         * @see #accept(org.gvsig.tools.visitor.Visitor)
91
         * @see #accept(org.gvsig.tools.visitor.Visitor, long)
92
         * 
93
         * @param index
94
         *            index of first element to be returned from the iterator (by a
95
         *            call to the <tt>next</tt> method).
96
         * @return an iterator of the elements in this collection (in proper
97
         *         sequence), starting at the specified position in the collection.
98
         * @throws DataException
99
         *             if the index is out of range (index &lt; 0 || index &gt;
100
         *             size()).
101
         */
102
        DisposableIterator iterator(long index) throws DataException;
103

    
104
        /**
105
         * Returns an iterator over the elements in this collection, in the order
106
         * (if any) defined when the collection was obtained.
107
         * 
108
         * <p>
109
         * <em>
110
         * <strong>NOTE:</strong> if you use this method to get the iterator, you
111
         * must get sure the iterator is disposed (@see
112
         * {@link DisposableIterator#dispose()}) in any case, even if an error occurs
113
         * while getting the data. It is recommended to use the <code>accept</code>
114
         * methods instead, which handle everything for you. 
115
         * Take into account the accept methods may use a fast iterator to 
116
         * get the features.
117
         * </em>
118
         * </p>
119
         * 
120
         * @see #accept(org.gvsig.tools.visitor.Visitor)
121
         * @see #accept(org.gvsig.tools.visitor.Visitor, long)
122
         * 
123
         * @return an iterator of the elements in this collection (in proper
124
         *         sequence).
125
         * 
126
         * @throws DataException
127
         */
128
        DisposableIterator iterator() throws DataException;
129

    
130
        /**
131
         * Returns a fast iterator over this set.
132
         * 
133
         * <p>
134
         * <em>
135
         * <strong>NOTE:</strong> if you use this method to get the iterator, you
136
         * must get sure the iterator is disposed (@see
137
         * {@link DisposableIterator#dispose()}) in any case, even if an error occurs
138
         * while getting the data. It is recommended to use the <code>accept</code>
139
         * methods instead, which handle everything for you. 
140
         * Take into account the accept methods may use a fast iterator to 
141
         * get the features.
142
         * </em>
143
         * </p>
144
         * 
145
         * @see #accept(org.gvsig.tools.visitor.Visitor)
146
         * @see #accept(org.gvsig.tools.visitor.Visitor, long)
147
         * 
148
         * @return an iterator over this set.
149
         * 
150
         * @throws DataException
151
         */
152
        public DisposableIterator fastIterator() throws DataException;
153

    
154
        /**
155
         * Returns a fast iterator over this set, starting from the given index.
156
         * 
157
         * <p>
158
         * <em>
159
         * <strong>NOTE:</strong> if you use this method to get the iterator, you
160
         * must get sure the iterator is disposed (@see
161
         * {@link DisposableIterator#dispose()}) in any case, even if an error occurs
162
         * while getting the data. It is recommended to use the <code>accept</code>
163
         * methods instead, which handle everything for you. 
164
         * Take into account the accept methods may use a fast iterator to 
165
         * get the features.
166
         * </em>
167
         * </p>
168
         * 
169
         * @see #accept(org.gvsig.tools.visitor.Visitor)
170
         * @see #accept(org.gvsig.tools.visitor.Visitor, long)
171
         * 
172
         * @param index
173
         *            position in which the iterator is initially located.
174
         * 
175
         * @return an iterator initially located at the position indicated by the
176
         *         given index
177
         * 
178
         * @throws DataException
179
         */
180
        public DisposableIterator fastIterator(long index) throws DataException;
181

    
182
        /**
183
         * Indicates whether this FeatureSet contains zero features.
184
         * 
185
         * The value returned by this method won't be accurate when
186
         * the FeatureStore is being edited and this set's features
187
         * are modified, added or deleted.
188
         *  
189
         * @return true if this FeatureSet is empty, false otherwise.
190
         * 
191
         * @throws DataException
192
         */
193
        boolean isEmpty() throws DataException;
194

    
195
        /**
196
         * Updates a {@link Feature} with the given {@link EditableFeature}.<br>
197
         * 
198
         * Any {@link DisposableIterator} from this store that was still in use can will not
199
         * reflect this change.
200
         * 
201
         * @param feature
202
         *            an instance of {@link EditableFeature} with which to update
203
         *            the associated {@link Feature}.
204
         * 
205
         * @throws DataException
206
         */
207
        public void update(EditableFeature feature) throws DataException;
208

    
209
        /**
210
         * Deletes a {@link Feature} from this FeatureSet.<br>
211
         * 
212
         * Any {@link DisposableIterator} from this store that was still in use will be
213
         * <i>unsafe</i>. Use {@link DisposableIterator#remove()} instead.
214
         * 
215
         * @param feature
216
         *            the {@link Feature} to delete.
217
         * 
218
         * @throws DataException
219
         */
220
        public void delete(Feature feature) throws DataException;
221

    
222
        /**
223
         * Inserts a new feature in this set. It needs to be an instance of
224
         * {@link EditableFeature} as it has not been stored yet.<br>
225
         * 
226
         * Any {@link DisposableIterator} from this store that was still in use can will not
227
         * reflect this change.
228
         * 
229
         * @param feature
230
         *            the {@link EditableFeature} to insert.
231
         * 
232
         * @throws DataException
233
         */
234
        public void insert(EditableFeature feature) throws DataException;
235

    
236
    /**
237
     * Returns a {@link DynObjectSet} of the contents of this set.
238
     * Defaults to fast iteration.
239
     * 
240
     * @return a {@link DynObjectSet}
241
     */
242
    public DynObjectSet getDynObjectSet();
243

    
244
    /**
245
     * Returns a {@link DynObjectSet} of the contents of this set.
246
     * 
247
     * @param fast
248
     *            if the set will be able to be iterated in a fast way, by
249
     *            reusing the {@link DynObject} instance for each
250
     *            {@link Feature} instance.
251
     * @return a {@link DynObjectSet}
252
     */
253
    public DynObjectSet getDynObjectSet(boolean fast);
254

    
255
    /**
256
     * Provides each value of this Store to the provided {@link Visitor},
257
     * beginning from the provided index position.
258
     * The values received through the {@link Visitor#visit(Object)} method
259
     * may be transient, reused or externally modifiable, so they can't
260
     * be used to be stored in any external form out of the visit method.
261
     * 
262
     * If you need to store any of the values out of the
263
     * {@link Visitor#visit(Object)} method execution, create a copy or clone
264
     * the received value in order to be stored.
265
     * 
266
     * @param visitor
267
     *            the visitor to apply to each value.
268
     * @param firstValueIndex
269
     *            index of first element to be visited by the {@link Visitor}
270
     * @exception BaseException
271
     *                if there is an error while performing the visit
272
     */
273
    void accept(Visitor visitor, long firstValueIndex) throws BaseException;
274
}