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.dbf / src / main / java / org / gvsig / fmap / dal / store / dbf / DBFFeatureProvider.java @ 40559

History | View | Annotate | Download (2.54 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.dbf;
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 DBFFeatureProvider extends DefaultFeatureProvider {
35
        protected DBFStoreProvider store;
36
        protected boolean loading;
37
        protected boolean loaded;
38

    
39
        public DBFFeatureProvider(DBFStoreProvider store, FeatureType type) {
40
                super(type);
41
                this.store = store;
42
                loading = false;
43
                loaded = false;
44
        }
45

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

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

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

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

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

    
81
        public Geometry getDefaultGeometry() {
82
                return null;
83
        }
84

    
85
        public Envelope getDefaultEnvelope() {
86
                return null;
87
        }
88

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

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

    
99

    
100

    
101

    
102
}