root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / spi / memory / AbstractMemoryStoreProvider.java @ 24496
History | View | Annotate | Download (2.73 KB)
1 |
package org.gvsig.fmap.dal.feature.spi.memory; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
import java.util.Iterator; |
5 |
|
6 |
import org.gvsig.fmap.dal.DataStoreParameters; |
7 |
import org.gvsig.fmap.dal.exceptions.DataException; |
8 |
import org.gvsig.fmap.dal.exceptions.InitializeException; |
9 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
10 |
import org.gvsig.fmap.dal.feature.FeatureType; |
11 |
import org.gvsig.fmap.dal.feature.exceptions.PerformEditingException; |
12 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider; |
13 |
import org.gvsig.fmap.dal.feature.spi.DefaultFeatureData; |
14 |
import org.gvsig.fmap.dal.feature.spi.FeatureData; |
15 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
16 |
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider; |
17 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider; |
18 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices; |
19 |
|
20 |
public abstract class AbstractMemoryStoreProvider extends |
21 |
AbstractFeatureStoreProvider { |
22 |
|
23 |
protected ArrayList data; |
24 |
protected DataStoreParameters parameters;
|
25 |
|
26 |
public AbstractMemoryStoreProvider(DataStoreParameters parameters) {
|
27 |
this.parameters = parameters;
|
28 |
} |
29 |
|
30 |
public FeatureStoreProvider initialize(FeatureStoreProviderServices store)
|
31 |
throws InitializeException {
|
32 |
super.initialize(store);
|
33 |
return this; |
34 |
} |
35 |
|
36 |
public void performEditing(Iterator deleteds, Iterator inserteds, Iterator updateds) throws PerformEditingException { |
37 |
throw new UnsupportedOperationException(); |
38 |
} |
39 |
|
40 |
public void addFeatureData(FeatureData data) { |
41 |
data.setOID(new Integer(this.data.size())); |
42 |
this.data.add(data);
|
43 |
} |
44 |
|
45 |
public Iterator dataIterator() throws DataException { |
46 |
this.open();
|
47 |
return this.data.iterator(); |
48 |
} |
49 |
|
50 |
public Iterator dataIterator(long index) throws DataException { |
51 |
this.open();
|
52 |
return this.data.listIterator((int) index); |
53 |
} |
54 |
|
55 |
public long getDataSize() throws DataException { |
56 |
this.open();
|
57 |
return this.data.size(); |
58 |
} |
59 |
|
60 |
public FeatureData getFeatureDataByReference(
|
61 |
FeatureReferenceProviderServices reference) |
62 |
throws DataException {
|
63 |
return getFeatureDataByReference(reference, this.store |
64 |
.getDefaultFeatureType()); |
65 |
} |
66 |
|
67 |
public FeatureData getFeatureDataByReference(
|
68 |
FeatureReferenceProviderServices reference, |
69 |
FeatureType featureType) throws DataException {
|
70 |
int oid = ((Integer) reference.getOID()).intValue(); |
71 |
return (FeatureData) this.data.get(oid); |
72 |
} |
73 |
|
74 |
public FeatureSetProvider createSet(FeatureQuery query)
|
75 |
throws DataException {
|
76 |
this.open();
|
77 |
return new MemoryFeatureSet(this, query); |
78 |
} |
79 |
|
80 |
public FeatureData createFeatureData(FeatureType featureType)throws DataException { |
81 |
this.open();
|
82 |
return new DefaultFeatureData(featureType); |
83 |
} |
84 |
|
85 |
public boolean canWriteGeometry(int geometryType) { |
86 |
// By default memory stores support all geometry types
|
87 |
return true; |
88 |
} |
89 |
|
90 |
|
91 |
} |