root / branches / v2_0_0_prep / libraries / libFMap_dalfile / src / org / gvsig / fmap / dal / store / dxf / DXFStoreParameters.java @ 25789
History | View | Annotate | Download (3.67 KB)
1 |
package org.gvsig.fmap.dal.store.dxf; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
|
5 |
import org.cresques.cts.IProjection; |
6 |
import org.gvsig.fmap.crs.CRSFactory; |
7 |
import org.gvsig.fmap.dal.DataStoreParameters; |
8 |
import org.gvsig.fmap.dal.DataTypes; |
9 |
import org.gvsig.fmap.dal.feature.FeatureType; |
10 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
11 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
12 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
13 |
import org.gvsig.tools.ToolsLocator; |
14 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
15 |
import org.gvsig.tools.dynobject.DynClass; |
16 |
import org.gvsig.tools.dynobject.DynField; |
17 |
import org.gvsig.tools.dynobject.DynObjectManager; |
18 |
|
19 |
public class DXFStoreParameters extends AbstractDataParameters implements |
20 |
DataStoreParameters, FilesystemStoreParameters, |
21 |
NewFeatureStoreParameters { |
22 |
|
23 |
public static final String DYNCLASS_NAME = "DXFStoreParameters"; |
24 |
|
25 |
private static final String FIELD_FILEPATH = "filepath"; |
26 |
private static final String FIELD_SRSID = "srsid"; |
27 |
|
28 |
public DXFStoreParameters() {
|
29 |
this.delegatedDynObjet = (DelegatedDynObject) ToolsLocator
|
30 |
.getDynObjectManager() |
31 |
.createDynObject(registerDynClass()); |
32 |
} |
33 |
|
34 |
public String getDataStoreName() { |
35 |
return DXFStoreProvider.NAME;
|
36 |
} |
37 |
|
38 |
public String getDescription() { |
39 |
return DXFStoreProvider.DESCRIPTION;
|
40 |
} |
41 |
|
42 |
public String getSRSID() { |
43 |
return (String) getDynValue(FIELD_SRSID); |
44 |
} |
45 |
|
46 |
public void setSRSID(String srsid) { |
47 |
setDynValue(FIELD_SRSID, srsid); |
48 |
} |
49 |
|
50 |
public IProjection getCRS() {
|
51 |
if (this.getSRSID() == null) { |
52 |
return null; |
53 |
} |
54 |
return CRSFactory.getCRS(this.getSRSID()); |
55 |
} |
56 |
|
57 |
public String getFileName() { |
58 |
return (String) getDynValue(FIELD_FILEPATH); |
59 |
} |
60 |
|
61 |
public void setFileName(String file) { |
62 |
setDynValue(FIELD_FILEPATH, file); |
63 |
} |
64 |
|
65 |
public boolean isValid() { |
66 |
if (getSRSID() == null || getSRSID().equals("")) { |
67 |
return false; |
68 |
} |
69 |
if (getFileName() == null) { |
70 |
return false; |
71 |
} |
72 |
return true; |
73 |
} |
74 |
|
75 |
public File getFile() { |
76 |
return new File(this.getFileName()); |
77 |
} |
78 |
|
79 |
public void setFile(File file) { |
80 |
this.setFileName(file.getPath());
|
81 |
} |
82 |
|
83 |
public FeatureType getDefaultFeatureType() {
|
84 |
return null; //TODO ???? |
85 |
} |
86 |
|
87 |
public void setDefaultFeatureType(FeatureType defaultFeatureType) { |
88 |
throw new UnsupportedOperationException(); |
89 |
} |
90 |
|
91 |
private DynClass registerDynClass() {
|
92 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
93 |
DynClass dynClass = dynman.get(DYNCLASS_NAME); |
94 |
DynField field; |
95 |
if (dynClass == null) { |
96 |
dynClass = dynman.add(DYNCLASS_NAME); |
97 |
|
98 |
field = dynClass.addDynField(FIELD_SRSID); |
99 |
field.setType(DataTypes.STRING); |
100 |
field.setDescription("The SRS identifier");
|
101 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
102 |
|
103 |
field = dynClass.addDynField(FIELD_FILEPATH); |
104 |
field.setType(DataTypes.STRING); |
105 |
field.setDescription("The DXF file path");
|
106 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
107 |
} |
108 |
return dynClass;
|
109 |
} |
110 |
|
111 |
// public XMLEntity getXMLEntity() {
|
112 |
// XMLEntity xmlEntity = super.getXMLEntity();
|
113 |
// xmlEntity.putProperty("srsid", this.getSRSID());
|
114 |
// xmlEntity.putProperty("file", this.getFileName());
|
115 |
// return xmlEntity;
|
116 |
// }
|
117 |
//
|
118 |
// public void loadFromXMLEntity(XMLEntity xmlEntity)
|
119 |
// throws InitializeException {
|
120 |
// try {
|
121 |
// this.setSRSID(xmlEntity.getStringProperty("srsid"));
|
122 |
// this.setFileName(xmlEntity.getStringProperty("file"));
|
123 |
// } catch (NotExistInXMLEntity e) {
|
124 |
// throw new InitializeException(e);
|
125 |
// }
|
126 |
// }
|
127 |
|
128 |
|
129 |
// public DataParameters getCopy() throws DataException {
|
130 |
// DXFStoreParameters copy = new DXFStoreParameters();
|
131 |
// this.copyValuesTo(copy);
|
132 |
// return copy;
|
133 |
// }
|
134 |
|
135 |
} |