Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.file / org.gvsig.fmap.dal.file.shp / src / main / java / org / gvsig / fmap / dal / store / shp / SHPFeatureProvider.java @ 40559

History | View | Annotate | Download (2.58 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal.store.shp;
25

    
26
import org.gvsig.fmap.dal.exception.DataException;
27
import org.gvsig.fmap.dal.exception.ReadRuntimeException;
28
import org.gvsig.fmap.dal.feature.FeatureType;
29
import org.gvsig.fmap.dal.feature.spi.DefaultFeatureProvider;
30
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
31
import org.gvsig.fmap.geom.Geometry;
32
import org.gvsig.fmap.geom.primitive.Envelope;
33

    
34
public class SHPFeatureProvider extends DefaultFeatureProvider {
35
        protected SHPStoreProvider store;
36
        protected boolean loading;
37
        protected boolean loaded;
38

    
39

    
40
        public SHPFeatureProvider(SHPStoreProvider store, FeatureType type) {
41
                super(type);
42
                this.store = store;
43
                loading = false;
44
                loaded = false;
45
        }
46

    
47
        protected void load() {
48
                if (loading || loaded || this.isNew()) {
49
                        return;
50
                }
51
                loading = true;
52
                try {
53
                        this.store.loadFeatureProviderByIndex(this);
54
                } catch (DataException e) {
55
                        throw new ReadRuntimeException("DBFFeatureProvider.load", e);
56
                } finally {
57
                        loading = false;
58
                        loaded = true;
59
                }
60
        }
61

    
62
        public void set(int i, Object value) {
63
                this.load();
64
                super.set(i, value);
65
        }
66

    
67
        public void set(String name, Object value) {
68
                this.load();
69
                super.set(featureType.getIndex(name), value);
70
        }
71

    
72
        public Object get(int i) {
73
                this.load();
74
                return super.get(i);
75
        }
76

    
77
        public Object get(String name) {
78
                this.load();
79
                return super.get(name);
80
        }
81

    
82
        public Geometry getDefaultGeometry() {
83
                this.load();
84
                return this.defaultGeometry;
85
        }
86

    
87
        public Envelope getDefaultEnvelope() {
88
                return this.envelope;
89
        }
90

    
91
        public void setOID(Object oid) {
92
                this.loaded = false;
93
                super.setOID(oid);
94
        }
95

    
96
        public FeatureProvider getCopy() {
97
                this.load();
98
                return super.getCopy();
99
        }
100

    
101
}