Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dalfile / src / org / gvsig / fmap / dal / store / dbf / DBFStoreParameters.java @ 25789

History | View | Annotate | Download (2.39 KB)

1
package org.gvsig.fmap.dal.store.dbf;
2

    
3
import java.io.File;
4

    
5
import org.gvsig.fmap.dal.DataStoreParameters;
6
import org.gvsig.fmap.dal.DataTypes;
7
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
8
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
9
import org.gvsig.tools.ToolsLocator;
10
import org.gvsig.tools.dynobject.DelegatedDynObject;
11
import org.gvsig.tools.dynobject.DynClass;
12
import org.gvsig.tools.dynobject.DynField;
13
import org.gvsig.tools.dynobject.DynObjectManager;
14

    
15
public class DBFStoreParameters extends AbstractDataParameters implements
16
                DataStoreParameters, FilesystemStoreParameters {
17

    
18
    public static final String DYNCLASS_NAME = "DBFStoreParameters";
19

    
20
    protected static final String FIELD_DBFFILENAME = "dbffilename";
21

    
22
        protected static DynClass DYNCLASS = null;
23

    
24
    protected static void registerDynClass() {
25
                DynObjectManager dynman = ToolsLocator.getDynObjectManager();
26
                DynClass dynClass;
27
                DynField field;
28
                if (DYNCLASS == null) {
29
                        dynClass = dynman.add(DYNCLASS_NAME);
30

    
31
                        field = dynClass.addDynField(FIELD_DBFFILENAME);
32
                        field.setTheTypeOfAvailableValues(DynField.SINGLE);
33
                        field.setDescription("DBF file name");
34
                        field.setType(DataTypes.STRING);
35
                        field.setMandatory(true);
36
                        DYNCLASS = dynClass;
37
                }
38

    
39
        }
40

    
41
        public DBFStoreParameters() {
42
                super();
43
                initialize();
44
        }
45

    
46
        protected void initialize() {
47
                this.delegatedDynObjet = (DelegatedDynObject) ToolsLocator
48
                                .getDynObjectManager()
49
                                .createDynObject(
50
                                                DBFStoreParameters.DYNCLASS);
51
        }
52

    
53
        public String getDataStoreName() {
54
                return DBFStoreProvider.NAME;
55
        }
56

    
57
        public boolean isValid() {
58
                return (this.getDBFFileName() != null);
59
        }
60

    
61
        public File getFile() {
62
                return new File(this.getDBFFileName());
63
        }
64

    
65
        public void setFile(File aFile) {
66
                this.setDBFFile(aFile);
67
        }
68

    
69
        public void setFile(String aFileName) {
70
                this.setDBFFileName(aFileName);
71
        }
72

    
73
        public String getDBFFileName() {
74
                return (String) this.getDynValue(FIELD_DBFFILENAME);
75
        }
76

    
77
        public File getDBFFile() {
78
                return new File((String) this.getDynValue(FIELD_DBFFILENAME));
79
        }
80

    
81
        public void setDBFFile(File aFile) {
82
                this.setDynValue(FIELD_DBFFILENAME, aFile.getPath());
83
        }
84

    
85
        public void setDBFFileName(String aFileName) {
86
                this.setDynValue(FIELD_DBFFILENAME, aFileName);
87
        }
88

    
89
        public String getDescription() {
90
                return DBFStoreProvider.DESCRIPTION;
91
        }
92
}