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.csv / src / main / java / org / gvsig / export / csv / service / ExportCSVParametersImpl.java @ 44589
History | View | Annotate | Download (6.01 KB)
1 | 44310 | omartinez | package org.gvsig.export.csv.service; |
---|---|---|---|
2 | |||
3 | import java.io.File; |
||
4 | import org.apache.commons.io.FilenameUtils; |
||
5 | 44386 | omartinez | import org.apache.commons.lang3.StringUtils; |
6 | 44573 | jjdelcerro | import org.gvsig.export.spi.AbstractExportParametersGeometryFile; |
7 | 44555 | omartinez | import org.gvsig.expressionevaluator.ExpressionUtils; |
8 | 44310 | omartinez | import org.gvsig.fmap.dal.feature.FeatureType; |
9 | 44411 | omartinez | import org.gvsig.tools.ToolsLocator; |
10 | import org.gvsig.tools.dynobject.DynStruct; |
||
11 | 44555 | omartinez | import org.gvsig.tools.folders.FoldersManager; |
12 | 44411 | omartinez | import org.gvsig.tools.persistence.PersistenceManager; |
13 | import org.gvsig.tools.persistence.PersistentState; |
||
14 | import org.gvsig.tools.persistence.exception.PersistenceException; |
||
15 | 44310 | omartinez | |
16 | /**
|
||
17 | *
|
||
18 | * @author jjdelcerro
|
||
19 | */
|
||
20 | public class ExportCSVParametersImpl |
||
21 | 44573 | jjdelcerro | extends AbstractExportParametersGeometryFile
|
22 | 44310 | omartinez | implements ExportCSVParameters {
|
23 | |||
24 | private String encoding; |
||
25 | private File file; |
||
26 | private String profile; |
||
27 | private String charset; |
||
28 | private String escapeCharacter; |
||
29 | private String commentStartMarker; |
||
30 | private String quoteCharacter; |
||
31 | private String delimiter; |
||
32 | private String recordSeparator; |
||
33 | private String locale; |
||
34 | private String quotePolicy; |
||
35 | |||
36 | 44386 | omartinez | public ExportCSVParametersImpl(ExportCSVServiceFactory factory) {
|
37 | super(factory);
|
||
38 | 44573 | jjdelcerro | this.fileHelper.setFileExtension("csv"); |
39 | 44386 | omartinez | } |
40 | |||
41 | 44411 | omartinez | public ExportCSVParametersImpl() {
|
42 | 44573 | jjdelcerro | this(null); |
43 | 44411 | omartinez | } |
44 | |||
45 | 44310 | omartinez | @Override
|
46 | public String getServiceName() { |
||
47 | return ExportCSVServiceFactory.SERVICE_NAME;
|
||
48 | } |
||
49 | |||
50 | @Override
|
||
51 | public void setSourceFeatureType(FeatureType sourceFeatureType) { |
||
52 | super.setSourceFeatureType(sourceFeatureType);
|
||
53 | } |
||
54 | |||
55 | @Override
|
||
56 | public String getProfile() { |
||
57 | return this.profile; |
||
58 | } |
||
59 | |||
60 | @Override
|
||
61 | public void setProfile(String profile) { |
||
62 | this.profile = profile;
|
||
63 | } |
||
64 | |||
65 | @Override
|
||
66 | public String getQuotePolicy() { |
||
67 | return this.quotePolicy; |
||
68 | } |
||
69 | |||
70 | @Override
|
||
71 | public void setQuotePolicy(String quotePolicy) { |
||
72 | this.quotePolicy = quotePolicy;
|
||
73 | } |
||
74 | |||
75 | @Override
|
||
76 | public String getLocale() { |
||
77 | return this.locale; |
||
78 | } |
||
79 | |||
80 | @Override
|
||
81 | public void setLocale(String locale) { |
||
82 | this.locale = locale;
|
||
83 | } |
||
84 | |||
85 | @Override
|
||
86 | public String getRecordSeparator() { |
||
87 | return this.recordSeparator; |
||
88 | } |
||
89 | |||
90 | @Override
|
||
91 | public void setRecordSeparator(String recordSeparator) { |
||
92 | this.recordSeparator = recordSeparator;
|
||
93 | } |
||
94 | |||
95 | @Override
|
||
96 | public String getDelimiter() { |
||
97 | return this.delimiter; |
||
98 | } |
||
99 | |||
100 | @Override
|
||
101 | public void setDelimiter(String delimiter) { |
||
102 | this.delimiter = delimiter;
|
||
103 | } |
||
104 | |||
105 | @Override
|
||
106 | public String getQuoteCharacter() { |
||
107 | return this.quoteCharacter; |
||
108 | } |
||
109 | |||
110 | @Override
|
||
111 | public void setQuoteCharacter(String quoteCharacter) { |
||
112 | this.quoteCharacter = quoteCharacter;
|
||
113 | } |
||
114 | |||
115 | @Override
|
||
116 | public String getCommentStartMarker() { |
||
117 | return this.commentStartMarker; |
||
118 | } |
||
119 | |||
120 | @Override
|
||
121 | public void setCommentStartMarker(String commentStartMarker) { |
||
122 | 44395 | omartinez | this.commentStartMarker = commentStartMarker;
|
123 | 44310 | omartinez | } |
124 | |||
125 | @Override
|
||
126 | public String getEscapeCharacter() { |
||
127 | return this.escapeCharacter; |
||
128 | } |
||
129 | |||
130 | @Override
|
||
131 | public void setEscapeCharacter(String escapeCharacer) { |
||
132 | this.escapeCharacter = escapeCharacer;
|
||
133 | } |
||
134 | |||
135 | @Override
|
||
136 | public String getCharset() { |
||
137 | return this.charset; |
||
138 | } |
||
139 | |||
140 | @Override
|
||
141 | public void setCharset(String charset) { |
||
142 | this.charset = charset;
|
||
143 | } |
||
144 | 44395 | omartinez | |
145 | 44386 | omartinez | @Override
|
146 | public String toString() { |
||
147 | 44395 | omartinez | String label = StringUtils.join(super.getLabel(), ",", this.getProfile()); |
148 | 44386 | omartinez | return label;
|
149 | } |
||
150 | 44310 | omartinez | |
151 | 44411 | omartinez | public static void registerPersistence() { |
152 | |||
153 | PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
||
154 | if (manager.getDefinition("ExportCSVParametersImpl") == null) { |
||
155 | DynStruct definition = manager.addDefinition(ExportCSVParametersImpl.class, |
||
156 | "ExportCSVParametersImpl", "ExportCSVParametersImpl persistence definition", null, null); |
||
157 | |||
158 | definition.addDynFieldString("encoding");
|
||
159 | definition.addDynFieldFile("file");
|
||
160 | definition.addDynFieldString("profile");
|
||
161 | definition.addDynFieldString("charset");
|
||
162 | definition.addDynFieldString("escapeCharacter");
|
||
163 | definition.addDynFieldString("commentStartMarker");
|
||
164 | definition.addDynFieldString("quoteCharacter");
|
||
165 | definition.addDynFieldString("delimiter");
|
||
166 | definition.addDynFieldString("recordSeparator");
|
||
167 | definition.addDynFieldString("locale");
|
||
168 | definition.addDynFieldString("quotePolicy");
|
||
169 | |||
170 | 44573 | jjdelcerro | definition.extend(manager.getDefinition("AbstractExportParametersGeometryFile"));
|
171 | 44411 | omartinez | } |
172 | } |
||
173 | |||
174 | @Override
|
||
175 | public void saveToState(PersistentState state) throws PersistenceException { |
||
176 | super.saveToState(state);
|
||
177 | state.set("encoding", encoding);
|
||
178 | state.set("file", file);
|
||
179 | state.set("profile", profile);
|
||
180 | state.set("charset", charset);
|
||
181 | state.set("escapeCharacter", escapeCharacter);
|
||
182 | state.set("commentStartMarker", commentStartMarker);
|
||
183 | state.set("quoteCharacter", quoteCharacter);
|
||
184 | state.set("delimiter", delimiter);
|
||
185 | state.set("recordSeparator", recordSeparator);
|
||
186 | state.set("locale", locale);
|
||
187 | state.set("quotePolicy", quotePolicy);
|
||
188 | } |
||
189 | |||
190 | @Override
|
||
191 | public void loadFromState(PersistentState state) throws PersistenceException { |
||
192 | super.loadFromState(state);
|
||
193 | this.encoding = state.getString("encoding"); |
||
194 | this.file = state.getFile("file"); |
||
195 | this.profile = state.getString("profile"); |
||
196 | this.charset = state.getString("charset"); |
||
197 | this.escapeCharacter = state.getString("escapeCharacter"); |
||
198 | this.commentStartMarker = state.getString("commentStartMarker"); |
||
199 | this.quoteCharacter = state.getString("quoteCharacter"); |
||
200 | this.delimiter = state.getString("delimiter"); |
||
201 | this.recordSeparator = state.getString("recordSeparator"); |
||
202 | this.locale = state.getString("locale"); |
||
203 | this.quotePolicy = state.getString("quotePolicy"); |
||
204 | } |
||
205 | |||
206 | 44310 | omartinez | } |