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