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 / SHPStoreParameters.java @ 40435
History | View | Annotate | Download (3.82 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.exception.ValidateDataParametersException; |
34 |
import org.gvsig.fmap.dal.store.dbf.DBFStoreParameters; |
35 |
import org.gvsig.fmap.dal.store.shp.utils.SHP; |
36 |
|
37 |
public class SHPStoreParameters extends DBFStoreParameters { |
38 |
|
39 |
public static final String PARAMETERS_DEFINITION_NAME = "SHPStoreParameters"; |
40 |
|
41 |
private static final String SHXFILE_PARAMTER_NAME = "shxfile"; |
42 |
private static final String SHPFILE_PARAMTER_NAME = "shpfile"; |
43 |
private static final String CRS_PARAMTER_NAME = "CRS"; |
44 |
|
45 |
public SHPStoreParameters() {
|
46 |
this(PARAMETERS_DEFINITION_NAME);
|
47 |
} |
48 |
|
49 |
@Override
|
50 |
public void validate() throws ValidateDataParametersException { |
51 |
fixParameters(); |
52 |
super.validate();
|
53 |
} |
54 |
|
55 |
public void fixParameters() { |
56 |
File file = this.getSHPFile(); |
57 |
if( file!=null ) { |
58 |
if (this.getDBFFile() == null){ |
59 |
this.setDBFFile(SHP.getDbfFile(file));
|
60 |
} |
61 |
if (this.getSHXFile() == null) { |
62 |
this.setSHXFile(SHP.getShxFile(file));
|
63 |
} |
64 |
} |
65 |
} |
66 |
|
67 |
public SHPStoreParameters(String parametersDefinitionName) { |
68 |
super(parametersDefinitionName, SHPStoreProvider.NAME);
|
69 |
} |
70 |
|
71 |
public boolean isValid() { |
72 |
return super.isValid() && (this.getSHPFileName() != null); |
73 |
} |
74 |
|
75 |
public File getFile() { |
76 |
return this.getSHPFile(); |
77 |
} |
78 |
|
79 |
public void setFile(File file) { |
80 |
this.setSHPFile(file);
|
81 |
} |
82 |
public void setFile(String fileName) { |
83 |
this.setSHPFile(fileName);
|
84 |
} |
85 |
|
86 |
|
87 |
public String getSHPFileName() { |
88 |
if( this.getSHPFile()==null ) { |
89 |
return null; |
90 |
} |
91 |
return this.getSHPFile().getAbsolutePath(); |
92 |
} |
93 |
|
94 |
public File getSHPFile() { |
95 |
return (File) this.getDynValue(SHPFILE_PARAMTER_NAME); |
96 |
} |
97 |
|
98 |
public void setSHPFile(File file) { |
99 |
this.setDynValue(SHPFILE_PARAMTER_NAME, file);
|
100 |
if (this.getDBFFile() == null){ |
101 |
this.setDBFFile(SHP.getDbfFile(file));
|
102 |
} |
103 |
if (this.getSHXFile() == null) { |
104 |
this.setSHXFile(SHP.getShxFile(file));
|
105 |
} |
106 |
} |
107 |
|
108 |
public void setSHPFile(String fileName) { |
109 |
this.setDynValue(SHPFILE_PARAMTER_NAME, fileName);
|
110 |
File file = (File) this.getDynValue(SHPFILE_PARAMTER_NAME); |
111 |
if (this.getDBFFile() == null){ |
112 |
this.setDBFFile(SHP.getDbfFile(file));
|
113 |
} |
114 |
if (this.getSHXFile() == null) { |
115 |
this.setSHXFile(SHP.getShxFile(file));
|
116 |
} |
117 |
} |
118 |
|
119 |
public String getSHXFileName() { |
120 |
if( this.getSHXFile()==null ) { |
121 |
return null; |
122 |
} |
123 |
return this.getSHXFile().getPath(); |
124 |
} |
125 |
|
126 |
public File getSHXFile() { |
127 |
return (File) this.getDynValue(SHXFILE_PARAMTER_NAME); |
128 |
} |
129 |
public void setSHXFile(File file) { |
130 |
this.setDynValue(SHXFILE_PARAMTER_NAME, file);
|
131 |
} |
132 |
|
133 |
public void setSHXFile(String fileName) { |
134 |
this.setDynValue(SHXFILE_PARAMTER_NAME, fileName);
|
135 |
} |
136 |
|
137 |
public void setCRS(IProjection srs) { |
138 |
setDynValue(CRS_PARAMTER_NAME, srs); |
139 |
} |
140 |
|
141 |
public void setCRS(String srs) { |
142 |
setDynValue(CRS_PARAMTER_NAME, srs); |
143 |
} |
144 |
|
145 |
public IProjection getCRS() {
|
146 |
return (IProjection) getDynValue(CRS_PARAMTER_NAME);
|
147 |
} |
148 |
|
149 |
} |