1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.apache.ojb.broker.accesslayer.conversions.ConversionException;
23 import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
24
25 public class ListConverter implements FieldConversion{
26
27
28
29
30 private static final long serialVersionUID = 1L;
31
32 @Override
33 public Object javaToSql(Object arg0) throws ConversionException {
34 return arg0;
35 }
36
37
38
39
40 @Override
41 public Object sqlToJava(Object arg0) throws ConversionException {
42
43 String selectedValues = arg0.toString();
44 List<String> aList = new ArrayList<String>();
45
46 selectedValues = StringUtils.removeStart(selectedValues, "[");
47 selectedValues = StringUtils.removeEnd(selectedValues, "]");
48 String[] values = StringUtils.split(selectedValues, ",");
49
50 for(String value : values){
51 aList.add(StringUtils.strip(value, " "));
52 }
53
54
55 return aList;
56 }
57
58 }