Revision 29326 branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/spi/memory/AbstractMemoryStoreProvider.java
AbstractMemoryStoreProvider.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import org.gvsig.fmap.dal.DataStoreParameters; |
7 | 7 |
import org.gvsig.fmap.dal.exception.DataException; |
8 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
9 |
import org.gvsig.fmap.dal.feature.DisposableIterator; |
|
10 | 8 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
11 | 9 |
import org.gvsig.fmap.dal.feature.FeatureType; |
12 | 10 |
import org.gvsig.fmap.dal.feature.exception.PerformEditingException; |
... | ... | |
15 | 13 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
16 | 14 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
17 | 15 |
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider; |
18 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider;
|
|
19 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices;
|
|
16 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
|
|
17 |
import org.gvsig.tools.dynobject.DynObject;
|
|
20 | 18 |
|
21 | 19 |
public abstract class AbstractMemoryStoreProvider extends |
22 | 20 |
AbstractFeatureStoreProvider { |
23 | 21 |
|
24 | 22 |
protected ArrayList data; |
25 |
protected DataStoreParameters parameters; |
|
26 | 23 |
|
27 |
public AbstractMemoryStoreProvider(DataStoreParameters parameters) {
|
|
28 |
super();
|
|
29 |
this.parameters = parameters;
|
|
24 |
protected AbstractMemoryStoreProvider(DataStoreParameters params,
|
|
25 |
DataStoreProviderServices storeServices, DynObject metadata) {
|
|
26 |
super(params, storeServices, metadata);
|
|
30 | 27 |
} |
31 | 28 |
|
32 |
public FeatureStoreProvider initialize(FeatureStoreProviderServices store) |
|
33 |
throws InitializeException { |
|
34 |
super.initialize(store); |
|
35 |
return this; |
|
29 |
protected AbstractMemoryStoreProvider(DataStoreParameters params, |
|
30 |
DataStoreProviderServices storeServices) { |
|
31 |
super(params, storeServices); |
|
36 | 32 |
} |
37 | 33 |
|
38 | 34 |
public void performChanges(Iterator deleteds, Iterator inserteds, Iterator updateds, Iterator originalFeatureTypesUpdated) throws PerformEditingException { |
... | ... | |
44 | 40 |
this.data.add(data); |
45 | 41 |
} |
46 | 42 |
|
47 |
public DisposableIterator dataIterator() throws DataException { |
|
48 |
this.open(); |
|
49 |
return new DelegatedDisposableIterator(this.data.iterator()); |
|
50 |
} |
|
51 | 43 |
|
52 |
public DisposableIterator dataIterator(long index) throws DataException { |
|
53 |
this.open(); |
|
54 |
return new DelegatedDisposableIterator(this.data |
|
55 |
.listIterator((int) index)); |
|
56 |
} |
|
57 |
public DisposableIterator dataIterator(FeatureType featureType) |
|
58 |
throws DataException { |
|
59 |
this.open(); |
|
60 |
return new DelegatedDisposableIterator(this.data.iterator(), |
|
61 |
featureType); |
|
62 |
} |
|
63 | 44 |
|
64 |
public DisposableIterator dataIterator(long index, FeatureType featureType) |
|
65 |
throws DataException { |
|
66 |
this.open(); |
|
67 |
return new DelegatedDisposableIterator(this.data |
|
68 |
.listIterator((int) index), featureType); |
|
69 |
} |
|
70 |
|
|
71 | 45 |
public long getDataSize() throws DataException { |
72 | 46 |
this.open(); |
73 | 47 |
return this.data.size(); |
... | ... | |
92 | 66 |
public FeatureSetProvider createSet(FeatureQuery query, FeatureType featureType) |
93 | 67 |
throws DataException { |
94 | 68 |
this.open(); |
95 |
return new MemoryFeatureSet(this, query, featureType); |
|
69 |
return new MemoryFeatureSet(this, query, featureType, this.data);
|
|
96 | 70 |
} |
97 | 71 |
|
98 | 72 |
public FeatureProvider createFeatureProvider(FeatureType featureType)throws DataException { |
... | ... | |
100 | 74 |
return new DefaultFeatureProvider(featureType); |
101 | 75 |
} |
102 | 76 |
|
103 |
public boolean canWriteGeometry(int geometryType, int geometrySubType) { |
|
104 |
// By default memory stores support all geometry types |
|
105 |
return true; |
|
106 |
} |
|
107 | 77 |
|
108 |
protected abstract void initializeFeatureTypes() throws InitializeException; |
|
109 |
|
|
110 |
private class DelegatedDisposableIterator implements DisposableIterator { |
|
111 |
private Iterator delegated; |
|
112 |
private FeatureType fType; |
|
113 |
|
|
114 |
public DelegatedDisposableIterator(Iterator it) { |
|
115 |
this(it, null); |
|
116 |
} |
|
117 |
|
|
118 |
public DelegatedDisposableIterator(Iterator it, FeatureType featureType) { |
|
119 |
this.delegated = it; |
|
120 |
this.fType = featureType; |
|
121 |
|
|
122 |
} |
|
123 |
|
|
124 |
public void dispose() { |
|
125 |
this.delegated = null; |
|
126 |
} |
|
127 |
|
|
128 |
public boolean hasNext() { |
|
129 |
return delegated.hasNext(); |
|
130 |
} |
|
131 |
|
|
132 |
public Object next() { |
|
133 |
if (fType == null) { |
|
134 |
return delegated.next(); |
|
135 |
} else { |
|
136 |
return new MemoryFeatureProviderAttributeMapper( |
|
137 |
(DefaultFeatureProvider) delegated.next(), |
|
138 |
this.fType); |
|
139 |
} |
|
140 |
|
|
141 |
} |
|
142 |
|
|
143 |
public void remove() { |
|
144 |
throw new UnsupportedOperationException(); |
|
145 |
} |
|
146 |
|
|
147 |
} |
|
148 |
|
|
149 | 78 |
public long getFeatureCount() throws DataException { |
150 | 79 |
return data.size(); |
151 | 80 |
} |
Also available in: Unified diff