Skip to content

Commit e8279e0

Browse files
committed
Update CSVEncoder.
1 parent 0531b66 commit e8279e0

File tree

2 files changed

+46
-59
lines changed

2 files changed

+46
-59
lines changed

kilo-client/src/main/java/org/httprpc/kilo/io/CSVEncoder.java

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.io.Writer;
2121
import java.text.Format;
2222
import java.util.Date;
23-
import java.util.HashMap;
2423
import java.util.List;
2524
import java.util.Map;
2625
import java.util.ResourceBundle;
@@ -33,13 +32,11 @@
3332
public class CSVEncoder extends Encoder<Iterable<?>> {
3433
private List<String> keys;
3534

36-
private ResourceBundle resourceBundle = null;
37-
3835
private Format numberFormat = null;
3936
private Format booleanFormat = null;
4037
private Format dateFormat = null;
4138

42-
private Map<String, Format> formats = new HashMap<>();
39+
private ResourceBundle resourceBundle = null;
4340

4441
private static final char DELIMITER = ',';
4542

@@ -57,27 +54,6 @@ public CSVEncoder(List<String> keys) {
5754
this.keys = keys;
5855
}
5956

60-
/**
61-
* Returns the resource bundle.
62-
*
63-
* @return
64-
* The resource bundle, or {@code null} if a resource bundle has not been
65-
* set.
66-
*/
67-
public ResourceBundle getResourceBundle() {
68-
return resourceBundle;
69-
}
70-
71-
/**
72-
* Sets the resource bundle.
73-
*
74-
* @param resourceBundle
75-
* The resource bundle, or {@code null} for no resource bundle.
76-
*/
77-
public void setResourceBundle(ResourceBundle resourceBundle) {
78-
this.resourceBundle = resourceBundle;
79-
}
80-
8157
/**
8258
* Returns the number format.
8359
*
@@ -138,6 +114,27 @@ public void setDateFormat(Format dateFormat) {
138114
this.dateFormat = dateFormat;
139115
}
140116

117+
/**
118+
* Returns the resource bundle.
119+
*
120+
* @return
121+
* The resource bundle, or {@code null} if a resource bundle has not been
122+
* set.
123+
*/
124+
public ResourceBundle getResourceBundle() {
125+
return resourceBundle;
126+
}
127+
128+
/**
129+
* Sets the resource bundle.
130+
*
131+
* @param resourceBundle
132+
* The resource bundle, or {@code null} for no resource bundle.
133+
*/
134+
public void setResourceBundle(ResourceBundle resourceBundle) {
135+
this.resourceBundle = resourceBundle;
136+
}
137+
141138
@Override
142139
public void write(Iterable<?> rows, Writer writer) throws IOException {
143140
if (rows == null || writer == null) {
@@ -189,17 +186,7 @@ private void encode(Iterable<?> rows, Writer writer) throws IOException {
189186
writer.write(DELIMITER);
190187
}
191188

192-
var value = map.get(key);
193-
194-
if (value != null) {
195-
var format = formats.get(key);
196-
197-
if (format != null) {
198-
value = format.format(value);
199-
}
200-
}
201-
202-
encode(value, writer);
189+
encode(map.get(key), writer);
203190

204191
i++;
205192
}

kilo-client/src/main/java/org/httprpc/kilo/io/TemplateEncoder.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,11 @@ public Set<Entry<Object, Object>> entrySet() {
284284

285285
private URI uri;
286286

287-
private ResourceBundle resourceBundle = null;
288-
289287
private Locale locale = Locale.getDefault();
290288
private TimeZone timeZone = TimeZone.getDefault();
291289

290+
private ResourceBundle resourceBundle = null;
291+
292292
private Modifier defaultModifier = new MarkupModifier();
293293

294294
private Map<String, Modifier> modifiers = mapOf(
@@ -347,27 +347,6 @@ public TemplateEncoder(Class<?> type, String name) {
347347
}
348348
}
349349

350-
/**
351-
* Returns the resource bundle.
352-
*
353-
* @return
354-
* The resource bundle, or {@code null} if a resource bundle has not been
355-
* set.
356-
*/
357-
public ResourceBundle getResourceBundle() {
358-
return resourceBundle;
359-
}
360-
361-
/**
362-
* Sets the resource bundle.
363-
*
364-
* @param resourceBundle
365-
* The resource bundle, or {@code null} for no resource bundle.
366-
*/
367-
public void setResourceBundle(ResourceBundle resourceBundle) {
368-
this.resourceBundle = resourceBundle;
369-
}
370-
371350
/**
372351
* Returns the locale.
373352
*
@@ -416,6 +395,27 @@ public void setTimeZone(TimeZone timeZone) {
416395
this.timeZone = timeZone;
417396
}
418397

398+
/**
399+
* Returns the resource bundle.
400+
*
401+
* @return
402+
* The resource bundle, or {@code null} if a resource bundle has not been
403+
* set.
404+
*/
405+
public ResourceBundle getResourceBundle() {
406+
return resourceBundle;
407+
}
408+
409+
/**
410+
* Sets the resource bundle.
411+
*
412+
* @param resourceBundle
413+
* The resource bundle, or {@code null} for no resource bundle.
414+
*/
415+
public void setResourceBundle(ResourceBundle resourceBundle) {
416+
this.resourceBundle = resourceBundle;
417+
}
418+
419419
/**
420420
* Returns the default modifier.
421421
*

0 commit comments

Comments
 (0)