svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / spi / memory / AbstractMemoryStoreProvider.java @ 25785
History | View | Annotate | Download (2.8 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.exception.DataException; |
8 |
import org.gvsig.fmap.dal.exception.InitializeException; |
9 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
10 |
import org.gvsig.fmap.dal.feature.FeatureType; |
11 |
import org.gvsig.fmap.dal.feature.exception.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 |
super();
|
28 |
this.parameters = parameters;
|
29 |
} |
30 |
|
31 |
public FeatureStoreProvider initialize(FeatureStoreProviderServices store)
|
32 |
throws InitializeException {
|
33 |
super.initialize(store);
|
34 |
return this; |
35 |
} |
36 |
|
37 |
public void performEditing(Iterator deleteds, Iterator inserteds, Iterator updateds) throws PerformEditingException { |
38 |
throw new UnsupportedOperationException(); |
39 |
} |
40 |
|
41 |
public void addFeatureData(FeatureData data) { |
42 |
data.setOID(this.createNewOID());
|
43 |
this.data.add(data);
|
44 |
} |
45 |
|
46 |
public Iterator dataIterator() throws DataException { |
47 |
this.open();
|
48 |
return this.data.iterator(); |
49 |
} |
50 |
|
51 |
public Iterator dataIterator(long index) throws DataException { |
52 |
this.open();
|
53 |
return this.data.listIterator((int) index); |
54 |
} |
55 |
|
56 |
public long getDataSize() throws DataException { |
57 |
this.open();
|
58 |
return this.data.size(); |
59 |
} |
60 |
|
61 |
public FeatureData getFeatureDataByReference(
|
62 |
FeatureReferenceProviderServices reference) |
63 |
throws DataException {
|
64 |
return getFeatureDataByReference(reference, this.store |
65 |
.getDefaultFeatureType()); |
66 |
} |
67 |
|
68 |
public FeatureData getFeatureDataByReference(
|
69 |
FeatureReferenceProviderServices reference, |
70 |
FeatureType featureType) throws DataException {
|
71 |
int oid = ((Integer) reference.getOID()).intValue(); |
72 |
return (FeatureData) this.data.get(oid); |
73 |
} |
74 |
|
75 |
public FeatureSetProvider createSet(FeatureQuery query)
|
76 |
throws DataException {
|
77 |
this.open();
|
78 |
return new MemoryFeatureSet(this, query); |
79 |
} |
80 |
|
81 |
public FeatureData createFeatureData(FeatureType featureType)throws DataException { |
82 |
this.open();
|
83 |
return new DefaultFeatureData(featureType); |
84 |
} |
85 |
|
86 |
public boolean canWriteGeometry(int geometryType) { |
87 |
// By default memory stores support all geometry types
|
88 |
return true; |
89 |
} |
90 |
|
91 |
protected abstract void initializeFeatureTypes() throws InitializeException; |
92 |
|
93 |
} |