svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dataFile / src / org / gvsig / fmap / data / feature / file / shp / SHPStoreParameters.java @ 23543
History | View | Annotate | Download (3.21 KB)
1 |
package org.gvsig.fmap.data.feature.file.shp; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.util.Map; |
5 |
|
6 |
import org.gvsig.fmap.data.InitializeException; |
7 |
import org.gvsig.fmap.data.feature.file.dbf.DBFStoreParameters; |
8 |
import org.gvsig.fmap.data.feature.file.shp.utils.SHP; |
9 |
|
10 |
import com.iver.utiles.NotExistInXMLEntity; |
11 |
import com.iver.utiles.XMLEntity; |
12 |
public class SHPStoreParameters extends DBFStoreParameters { |
13 |
private File shpfile; |
14 |
private File shxfile; |
15 |
private String srs = null; |
16 |
|
17 |
public boolean isValid() { |
18 |
return super.isValid() && ( shpfile != null ) && (shxfile != null ); |
19 |
} |
20 |
public String getDataStoreName() { |
21 |
return SHPStore.DATASTORE_NAME;
|
22 |
} |
23 |
|
24 |
public File getFile() { |
25 |
return getSHPFile();
|
26 |
} |
27 |
|
28 |
public void setFile(File aFile) { |
29 |
this.setSHPFile(aFile);
|
30 |
} |
31 |
|
32 |
public void setSHPFile(File aFile){ |
33 |
shpfile=aFile; |
34 |
if (super.getDBFFile() == null){ |
35 |
super.setFile(SHP.getDbfFile(this.shpfile)); |
36 |
} |
37 |
if (this.shxfile == null){ |
38 |
this.shxfile = SHP.getShxFile(this.shpfile); |
39 |
} |
40 |
this.file = aFile;
|
41 |
|
42 |
} |
43 |
|
44 |
protected File getSHPFile(){ |
45 |
return this.shpfile; |
46 |
} |
47 |
|
48 |
protected File getSHXFile(){ |
49 |
return this.shxfile; |
50 |
} |
51 |
|
52 |
protected void setSHXFile(File file){ |
53 |
this.shxfile = file;
|
54 |
super.clearInternalMap();
|
55 |
} |
56 |
/**
|
57 |
* @return the srs
|
58 |
*/
|
59 |
public String getSRS() { |
60 |
return srs;
|
61 |
} |
62 |
/**
|
63 |
* @param srs the srs to set
|
64 |
*/
|
65 |
public void setSRS(String srs) { |
66 |
this.srs = srs;
|
67 |
super.clearInternalMap();
|
68 |
} |
69 |
/* (non-Javadoc)
|
70 |
* @see org.gvsig.fmap.data.feature.file.dbf.DBFStoreParameters#getDBFFile()
|
71 |
*/
|
72 |
protected File getDBFFile() { |
73 |
return super.getDBFFile(); |
74 |
} |
75 |
/* (non-Javadoc)
|
76 |
* @see org.gvsig.fmap.data.feature.file.dbf.DBFStoreParameters#setDBFFile(java.io.File)
|
77 |
*/
|
78 |
protected void setDBFFile(File aFile) { |
79 |
super.setDBFFile(aFile);
|
80 |
} |
81 |
public boolean fileAccept(File f) { |
82 |
return f.getAbsolutePath().toLowerCase().endsWith(".shp"); |
83 |
} |
84 |
|
85 |
public String getDescription() { |
86 |
return "Shp File"; |
87 |
} |
88 |
|
89 |
public XMLEntity getXMLEntity() {
|
90 |
XMLEntity xmlEntity = super.getXMLEntity();
|
91 |
xmlEntity.putProperty("shpfile", this.shpfile.getPath()); |
92 |
xmlEntity.putProperty("shxfile", this.shxfile.getPath()); |
93 |
xmlEntity.putProperty("srs", this.srs); |
94 |
return xmlEntity;
|
95 |
} |
96 |
|
97 |
public void loadFromXMLEntity(XMLEntity xmlEntity) |
98 |
throws InitializeException {
|
99 |
super.loadFromXMLEntity(xmlEntity);
|
100 |
try {
|
101 |
this.shpfile = new File(xmlEntity.getStringProperty("shpfile")); |
102 |
} catch (NotExistInXMLEntity e) {
|
103 |
throw new InitializeException("shpfile property not found", this |
104 |
.getDataStoreName()); |
105 |
} |
106 |
|
107 |
try {
|
108 |
this.shxfile = new File(xmlEntity.getStringProperty("shxfile")); |
109 |
} catch (NotExistInXMLEntity e) {
|
110 |
throw new InitializeException("shpfile property not found", this |
111 |
.getDataStoreName()); |
112 |
} |
113 |
|
114 |
try {
|
115 |
this.srs = xmlEntity.getStringProperty("srs"); |
116 |
} catch (NotExistInXMLEntity e) {
|
117 |
throw new InitializeException("shpfile property not found", this |
118 |
.getDataStoreName()); |
119 |
} |
120 |
|
121 |
} |
122 |
|
123 |
protected Map getInternalMap() { |
124 |
Map map = super.getInternalMap(); |
125 |
map.put("srs", this.srs); |
126 |
map.put("shpfile", this.shpfile.getPath()); |
127 |
map.put("shxfile", this.shxfile.getPath()); |
128 |
return map;
|
129 |
} |
130 |
|
131 |
} |