Revision 25716 branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/IndexFeatureSet.java
IndexFeatureSet.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
package org.gvsig.fmap.dal.feature.impl; |
30 | 30 |
|
31 |
import java.util.ArrayList; |
|
32 |
import java.util.Collections; |
|
31 | 33 |
import java.util.Iterator; |
34 |
import java.util.List; |
|
32 | 35 |
|
36 |
import org.gvsig.fmap.dal.DataStore; |
|
33 | 37 |
import org.gvsig.fmap.dal.exception.DataException; |
34 | 38 |
import org.gvsig.fmap.dal.exception.ReadRuntimeException; |
39 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
35 | 40 |
import org.gvsig.fmap.dal.feature.Feature; |
36 | 41 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
42 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
43 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
37 | 44 |
import org.gvsig.fmap.dal.feature.spi.FeatureData; |
38 | 45 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
39 | 46 |
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider; |
40 | 47 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider; |
41 | 48 |
import org.gvsig.fmap.dal.feature.spi.LongList; |
42 | 49 |
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProviderServices; |
50 |
import org.gvsig.tools.exception.BaseException; |
|
51 |
import org.gvsig.tools.visitor.Visitor; |
|
43 | 52 |
|
44 | 53 |
|
45 |
public class IndexFeatureSet implements FeatureSetProvider { |
|
54 |
public class IndexFeatureSet implements FeatureSet, FeatureSetProvider {
|
|
46 | 55 |
|
47 | 56 |
LongList featureReferences = null; |
48 | 57 |
FeatureStoreProvider store = null; |
49 | 58 |
FeatureIndexProviderServices index = null; |
59 |
List featureTypes = null; |
|
50 | 60 |
|
51 | 61 |
public class IndexIterator implements Iterator { |
52 | 62 |
Iterator it = null; |
... | ... | |
153 | 163 |
return new FastIndexIterator(this.featureReferences.iterator((int)index)); |
154 | 164 |
} |
155 | 165 |
|
166 |
public void delete(Feature feature) throws DataException { |
|
167 |
index.delete(feature); |
|
168 |
index.getFeatureStore().delete(feature); |
|
169 |
} |
|
170 |
|
|
171 |
public FeatureType getDefaultFeatureType() { |
|
172 |
return index.getFeatureType(); |
|
173 |
} |
|
174 |
|
|
175 |
public List getFeatureTypes() { |
|
176 |
List types = new ArrayList(); |
|
177 |
types.add(index.getFeatureType()); |
|
178 |
return Collections.unmodifiableList(types); |
|
179 |
} |
|
180 |
|
|
181 |
public void insert(EditableFeature feature) throws DataException { |
|
182 |
index.insert(feature); |
|
183 |
index.getFeatureStore().insert(feature); |
|
184 |
} |
|
185 |
|
|
186 |
public void update(EditableFeature feature) throws DataException { |
|
187 |
index.getFeatureStore().update(feature); |
|
188 |
// we need to re-index the feature, since its shape might have changed |
|
189 |
index.delete(feature); |
|
190 |
index.insert(feature); |
|
191 |
} |
|
192 |
|
|
193 |
public void dispose() { |
|
194 |
|
|
195 |
} |
|
196 |
|
|
197 |
public boolean isFromStore(DataStore store) { |
|
198 |
return this.store.equals(store); |
|
199 |
} |
|
200 |
|
|
201 |
public void accept(Visitor visitor) throws BaseException { |
|
202 |
Iterator iterator = iterator(); |
|
203 |
|
|
204 |
while (iterator.hasNext()) { |
|
205 |
Feature feature = (Feature) iterator.next(); |
|
206 |
visitor.visit(feature); |
|
207 |
} |
|
208 |
} |
|
209 |
|
|
156 | 210 |
} |
157 | 211 |
|
Also available in: Unified diff