1 package com.github.mygreen.supercsv.cellprocessor.conversion;
2
3 import org.supercsv.cellprocessor.CellProcessorAdaptor;
4 import org.supercsv.cellprocessor.ift.StringCellProcessor;
5 import org.supercsv.util.CsvContext;
6
7
8
9
10
11
12
13
14
15
16 public class Trim extends CellProcessorAdaptor implements StringCellProcessor {
17
18
19
20
21 public Trim() {
22 super();
23 }
24
25
26
27
28
29
30
31
32 public Trim(final StringCellProcessor next) {
33 super(next);
34 }
35
36 @SuppressWarnings("unchecked")
37 public Object execute(final Object value, final CsvContext context) {
38
39 if(value == null) {
40 return next.execute(value, context);
41 }
42
43 final String result = value.toString().trim();
44 return next.execute(result, context);
45 }
46
47 }