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 | 24496 | jmvivo | package org.gvsig.fmap.dal.feature.spi.memory; |
---|---|---|---|
2 | 23842 | jjdelcerro | |
3 | 23875 | jjdelcerro | import java.util.ArrayList; |
4 | import java.util.Iterator; |
||
5 | |||
6 | 24496 | jmvivo | 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 | 23842 | jjdelcerro | |
20 | 23875 | jjdelcerro | public abstract class AbstractMemoryStoreProvider extends |
21 | AbstractFeatureStoreProvider { |
||
22 | 23842 | jjdelcerro | |
23 | 23875 | jjdelcerro | protected ArrayList data; |
24 | 24454 | jmvivo | protected DataStoreParameters parameters;
|
25 | 23842 | jjdelcerro | |
26 | 24454 | jmvivo | public AbstractMemoryStoreProvider(DataStoreParameters parameters) {
|
27 | this.parameters = parameters;
|
||
28 | } |
||
29 | |||
30 | 23875 | jjdelcerro | public FeatureStoreProvider initialize(FeatureStoreProviderServices store)
|
31 | 23842 | jjdelcerro | throws InitializeException {
|
32 | super.initialize(store);
|
||
33 | 23875 | jjdelcerro | return this; |
34 | } |
||
35 | 23842 | jjdelcerro | |
36 | 24144 | vcaballero | public void performEditing(Iterator deleteds, Iterator inserteds, Iterator updateds) throws PerformEditingException { |
37 | 23875 | jjdelcerro | throw new UnsupportedOperationException(); |
38 | 23842 | jjdelcerro | } |
39 | |||
40 | 23875 | jjdelcerro | public void addFeatureData(FeatureData data) { |
41 | 24248 | jjdelcerro | data.setOID(new Integer(this.data.size())); |
42 | 23875 | jjdelcerro | this.data.add(data);
|
43 | } |
||
44 | 23842 | jjdelcerro | |
45 | 23894 | jjdelcerro | public Iterator dataIterator() throws DataException { |
46 | this.open();
|
||
47 | 23875 | jjdelcerro | return this.data.iterator(); |
48 | 23842 | jjdelcerro | } |
49 | |||
50 | 23894 | jjdelcerro | public Iterator dataIterator(long index) throws DataException { |
51 | this.open();
|
||
52 | 23875 | jjdelcerro | return this.data.listIterator((int) index); |
53 | 23842 | jjdelcerro | } |
54 | |||
55 | 23894 | jjdelcerro | public long getDataSize() throws DataException { |
56 | this.open();
|
||
57 | 23875 | jjdelcerro | return this.data.size(); |
58 | } |
||
59 | 23842 | jjdelcerro | |
60 | 24248 | jjdelcerro | 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 | 23875 | jjdelcerro | FeatureType featureType) throws DataException {
|
70 | 24248 | jjdelcerro | int oid = ((Integer) reference.getOID()).intValue(); |
71 | return (FeatureData) this.data.get(oid); |
||
72 | 23842 | jjdelcerro | } |
73 | |||
74 | public FeatureSetProvider createSet(FeatureQuery query)
|
||
75 | throws DataException {
|
||
76 | 23894 | jjdelcerro | this.open();
|
77 | 23875 | jjdelcerro | return new MemoryFeatureSet(this, query); |
78 | 23842 | jjdelcerro | } |
79 | |||
80 | 24248 | jjdelcerro | public FeatureData createFeatureData(FeatureType featureType)throws DataException { |
81 | 24141 | vcaballero | this.open();
|
82 | 24248 | jjdelcerro | return new DefaultFeatureData(featureType); |
83 | 23995 | jmvivo | } |
84 | |||
85 | 23875 | jjdelcerro | public boolean canWriteGeometry(int geometryType) { |
86 | // By default memory stores support all geometry types
|
||
87 | return true; |
||
88 | 23842 | jjdelcerro | } |
89 | |||
90 | |||
91 | } |