Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dataFile / src / org / gvsig / fmap / data / feature / file / dbf / DBFStoreParameters.java @ 23602

History | View | Annotate | Download (1.9 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.FileStoreParameters;
8

    
9
import com.iver.utiles.NotExistInXMLEntity;
10
import com.iver.utiles.XMLEntity;
11

    
12
public class DBFStoreParameters extends FileStoreParameters {
13

    
14

    
15
        protected Map createDefaultValuesMap() {
16
                Map defaultValues = super.createDefaultValuesMap();
17
                defaultValues.put("dbffile", null);
18
                return defaultValues;
19
        }
20
        public String getDataStoreName() {
21
                return DBFStore.DATASTORE_NAME;
22
        }
23

    
24
        public boolean isValid() {
25
                return (this.getDBFFile() != null);
26
        }
27

    
28
        /*
29
         * (non-Javadoc)
30
         * 
31
         * @see org.gvsig.fmap.data.feature.file.FileStoreParameters#getFile ()
32
         */
33
        public File getFile() {
34
                return this.getDBFFile();
35
        }
36

    
37
        /*
38
         * (non-Javadoc)
39
         * 
40
         * @see org.gvsig.fmap.data.feature.file.FileStoreParameters#setFile
41
         * (java.io.File)
42
         */
43
        public void setFile(File aFile) {
44
                super.setFile(aFile);
45
                this.setDBFFile(aFile);
46
        }
47

    
48
        protected File getDBFFile() {
49
                return (File) this.get("dbffile");
50
        }
51

    
52
        protected void setDBFFile(File aFile) {
53
                super.setFile(aFile);
54
                this.put("dbffile", aFile);
55
        }
56

    
57
        public boolean fileAccept(File f) {
58
                return f.getAbsolutePath().toLowerCase().endsWith(".dbf");
59
        }
60

    
61
        public String getDescription() {
62
                return "DBF File";
63
        }
64

    
65
        public XMLEntity getXMLEntity() {
66
                XMLEntity xmlEntity = super.getXMLEntity();
67
                xmlEntity.putProperty("dbffile", this.getDBFFile().getPath());
68
                return xmlEntity;
69
        }
70

    
71
        public void loadFromXMLEntity(XMLEntity xmlEntity)
72
                        throws InitializeException {
73
                super.loadFromXMLEntity(xmlEntity);
74
                try{
75
                        this.setDBFFile(new File(xmlEntity.getStringProperty("dbffile")));
76
                } catch (NotExistInXMLEntity e) {
77
                        throw new InitializeException("dbffile property not found", this
78
                                        .getDataStoreName());
79
                }
80
        }
81

    
82
}