Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dalfile / src / org / gvsig / fmap / dal / store / shp / SHPStoreParameters.java @ 32880

History | View | Annotate | Download (3.33 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I. S.A.   {{Task}}
26
*/
27

    
28
package org.gvsig.fmap.dal.store.shp;
29

    
30
import java.io.File;
31

    
32
import org.cresques.cts.IProjection;
33
import org.gvsig.fmap.dal.store.dbf.DBFStoreParameters;
34
import org.gvsig.fmap.dal.store.shp.utils.SHP;
35

    
36
public class SHPStoreParameters extends DBFStoreParameters {
37

    
38
    public static final String PARAMETERS_DEFINITION_NAME = "SHPStoreParameters";
39

    
40
        private static final String SHXFILE_PARAMTER_NAME = "shxfile";
41
    private static final String SHPFILE_PARAMTER_NAME = "shpfile";
42
        private static final String CRS_PARAMTER_NAME = "CRS";
43

    
44
        public SHPStoreParameters() {
45
                this(PARAMETERS_DEFINITION_NAME);
46
        }
47

    
48
        public SHPStoreParameters(String parametersDefinitionName) {
49
                super(parametersDefinitionName, SHPStoreProvider.NAME);
50
        }
51

    
52
        public boolean isValid() {
53
                return super.isValid() && (this.getSHPFileName() != null);
54
        }
55

    
56
        public File getFile() {
57
                return this.getSHPFile();
58
        }
59

    
60
        public void setFile(File file) {
61
                this.setSHPFile(file);
62
        }
63
        public void setFile(String fileName) {
64
                this.setSHPFile(fileName);
65
        }
66
        
67
        
68
        public String getSHPFileName() {
69
                if( this.getSHPFile()==null ) {
70
                        return null;
71
                }
72
                return this.getSHPFile().getAbsolutePath();
73
        }
74

    
75
        public File getSHPFile() {
76
                return (File) this.getDynValue(SHPFILE_PARAMTER_NAME);
77
        }
78

    
79
        public void setSHPFile(File file) {
80
                this.setDynValue(SHPFILE_PARAMTER_NAME, file);
81
                if (this.getDBFFile() == null){
82
                        this.setDBFFile(SHP.getDbfFile(file));
83
                }
84
                if (this.getSHXFile() == null) {
85
                        this.setSHXFile(SHP.getShxFile(file));
86
                }
87
        }
88

    
89
        public void setSHPFile(String fileName) {
90
                this.setDynValue(SHPFILE_PARAMTER_NAME, fileName);
91
                File file = (File) this.getDynValue(SHPFILE_PARAMTER_NAME);
92
                if (this.getDBFFile() == null){
93
                        this.setDBFFile(SHP.getDbfFile(file));
94
                }
95
                if (this.getSHXFile() == null) {
96
                        this.setSHXFile(SHP.getShxFile(file));
97
                }
98
        }
99

    
100
        public String getSHXFileName() {
101
                return this.getSHXFile().getPath();
102
        }
103

    
104
        public File getSHXFile() {
105
                return (File) this.getDynValue(SHXFILE_PARAMTER_NAME);
106
        }
107
        public void setSHXFile(File file) {
108
                this.setDynValue(SHXFILE_PARAMTER_NAME, file);
109
        }
110

    
111
        public void setSHXFile(String fileName) {
112
                this.setDynValue(SHXFILE_PARAMTER_NAME, fileName);
113
        }
114

    
115
        public void setCRS(IProjection srs) {
116
                setDynValue(CRS_PARAMTER_NAME, srs);
117
        }
118

    
119
        public void setCRS(String srs) {
120
                setDynValue(CRS_PARAMTER_NAME, srs);
121
        }
122

    
123
        public IProjection getCRS() {
124
                return (IProjection) getDynValue(CRS_PARAMTER_NAME);
125
        }
126

    
127
}