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 @ 40559
History | View | Annotate | Download (3.87 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40559 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 40559 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | /*
|
||
25 | * AUTHORS (In addition to CIT):
|
||
26 | * 2008 IVER T.I. S.A. {{Task}}
|
||
27 | */
|
||
28 | |||
29 | package org.gvsig.fmap.dal.store.shp; |
||
30 | |||
31 | import java.io.File; |
||
32 | |||
33 | import org.cresques.cts.IProjection; |
||
34 | import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
||
35 | import org.gvsig.fmap.dal.store.dbf.DBFStoreParameters; |
||
36 | import org.gvsig.fmap.dal.store.shp.utils.SHP; |
||
37 | |||
38 | public class SHPStoreParameters extends DBFStoreParameters { |
||
39 | |||
40 | public static final String PARAMETERS_DEFINITION_NAME = "SHPStoreParameters"; |
||
41 | |||
42 | private static final String SHXFILE_PARAMTER_NAME = "shxfile"; |
||
43 | private static final String SHPFILE_PARAMTER_NAME = "shpfile"; |
||
44 | private static final String CRS_PARAMTER_NAME = "CRS"; |
||
45 | |||
46 | public SHPStoreParameters() {
|
||
47 | this(PARAMETERS_DEFINITION_NAME);
|
||
48 | } |
||
49 | |||
50 | @Override
|
||
51 | public void validate() throws ValidateDataParametersException { |
||
52 | fixParameters(); |
||
53 | super.validate();
|
||
54 | } |
||
55 | |||
56 | public void fixParameters() { |
||
57 | File file = this.getSHPFile(); |
||
58 | if( file!=null ) { |
||
59 | if (this.getDBFFile() == null){ |
||
60 | this.setDBFFile(SHP.getDbfFile(file));
|
||
61 | } |
||
62 | if (this.getSHXFile() == null) { |
||
63 | this.setSHXFile(SHP.getShxFile(file));
|
||
64 | } |
||
65 | } |
||
66 | } |
||
67 | |||
68 | public SHPStoreParameters(String parametersDefinitionName) { |
||
69 | super(parametersDefinitionName, SHPStoreProvider.NAME);
|
||
70 | } |
||
71 | |||
72 | public boolean isValid() { |
||
73 | return super.isValid() && (this.getSHPFileName() != null); |
||
74 | } |
||
75 | |||
76 | public File getFile() { |
||
77 | return this.getSHPFile(); |
||
78 | } |
||
79 | |||
80 | public void setFile(File file) { |
||
81 | this.setSHPFile(file);
|
||
82 | } |
||
83 | public void setFile(String fileName) { |
||
84 | this.setSHPFile(fileName);
|
||
85 | } |
||
86 | |||
87 | |||
88 | public String getSHPFileName() { |
||
89 | if( this.getSHPFile()==null ) { |
||
90 | return null; |
||
91 | } |
||
92 | return this.getSHPFile().getAbsolutePath(); |
||
93 | } |
||
94 | |||
95 | public File getSHPFile() { |
||
96 | return (File) this.getDynValue(SHPFILE_PARAMTER_NAME); |
||
97 | } |
||
98 | |||
99 | public void setSHPFile(File file) { |
||
100 | this.setDynValue(SHPFILE_PARAMTER_NAME, file);
|
||
101 | if (this.getDBFFile() == null){ |
||
102 | this.setDBFFile(SHP.getDbfFile(file));
|
||
103 | } |
||
104 | if (this.getSHXFile() == null) { |
||
105 | this.setSHXFile(SHP.getShxFile(file));
|
||
106 | } |
||
107 | } |
||
108 | |||
109 | public void setSHPFile(String fileName) { |
||
110 | this.setDynValue(SHPFILE_PARAMTER_NAME, fileName);
|
||
111 | File file = (File) this.getDynValue(SHPFILE_PARAMTER_NAME); |
||
112 | if (this.getDBFFile() == null){ |
||
113 | this.setDBFFile(SHP.getDbfFile(file));
|
||
114 | } |
||
115 | if (this.getSHXFile() == null) { |
||
116 | this.setSHXFile(SHP.getShxFile(file));
|
||
117 | } |
||
118 | } |
||
119 | |||
120 | public String getSHXFileName() { |
||
121 | if( this.getSHXFile()==null ) { |
||
122 | return null; |
||
123 | } |
||
124 | return this.getSHXFile().getPath(); |
||
125 | } |
||
126 | |||
127 | public File getSHXFile() { |
||
128 | return (File) this.getDynValue(SHXFILE_PARAMTER_NAME); |
||
129 | } |
||
130 | public void setSHXFile(File file) { |
||
131 | this.setDynValue(SHXFILE_PARAMTER_NAME, file);
|
||
132 | } |
||
133 | |||
134 | public void setSHXFile(String fileName) { |
||
135 | this.setDynValue(SHXFILE_PARAMTER_NAME, fileName);
|
||
136 | } |
||
137 | |||
138 | public void setCRS(IProjection srs) { |
||
139 | setDynValue(CRS_PARAMTER_NAME, srs); |
||
140 | } |
||
141 | |||
142 | public void setCRS(String srs) { |
||
143 | setDynValue(CRS_PARAMTER_NAME, srs); |
||
144 | } |
||
145 | |||
146 | public IProjection getCRS() {
|
||
147 | return (IProjection) getDynValue(CRS_PARAMTER_NAME);
|
||
148 | } |
||
149 | |||
150 | } |