svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.prov / org.gvsig.exportto.swing.prov.shape / src / main / java / org / gvsig / export / shape / service / ExportShapeParametersImpl.java @ 44411
History | View | Annotate | Download (3.41 KB)
1 |
package org.gvsig.export.shape.service; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import org.apache.commons.io.FilenameUtils; |
5 |
import org.gvsig.export.ExportParameters; |
6 |
import org.gvsig.export.dbf.service.ExportDBFService; |
7 |
import org.gvsig.export.spi.AbstractExportParametersGeometry; |
8 |
import org.gvsig.export.spi.AttributeNamesTranslator; |
9 |
import org.gvsig.export.spi.CutAttributeNamesTranslator; |
10 |
import org.gvsig.fmap.dal.feature.FeatureType; |
11 |
import org.gvsig.tools.ToolsLocator; |
12 |
import org.gvsig.tools.dynobject.DynStruct; |
13 |
import org.gvsig.tools.persistence.PersistenceManager; |
14 |
import org.gvsig.tools.persistence.PersistentState; |
15 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
16 |
|
17 |
/**
|
18 |
*
|
19 |
* @author jjdelcerro
|
20 |
*/
|
21 |
public class ExportShapeParametersImpl |
22 |
extends AbstractExportParametersGeometry
|
23 |
implements ExportShapeParameters {
|
24 |
|
25 |
private String encoding; |
26 |
private File file; |
27 |
private boolean useSimplifiedExport = true; |
28 |
|
29 |
public ExportShapeParametersImpl(ExportShapeServiceFactory factory) {
|
30 |
super(factory);
|
31 |
AttributeNamesTranslator attr = new CutAttributeNamesTranslator(ExportDBFService.MAX_FIELD_NAME_LENGTH);
|
32 |
this.exportAttributes.setNamesTranslator(attr);
|
33 |
} |
34 |
|
35 |
public ExportShapeParametersImpl() {
|
36 |
super(null); |
37 |
} |
38 |
|
39 |
@Override
|
40 |
public String getServiceName() { |
41 |
return ExportShapeServiceFactory.SERVICE_NAME;
|
42 |
} |
43 |
|
44 |
@Override
|
45 |
public String getEncoding() { |
46 |
return this.encoding; |
47 |
} |
48 |
|
49 |
@Override
|
50 |
public void setEncoding(String encoding) { |
51 |
this.encoding = encoding;
|
52 |
} |
53 |
|
54 |
@Override
|
55 |
public File getFile() { |
56 |
return this.file; |
57 |
} |
58 |
|
59 |
@Override
|
60 |
public void setFile(File file) { |
61 |
this.file = new File(FilenameUtils.removeExtension(file.getAbsolutePath()) + ".shp"); |
62 |
} |
63 |
|
64 |
@Override
|
65 |
public boolean getUseSimplifiedExport() { |
66 |
return this.useSimplifiedExport; |
67 |
} |
68 |
|
69 |
@Override
|
70 |
public void setUseSimplifiedExport(boolean useSimplifiedExport) { |
71 |
this.useSimplifiedExport = useSimplifiedExport;
|
72 |
} |
73 |
|
74 |
@Override
|
75 |
public void setSourceFeatureType(FeatureType sourceFeatureType) { |
76 |
super.setSourceFeatureType(sourceFeatureType);
|
77 |
|
78 |
} |
79 |
|
80 |
public static void registerPersistence() { |
81 |
|
82 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
83 |
if (manager.getDefinition("ExportShapeParametersImpl") == null) { |
84 |
DynStruct definition = manager.addDefinition(ExportShapeParametersImpl.class, |
85 |
"ExportShapeParametersImpl", "ExportShapeParametersImpl persistence definition", null, null); |
86 |
definition.addDynFieldString("encoding");
|
87 |
definition.addDynFieldFile("file");
|
88 |
definition.addDynFieldBoolean("useSimplifiedExport");
|
89 |
definition.extend(manager.getDefinition("AbstractExportParametersGeometry"));
|
90 |
} |
91 |
} |
92 |
|
93 |
@Override
|
94 |
public void saveToState(PersistentState state) throws PersistenceException { |
95 |
super.saveToState(state);
|
96 |
state.set("encoding", this.encoding); |
97 |
state.set("file", this.file); |
98 |
state.set("useSimplifiedExport", this.useSimplifiedExport); |
99 |
} |
100 |
|
101 |
@Override
|
102 |
public void loadFromState(PersistentState state) throws PersistenceException { |
103 |
super.loadFromState(state);
|
104 |
this.encoding = state.getString("encoding"); |
105 |
this.file = state.getFile("file"); |
106 |
this.useSimplifiedExport = state.getBoolean("useSimplifiedExport"); |
107 |
} |
108 |
|
109 |
} |