01: package org.geotools.data.jdbc;
02:
03: import java.io.IOException;
04:
05: import org.geotools.data.jdbc.collection.JDBCFeatureCollection;
06: import org.geotools.data.store.ContentEntry;
07: import org.geotools.data.store.ContentFeatureSource;
08: import org.geotools.data.store.ContentState;
09: import org.geotools.feature.FeatureCollection;
10: import org.geotools.feature.FeatureType;
11: import org.opengis.filter.Filter;
12:
13: public class JDBCFeatureSource extends ContentFeatureSource {
14:
15: PrimaryKey primaryKey;
16:
17: public JDBCFeatureSource(ContentEntry entry) throws IOException {
18: super (entry);
19:
20: primaryKey = ((JDBCDataStore) entry.getDataStore())
21: .getPrimaryKey(entry);
22: }
23:
24: public PrimaryKey getPrimaryKey() {
25: return primaryKey;
26: }
27:
28: protected FeatureType buildFeatureType() throws IOException {
29:
30: try {
31: return JDBCUtils.buildFeatureType(entry.getName(),
32: (JDBCDataStore) entry.getDataStore());
33: } catch (Exception e) {
34: throw (IOException) new IOException().initCause(e);
35: }
36: }
37:
38: protected FeatureCollection all(ContentState state) {
39: return new JDBCFeatureCollection(this , (JDBCState) state);
40: }
41:
42: protected FeatureCollection filtered(ContentState state,
43: Filter filter) {
44: return new JDBCFeatureCollection(this , (JDBCState) state,
45: filter);
46: }
47:
48: }
|