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.dbf / src / main / java / org / gvsig / fmap / dal / store / dbf / DBFStoreParameters.java @ 40435
History | View | Annotate | Download (2.79 KB)
1 | 40435 | jjdelcerro | package org.gvsig.fmap.dal.store.dbf; |
---|---|---|---|
2 | |||
3 | import java.io.File; |
||
4 | import java.nio.charset.Charset; |
||
5 | |||
6 | import org.gvsig.fmap.dal.DataStoreParameters; |
||
7 | import org.gvsig.fmap.dal.FileHelper; |
||
8 | import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
||
9 | import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
||
10 | import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
||
11 | import org.gvsig.tools.dynobject.DelegatedDynObject; |
||
12 | |||
13 | |||
14 | public class DBFStoreParameters extends AbstractDataParameters implements |
||
15 | DataStoreParameters, FilesystemStoreParameters { |
||
16 | |||
17 | public static final String PARAMETERS_DEFINITION_NAME = "DBFStoreParameters"; |
||
18 | |||
19 | public static final String DBFFILE_PARAMTER_NAME = "dbfFile"; |
||
20 | public static final String ENCODING_PARAMTER_NAME = "encoding"; |
||
21 | |||
22 | private DelegatedDynObject parameters;
|
||
23 | |||
24 | public DBFStoreParameters() {
|
||
25 | this(PARAMETERS_DEFINITION_NAME);
|
||
26 | } |
||
27 | |||
28 | protected DBFStoreParameters(String parametersDefinitionName) { |
||
29 | this(parametersDefinitionName, DBFStoreProvider.NAME);
|
||
30 | } |
||
31 | |||
32 | public DBFStoreParameters(String parametersDefinitionName, String name) { |
||
33 | super();
|
||
34 | this.parameters = (DelegatedDynObject) FileHelper.newParameters(parametersDefinitionName);
|
||
35 | this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, name);
|
||
36 | } |
||
37 | |||
38 | public String getDataStoreName() { |
||
39 | return (String) this.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME); |
||
40 | } |
||
41 | |||
42 | public String getDescription() { |
||
43 | return this.getDynClass().getDescription(); |
||
44 | } |
||
45 | |||
46 | public boolean isValid() { |
||
47 | return (this.getDBFFileName() != null); |
||
48 | } |
||
49 | |||
50 | public File getFile() { |
||
51 | return (File) this.getDynValue(DBFFILE_PARAMTER_NAME); |
||
52 | } |
||
53 | |||
54 | public void setFile(File file) { |
||
55 | this.setDynValue(DBFFILE_PARAMTER_NAME, file);
|
||
56 | } |
||
57 | |||
58 | public void setFile(String fileName) { |
||
59 | this.setDynValue(DBFFILE_PARAMTER_NAME, fileName);
|
||
60 | } |
||
61 | |||
62 | public String getDBFFileName() { |
||
63 | if( this.getDBFFile() == null ) { |
||
64 | return null; |
||
65 | } |
||
66 | return this.getDBFFile().getAbsolutePath(); |
||
67 | } |
||
68 | |||
69 | public File getDBFFile() { |
||
70 | return (File) this.getDynValue(DBFFILE_PARAMTER_NAME); |
||
71 | } |
||
72 | |||
73 | public void setDBFFile(File file) { |
||
74 | this.setDynValue(DBFFILE_PARAMTER_NAME, file);
|
||
75 | } |
||
76 | |||
77 | public void setDBFFile(String fileName) { |
||
78 | this.setDynValue(DBFFILE_PARAMTER_NAME, fileName);
|
||
79 | } |
||
80 | |||
81 | public String getEncodingName() { |
||
82 | return (String) getDynValue(ENCODING_PARAMTER_NAME); |
||
83 | } |
||
84 | |||
85 | public Charset getEncoding() { |
||
86 | String name = getEncodingName();
|
||
87 | if (name == null) { |
||
88 | return null; |
||
89 | } |
||
90 | return Charset.forName(name); |
||
91 | } |
||
92 | |||
93 | public void setEncoding(String encoding) { |
||
94 | this.setEncoding(Charset.forName(encoding)); |
||
95 | } |
||
96 | |||
97 | public void setEncoding(Charset charset) { |
||
98 | this.setDynValue(ENCODING_PARAMTER_NAME, charset.name());
|
||
99 | } |
||
100 | |||
101 | protected DelegatedDynObject getDelegatedDynObject() {
|
||
102 | return parameters;
|
||
103 | } |
||
104 | } |