|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| package org.rblasch.convert.converters; |
|
17 |
| |
|
18 |
| import org.rblasch.convert.type.Type; |
|
19 |
| import org.rblasch.convert.type.Types; |
|
20 |
| |
|
21 |
| import java.util.ArrayList; |
|
22 |
| import java.util.List; |
|
23 |
| import java.util.StringTokenizer; |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| public class StringToStringListConverter extends AbstractConverter { |
|
29 |
201
| public Type getSourceType() {
|
|
30 |
201
| return Types.findTypeByClass(String.class);
|
|
31 |
| } |
|
32 |
| |
|
33 |
201
| public Type getDestinationType() {
|
|
34 |
201
| return Types.findPTypeByClass(List.class, String.class);
|
|
35 |
| } |
|
36 |
| |
|
37 |
1
| public int getWeight() {
|
|
38 |
1
| return 100;
|
|
39 |
| } |
|
40 |
| |
|
41 |
1
| public Object convert(final Object obj) throws Exception {
|
|
42 |
1
| final String s = (String) obj;
|
|
43 |
| |
|
44 |
1
| final List l = new ArrayList();
|
|
45 |
1
| for (final StringTokenizer tokenizer = new StringTokenizer(s, ","); tokenizer.hasMoreTokens();) {
|
|
46 |
3
| l.add(tokenizer.nextToken());
|
|
47 |
| } |
|
48 |
| |
|
49 |
1
| return l;
|
|
50 |
| } |
|
51 |
| } |