svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dalfile / src / org / gvsig / fmap / dal / store / shp / SHPFeatureData.java @ 29289
History | View | Annotate | Download (1.63 KB)
1 |
package org.gvsig.fmap.dal.store.shp; |
---|---|
2 |
|
3 |
import org.gvsig.fmap.dal.exception.DataException; |
4 |
import org.gvsig.fmap.dal.exception.ReadRuntimeException; |
5 |
import org.gvsig.fmap.dal.feature.FeatureType; |
6 |
import org.gvsig.fmap.dal.feature.spi.DefaultFeatureProvider; |
7 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
8 |
import org.gvsig.fmap.geom.Geometry; |
9 |
import org.gvsig.fmap.geom.primitive.Envelope; |
10 |
|
11 |
public class SHPFeatureData extends DefaultFeatureProvider { |
12 |
protected SHPStoreProvider store;
|
13 |
protected boolean loading; |
14 |
protected boolean loaded; |
15 |
|
16 |
|
17 |
public SHPFeatureData(SHPStoreProvider store, FeatureType type) {
|
18 |
super(type);
|
19 |
this.store = store;
|
20 |
loading = false;
|
21 |
loaded = false;
|
22 |
} |
23 |
|
24 |
protected void load() { |
25 |
if (loading || loaded || this.isNew()) { |
26 |
return;
|
27 |
} |
28 |
loading = true;
|
29 |
try {
|
30 |
this.store.loadFeatureDataByIndex(this); |
31 |
} catch (DataException e) {
|
32 |
throw new ReadRuntimeException("DBFFeatureData.load", e); |
33 |
} finally {
|
34 |
loading = false;
|
35 |
loaded = true;
|
36 |
} |
37 |
} |
38 |
|
39 |
public void set(int i, Object value) { |
40 |
this.load();
|
41 |
super.set(i, value);
|
42 |
} |
43 |
|
44 |
public void set(String name, Object value) { |
45 |
this.load();
|
46 |
super.set(featureType.getIndex(name), value);
|
47 |
} |
48 |
|
49 |
public Object get(int i) { |
50 |
this.load();
|
51 |
return super.get(i); |
52 |
} |
53 |
|
54 |
public Object get(String name) { |
55 |
this.load();
|
56 |
return super.get(name); |
57 |
} |
58 |
|
59 |
public Geometry getDefaultGeometry() {
|
60 |
this.load();
|
61 |
return this.defaultGeometry; |
62 |
} |
63 |
|
64 |
public Envelope getDefaultEnvelope() {
|
65 |
return this.envelope; |
66 |
} |
67 |
|
68 |
public void setOID(Object oid) { |
69 |
this.loaded = false; |
70 |
super.setOID(oid);
|
71 |
} |
72 |
|
73 |
public FeatureProvider getCopy() {
|
74 |
this.load();
|
75 |
return super.getCopy(); |
76 |
} |
77 |
|
78 |
} |