svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dataFile / src / org / gvsig / fmap / data / feature / file / dbf / DBFStoreParameters.java @ 23543
History | View | Annotate | Download (1.95 KB)
1 |
package org.gvsig.fmap.data.feature.file.dbf; |
---|---|
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.AbstractFileStoreParameters; |
8 |
import org.gvsig.fmap.data.feature.file.FileStoreParameters; |
9 |
|
10 |
import com.iver.utiles.NotExistInXMLEntity; |
11 |
import com.iver.utiles.XMLEntity; |
12 |
|
13 |
public class DBFStoreParameters extends AbstractFileStoreParameters implements |
14 |
FileStoreParameters { |
15 |
|
16 |
private File dbffile; |
17 |
|
18 |
public String getDataStoreName() { |
19 |
return DBFStore.DATASTORE_NAME;
|
20 |
} |
21 |
|
22 |
public boolean isValid() { |
23 |
return (dbffile != null); |
24 |
} |
25 |
|
26 |
/*
|
27 |
* (non-Javadoc)
|
28 |
*
|
29 |
* @see org.gvsig.fmap.data.feature.file.FileStoreParameters#getFile ()
|
30 |
*/
|
31 |
public File getFile() { |
32 |
return this.getDBFFile(); |
33 |
} |
34 |
|
35 |
/*
|
36 |
* (non-Javadoc)
|
37 |
*
|
38 |
* @see org.gvsig.fmap.data.feature.file.FileStoreParameters#setFile
|
39 |
* (java.io.File)
|
40 |
*/
|
41 |
public void setFile(File aFile) { |
42 |
super.setFile(aFile);
|
43 |
this.setDBFFile(aFile);
|
44 |
} |
45 |
|
46 |
protected File getDBFFile() { |
47 |
return dbffile;
|
48 |
} |
49 |
|
50 |
protected void setDBFFile(File aFile) { |
51 |
super.setFile(aFile);
|
52 |
this.dbffile = aFile;
|
53 |
} |
54 |
|
55 |
public boolean fileAccept(File f) { |
56 |
return f.getAbsolutePath().toLowerCase().endsWith(".dbf"); |
57 |
} |
58 |
|
59 |
public String getDescription() { |
60 |
return "DBF File"; |
61 |
} |
62 |
|
63 |
public XMLEntity getXMLEntity() {
|
64 |
XMLEntity xmlEntity = super.getXMLEntity();
|
65 |
xmlEntity.putProperty("dbffile", this.dbffile.getPath()); |
66 |
return xmlEntity;
|
67 |
} |
68 |
|
69 |
public void loadFromXMLEntity(XMLEntity xmlEntity) |
70 |
throws InitializeException {
|
71 |
super.loadFromXMLEntity(xmlEntity);
|
72 |
try{
|
73 |
this.dbffile = new File(xmlEntity.getStringProperty("dbffile")); |
74 |
} catch (NotExistInXMLEntity e) {
|
75 |
throw new InitializeException("dbffile property not found", this |
76 |
.getDataStoreName()); |
77 |
} |
78 |
} |
79 |
|
80 |
protected Map getInternalMap() { |
81 |
Map map = super.getInternalMap(); |
82 |
map.put("dbffile", this.dbffile); |
83 |
return map;
|
84 |
} |
85 |
} |