Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / FeatureSet.java @ 34026

History | View | Annotate | Download (8.76 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.visitor.IndexedVisitable;
11

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
253
}