1 |
| package photospace.web.spring; |
2 |
| |
3 |
| import java.beans.*; |
4 |
| import org.apache.commons.lang.*; |
5 |
| |
6 |
| public class LabelsEditor extends PropertyEditorSupport |
7 |
| { |
8 |
| private String split = ", "; |
9 |
| private String join = " "; |
10 |
| |
11 |
1
| public void setAsText(String text) throws IllegalArgumentException
|
12 |
| { |
13 |
1
| try
|
14 |
| { |
15 |
1
| if (text != null || !"".equals(text.trim()))
|
16 |
| { |
17 |
1
| String[] labels = StringUtils.split(text, split);
|
18 |
1
| for (int i = 0; i < labels.length; i++)
|
19 |
| { |
20 |
2
| labels[i] = labels[i].toLowerCase();
|
21 |
| } |
22 |
1
| setValue(labels);
|
23 |
| } |
24 |
| else |
25 |
| { |
26 |
0
| setValue(new String[0]);
|
27 |
| } |
28 |
| } |
29 |
| catch (Exception e) |
30 |
| { |
31 |
0
| throw new IllegalArgumentException("Error converting " + text + " to String[]");
|
32 |
| } |
33 |
| } |
34 |
| |
35 |
0
| public String getAsText()
|
36 |
| { |
37 |
0
| return StringUtils.join(((String[]) getValue()), join);
|
38 |
| } |
39 |
| |
40 |
| } |